From c8974bc32de12ddbe280f12c3832f580b69cf0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 13 Nov 2012 14:19:49 +0100 Subject: [PATCH] cli: allow more forms of "help" command showing OBJECTs' description allow "-[h]elp" and "--[h]elp" in addition to "help" --- cli/src/connections.c | 11 ++++++++--- cli/src/devices.c | 8 ++++++-- cli/src/network-manager.c | 5 ++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cli/src/connections.c b/cli/src/connections.c index 4776e1a6af..409bf2ba6c 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -197,7 +197,9 @@ usage (void) " up id | uuid [iface ] [ap ] [--nowait] [--timeout ]\n" #endif " down id | uuid \n" - " delete id | uuid \n")); + " delete id | uuid \n" + "\n" + )); } /* The real commands that do something - i.e. not 'help', etc. */ @@ -1987,10 +1989,13 @@ parse_cmd (NmCli *nmc, int argc, char **argv) else if (matches(*argv, "delete") == 0) { nmc->return_value = do_connection_delete (nmc, argc-1, argv+1); } - else if (matches (*argv, "help") == 0) { + else if ( matches (*argv, "help") == 0 + || (g_str_has_prefix (*argv, "-") && matches ((*argv)+1, "help") == 0) + || (g_str_has_prefix (*argv, "--") && matches ((*argv)+2, "help") == 0)) { usage (); nmc->should_wait = FALSE; - } else { + } + else { usage (); g_string_printf (nmc->return_text, _("Error: 'con' command '%s' is not valid."), *argv); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; diff --git a/cli/src/devices.c b/cli/src/devices.c index fefb533aea..23ed1bfc7c 100644 --- a/cli/src/devices.c +++ b/cli/src/devices.c @@ -253,8 +253,9 @@ usage (void) " wifi connect <(B)SSID> [password ] [wep-key-type key|phrase] [iface ] [bssid ] [name ]\n" " [--private] [--nowait] [--timeout ]\n" #if WITH_WIMAX - " wimax [list [iface ] [nsp ]]\n\n" + " wimax [list [iface ] [nsp ]]\n" #endif + "\n" )); } @@ -2104,10 +2105,13 @@ do_devices (NmCli *nmc, int argc, char **argv) nmc->return_value = do_device_wimax (nmc, argc-1, argv+1); } #endif - else if (strcmp (*argv, "help") == 0) { + else if ( matches (*argv, "help") == 0 + || (g_str_has_prefix (*argv, "-") && matches ((*argv)+1, "help") == 0) + || (g_str_has_prefix (*argv, "--") && matches ((*argv)+2, "help") == 0)) { usage (); } else { + usage (); g_string_printf (nmc->return_text, _("Error: 'dev' command '%s' is not valid."), *argv); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; } diff --git a/cli/src/network-manager.c b/cli/src/network-manager.c index 927eadd193..8fb5f6cf60 100644 --- a/cli/src/network-manager.c +++ b/cli/src/network-manager.c @@ -578,10 +578,13 @@ do_network_manager (NmCli *nmc, int argc, char **argv) } } #endif - else if (strcmp (*argv, "help") == 0) { + else if ( matches (*argv, "help") == 0 + || (g_str_has_prefix (*argv, "-") && matches ((*argv)+1, "help") == 0) + || (g_str_has_prefix (*argv, "--") && matches ((*argv)+2, "help") == 0)) { usage (); } else { + usage (); g_string_printf (nmc->return_text, _("Error: 'nm' command '%s' is not valid."), *argv); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; }