Skip to content

Commit

Permalink
Fix a bug in parsing occa cli options
Browse files Browse the repository at this point in the history
  • Loading branch information
thilinarmtb committed Nov 1, 2024
1 parent 9ab654f commit 2f93eb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/occa/internal/utils/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ namespace occa {
}

occa::json parser::parseArgs(const strVector &args_,
const std::vector<command> &commands,
const bool supressErrors) {
strVector args = splitShortOptionArgs(args_);
const int argc = (int) args.size();
Expand Down Expand Up @@ -445,7 +446,12 @@ namespace occa {

// No option
if (!opt) {
checkOptions = (arg == "==");
for (auto cmd : commands) {
if (arg == cmd.name) {
checkOptions = 0;
break;
}
}
jArguments += arg;
continue;
}
Expand Down Expand Up @@ -779,7 +785,7 @@ namespace occa {

const bool hasCommands = commands.size();

json parsedArgs = parseArgs(shellArgs, supressErrors);
json parsedArgs = parseArgs(shellArgs, commands, supressErrors);
lastCommandArgs = parsedArgs;

json &jArguments = parsedArgs["arguments"];
Expand Down
3 changes: 3 additions & 0 deletions src/occa/internal/utils/cli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ namespace occa {
};
//==================================

class command;

//---[ Parser ]---------------------
class parser : public printable {
public:
Expand Down Expand Up @@ -157,6 +159,7 @@ namespace occa {

occa::json parseArgs(const int argc, const char **argv);
occa::json parseArgs(const strVector &args_,
const std::vector<command> &commands = {},
const bool supressErrors = false);

bool hasCustomHelpOption();
Expand Down

0 comments on commit 2f93eb2

Please sign in to comment.