Skip to content

Commit

Permalink
Fixed how valued option handling was being parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed May 11, 2023
1 parent 64dc082 commit ac5d7c6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion impl/command_line/arguments.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,13 @@ namespace substrate::commandLine
// Check if we're parsing a "simple" option
if (!option.matches(argument))
return std::nullopt;
const auto &token{lexer.next()};
// If the option matches, try parsing out and validating the value portion if there is one
if (!option.takesParameter())
{
lexer.next();
return flag_t{argument};
}
const auto &token{lexer.token()};
// Consume tokens to get to the value token if the option is not value-only
if (!option.valueOnly())
{
Expand All @@ -184,6 +187,7 @@ namespace substrate::commandLine
}
// Try parsing that parameter component as a value for the option
auto value{option.parseValue(token.value())};
lexer.next();
if (!value)
// If the operation fails, use monostate to signal match-but-fail.
return std::monostate{};
Expand Down

0 comments on commit ac5d7c6

Please sign in to comment.