summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2017-02-14 15:30:01 +0100
committerLubomir Rintel <lkundrak@v3.sk>2017-02-15 11:16:19 +0100
commit29bb6ae4fec37db177418bae9d9462b577d3b2fd (patch)
tree80f15ec65ec74e203d6b93d51e550c940b4587af /clients
parent1a0c7792140dc58ce173191fa2a7de963b428ae2 (diff)
downloadNetworkManager-29bb6ae4fec37db177418bae9d9462b577d3b2fd.tar.gz
cli: complete the [-][-]help arguments
Diffstat (limited to 'clients')
-rw-r--r--clients/cli/common.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/clients/cli/common.c b/clients/cli/common.c
index 47e858e778..ca9ec38ec8 100644
--- a/clients/cli/common.c
+++ b/clients/cli/common.c
@@ -1643,6 +1643,14 @@ call_cmd (NmCli *nmc, GSimpleAsyncResult *simple, const NMCCommand *cmd, int arg
}
}
+static void
+nmc_complete_help (const char *prefix)
+{
+ nmc_complete_strings (prefix, "help", NULL);
+ if (*prefix == '-')
+ nmc_complete_strings (prefix, "-help", "--help", NULL);
+}
+
/**
* nmc_do_cmd:
* @nmc: Client instance
@@ -1684,6 +1692,7 @@ nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char
if (!*cmd || matches (cmd, c->cmd) == 0)
g_print ("%s\n", c->cmd);
}
+ nmc_complete_help (cmd);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
return;
@@ -1696,8 +1705,11 @@ nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char
if (c->cmd) {
/* A valid command was specified. */
+ if (c->usage && argc == 2 && nmc->complete)
+ nmc_complete_help (*(argv+1));
if (c->usage && nmc_arg_is_help (*(argv+1))) {
- c->usage ();
+ if (!nmc->complete)
+ c->usage ();
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
} else