summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-07-06 16:25:02 +0200
committerLubomir Rintel <lkundrak@v3.sk>2016-08-01 13:52:36 +0200
commit60f992c5d31228dabbca770d960fbf44f30e4493 (patch)
tree79b02616da8fd7d78d2a214c5ee2a790a2ace6e6
parent33cd5149f8c9399efdb60f3d4f1ed2d0779a74a7 (diff)
downloadNetworkManager-60f992c5d31228dabbca770d960fbf44f30e4493.tar.gz
cli: handle global usage with nmc_do_cmd()
-rw-r--r--clients/cli/nmcli.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c
index 0a8dcb5b74..89279eb6dc 100644
--- a/clients/cli/nmcli.c
+++ b/clients/cli/nmcli.c
@@ -78,9 +78,9 @@ nmcli_error_quark (void)
}
static void
-usage (const char *prog_name)
+usage (void)
{
- g_printerr (_("Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n"
+ g_printerr (_("Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }\n"
"\n"
"OPTIONS\n"
" -t[erse] terse output\n"
@@ -103,15 +103,7 @@ usage (const char *prog_name)
" d[evice] devices managed by NetworkManager\n"
" a[gent] NetworkManager secret agent or polkit agent\n"
" m[onitor] monitor NetworkManager changes\n"
- "\n"),
- prog_name);
-}
-
-static NMCResultCode
-do_help (NmCli *nmc, int argc, char **argv)
-{
- usage ("nmcli");
- return NMC_RESULT_SUCCESS;
+ "\n"));
}
static const NMCCommand nmcli_cmds[] = {
@@ -122,8 +114,7 @@ static const NMCCommand nmcli_cmds[] = {
{ "connection", do_connections, NULL },
{ "device", do_devices, NULL },
{ "agent", do_agent, NULL },
- { "help", do_help, NULL },
- { NULL, do_overview, NULL },
+ { NULL, do_overview, usage }
};
static NMCResultCode
@@ -270,7 +261,7 @@ parse_command_line (NmCli *nmc, int argc, char **argv)
g_print (_("nmcli tool, version %s\n"), NMCLI_VERSION);
return NMC_RESULT_SUCCESS;
} else if (matches (opt, "-help") == 0) {
- usage (base);
+ usage ();
return NMC_RESULT_SUCCESS;
} else {
g_string_printf (nmc->return_text, _("Error: Option '%s' is unknown, try 'nmcli -help'."), opt);