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: rpm-software-management#1353
  • Loading branch information
j-mracek committed Apr 22, 2024
1 parent 077c7b1 commit 0832ffe
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libdnf5-cli/argument_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,20 @@ 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 {
printf("option has %s \n", option);
if (option[1] == '\0') {
printf("option %s \n", option);
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 0832ffe

Please sign in to comment.