From ea8a610776ca80ddb2302543e32b487896ad2f5c Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Sat, 11 Feb 2017 10:57:03 -0500 Subject: cli: Fix various CLI documentation and completion issues * app_minivm: Use built-in completion facilities to complete optional arguments. * app_voicemail: Use built-in completion facilities to complete optional arguments. * app_confbridge: Add missing colons after 'Usage' text. * chan_alsa: Use built-in completion facilities to complete optional arguments. * chan_sip: Use built-in completion facilities to complete optional arguments. Add completions for 'load' for 'sip show user', 'sip show peer', and 'sip qualify peer.' * chan_skinny: Correct and extend completions for 'skinny reset' and 'skinny show line.' * func_odbc: Correct completions for 'odbc read' and 'odbc write' * main/asterisk: Correct and extend completions for 'core show file version.' * main/astmm: Use built-in completion facilities to complete arguments for 'memory' commands. * main/bridge: Correct completions for 'bridge kick.' * main/ccss: Use built-in completion facilities to complete arguments for 'cc cancel' command. * main/cli: Add 'all' completion for 'channel request hangup.' Correct completions for 'core set debug channel.' Correct completions for 'core show calls.' * main/pbx_app: Remove redundant completions for 'core show applications.' * main/pbx_hangup_handler: Remove unused completions for 'core show hanguphandlers all.' * res_sorcery_memory_cache: Add completion for 'reload' argument of 'sorcery memory cache stale' and properly implement. Change-Id: Iee58c7392f6fec34ad9d596109117af87697bbca --- main/asterisk.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'main/asterisk.c') diff --git a/main/asterisk.c b/main/asterisk.c index 994dfbeb7..076ae6d22 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1064,35 +1064,30 @@ static char *handle_clear_profile(struct ast_cli_entry *e, int cmd, struct ast_c static char *handle_show_version_files(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { #define FORMAT "%-25.25s %-40.40s\n" + static const char * const completions[] = { "like", NULL }; struct registered_file *iterator; regex_t regexbuf; int havepattern = 0; int havename = 0; int count_files = 0; char *ret = NULL; - int matchlen, which = 0; - struct registered_file *find; switch (cmd) { case CLI_INIT: - e->command = "core show file version [like]"; + e->command = "core show file version"; e->usage = - "Usage: core show file version [like ]\n" + "Usage: core show file version [|like ]\n" " Lists the files along with the Asterisk version.\n" " Optional regular expression pattern is used to filter the file list.\n"; return NULL; case CLI_GENERATE: - matchlen = strlen(a->word); - if (a->pos != 3) + if (a->pos != 4) { return NULL; - AST_RWLIST_RDLOCK(®istered_files); - AST_RWLIST_TRAVERSE(®istered_files, find, list) { - if (!strncasecmp(a->word, find->file, matchlen) && ++which > a->n) { - ret = ast_strdup(find->file); - break; - } } - AST_RWLIST_UNLOCK(®istered_files); + ret = ast_cli_complete(a->word, completions, a->n); + if (!ret) { + ret = ast_complete_source_filename(a->word, a->n - 1); + } return ret; } @@ -1107,6 +1102,9 @@ static char *handle_show_version_files(struct ast_cli_entry *e, int cmd, struct return CLI_SHOWUSAGE; break; case 5: + if (!strcasecmp(a->argv[4], "like")) { + return CLI_SHOWUSAGE; + } havename = 1; break; case 4: -- cgit v1.2.3