From 8c8e56cc45499039943e40a7c3972fb7998ce7a5 Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Thu, 9 Nov 2023 15:02:34 +0100 Subject: [PATCH] SporeModManager: improve path argument parsing --- SporeModManager/main.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/SporeModManager/main.cpp b/SporeModManager/main.cpp index 49b5a89..aba84e9 100644 --- a/SporeModManager/main.cpp +++ b/SporeModManager/main.cpp @@ -146,20 +146,29 @@ int main(int argc, char** argv) } for (const auto& pathArg : pathArgs) { - if (arg == pathArg.argument) + if (arg.rfind(pathArg.argument, 0) == 0) { - if (i == (args.size() - 1)) - { - ShowUsage(); - return 1; + arg.erase(0, pathArg.argument.size()); + if (!arg.empty() && arg.at(0) == arg_char('=')) + { // use path after = + arg.erase(0, 1); + pathArg.path = arg; + } + else + { // use next argument as path + if (i == (args.size() - 1)) + { + ShowUsage(); + return 1; + } + pathArg.path = args.at(i + 1); + args.erase(args.begin() + i + 1); } - pathArg.path = args.at(i + 1); if (!std::filesystem::is_directory(pathArg.path)) { ShowUsage(); return 1; } - args.erase(args.begin() + i + 1); arg.clear(); } }