diff options
Diffstat (limited to 'main/cli.c')
-rw-r--r-- | main/cli.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/main/cli.c b/main/cli.c index 632883d39..ccdbb97c3 100644 --- a/main/cli.c +++ b/main/cli.c @@ -916,6 +916,7 @@ static char *handle_modlist(struct ast_cli_entry *e, int cmd, struct ast_cli_arg static char *handle_showcalls(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { + static const char * const completions[] = { "seconds", NULL }; struct timeval curtime = ast_tvnow(); int showuptime, printsec; @@ -923,7 +924,7 @@ static char *handle_showcalls(struct ast_cli_entry *e, int cmd, struct ast_cli_a case CLI_INIT: e->command = "core show calls [uptime]"; e->usage = - "Usage: core show calls [uptime] [seconds]\n" + "Usage: core show calls [uptime [seconds]]\n" " Lists number of currently active calls and total number of calls\n" " processed through PBX since last restart. If 'uptime' is specified\n" " the system uptime is also displayed. If 'seconds' is specified in\n" @@ -933,7 +934,7 @@ static char *handle_showcalls(struct ast_cli_entry *e, int cmd, struct ast_cli_a case CLI_GENERATE: if (a->pos != e->args) return NULL; - return a->n == 0 ? ast_strdup("seconds") : NULL; + return ast_cli_complete(a->word, completions, a->n); } /* regular handler */ @@ -1103,7 +1104,9 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar static char *handle_softhangup(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - struct ast_channel *c=NULL; + struct ast_channel *c = NULL; + static const char * const completions[] = { "all", NULL }; + char *complete; switch (cmd) { case CLI_INIT: @@ -1116,7 +1119,14 @@ static char *handle_softhangup(struct ast_cli_entry *e, int cmd, struct ast_cli_ " will see the hangup request.\n"; return NULL; case CLI_GENERATE: - return ast_complete_channels(a->line, a->word, a->pos, a->n, e->args); + if (a->pos != e->args) { + return NULL; + } + complete = ast_cli_complete(a->word, completions, a->n); + if (!complete) { + complete = ast_complete_channels(a->line, a->word, a->pos, a->n - 1, e->args); + } + return complete; } if (a->argc != 4) { @@ -1428,6 +1438,8 @@ static int channel_set_debug(void *obj, void *arg, void *data, int flags) static char *handle_core_set_debug_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ast_channel *c = NULL; + static const char * const completions_all[] = { "all", NULL }; + static const char * const completions_off[] = { "off", NULL }; struct channel_set_debug_args args = { .fd = a->fd, }; @@ -1440,10 +1452,15 @@ static char *handle_core_set_debug_channel(struct ast_cli_entry *e, int cmd, str " Enables/disables debugging on all or on a specific channel.\n"; return NULL; case CLI_GENERATE: - /* XXX remember to handle the optional "off" */ - if (a->pos != e->args) - return NULL; - return a->n == 0 ? ast_strdup("all") : ast_complete_channels(a->line, a->word, a->pos, a->n - 1, e->args); + if (a->pos == 4) { + char *complete = ast_cli_complete(a->word, completions_all, a->n); + if (!complete) { + complete = ast_complete_channels(a->line, a->word, a->pos, a->n - 1, e->args); + } + return complete; + } else if (a->pos == 5) { + return ast_cli_complete(a->word, completions_off, a->n); + } } if (cmd == (CLI_HANDLER + 1000)) { |