Skip to content

Commit

Permalink
Support = for short options
Browse files Browse the repository at this point in the history
It unifies behavioe with long options and provide compatibility
with DNF4 and rpm.

Closes: #1353
  • Loading branch information
j-mracek committed Apr 24, 2024
1 parent 077c7b1 commit 5c9fb6f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libdnf5-cli/argument_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,18 @@ int ArgumentParser::NamedArg::parse_short(const char * option, int argc, const c
const char * arg_value;
int consumed_args;
if (has_value) {
if (option[1] != '\0') {
arg_value = option + 1;
consumed_args = 1;
} else {
if (option[1] == '\0') {
if (argc < 2) {
throw ArgumentParserNamedArgMissingValueError(M_("Missing value for named argument \"-{}\""), *option);
}
arg_value = argv[1];
consumed_args = 2;
} else if (option[1] == '=') {
arg_value = option + 2;
consumed_args = 1;
} else {
arg_value = option + 1;
consumed_args = 1;
}
} else {
arg_value = const_val.c_str();
Expand Down

0 comments on commit 5c9fb6f

Please sign in to comment.