Skip to content

Commit

Permalink
SporeModManager: improve path argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Nov 9, 2023
1 parent 85a65ff commit 8c8e56c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions SporeModManager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 8c8e56c

Please sign in to comment.