cli: make command line parsing check for help option first
Move the checks for nmc_arg_is_help to the beginning of the checks for command matches. Up to now, no command begins with 'h', so this has no behavioral change whatsoever. But imagine a command that begins with 'h' (for example `nmcli general hostname`), in that case `nmcli general h` should still show the help, as users might be accustomed to this abbreviation. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -7290,7 +7290,11 @@ parse_cmd (NmCli *nmc, int argc, char **argv)
|
||||
goto opt_error;
|
||||
nmc->return_value = do_connections_show (nmc, argc, argv);
|
||||
} else {
|
||||
if (matches (*argv, "show") == 0) {
|
||||
if (nmc_arg_is_help (*argv)) {
|
||||
usage ();
|
||||
nmc->should_wait = FALSE;
|
||||
}
|
||||
else if (matches (*argv, "show") == 0) {
|
||||
arg_ret = next_arg (&argc, &argv);
|
||||
if (arg_ret != 0 || matches (*argv, "configured") == 0) {
|
||||
next_arg (&argc, &argv);
|
||||
@@ -7334,10 +7338,6 @@ parse_cmd (NmCli *nmc, int argc, char **argv)
|
||||
else if (matches (*argv, "modify") == 0) {
|
||||
nmc->return_value = do_connection_modify (nmc, argc-1, argv+1);
|
||||
}
|
||||
else if (nmc_arg_is_help (*argv)) {
|
||||
usage ();
|
||||
nmc->should_wait = FALSE;
|
||||
}
|
||||
else {
|
||||
usage ();
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' is not valid 'connection' command."), *argv);
|
||||
|
Reference in New Issue
Block a user