summaryrefslogtreecommitdiff
path: root/main/asterisk.c
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-02-11 10:57:03 -0500
committerSean Bright <sean.bright@gmail.com>2017-02-13 10:57:16 -0500
commitea8a610776ca80ddb2302543e32b487896ad2f5c (patch)
tree99e81d8c71322715eedb8fa59cb2d72e807de512 /main/asterisk.c
parentc7fcc4468ffd54066129a982ff5b0a3cdfa7c5e0 (diff)
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
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c24
1 files changed, 11 insertions, 13 deletions
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 <pattern>]\n"
+ "Usage: core show file version [<filename>|like <pattern>]\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(&registered_files);
- AST_RWLIST_TRAVERSE(&registered_files, find, list) {
- if (!strncasecmp(a->word, find->file, matchlen) && ++which > a->n) {
- ret = ast_strdup(find->file);
- break;
- }
}
- AST_RWLIST_UNLOCK(&registered_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: