diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2017-02-14 15:30:01 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2017-02-14 16:57:12 +0100 |
commit | 90380924b53472ff951a7def6edf92cefb60b14a (patch) | |
tree | 4c1e7d6054d399f56ed3fc5e0042c383608eb8e8 | |
parent | bbba58291fd0edd8ad8718c923fe1ce86d20be38 (diff) |
cli: complete the [-][-]help arguments
-rw-r--r-- | clients/cli/common.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clients/cli/common.c b/clients/cli/common.c index 47e858e77..ca9ec38ec 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 |