diff options
author | zuul <zuul@gerrit.asterisk.org> | 2017-02-14 14:16:26 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-02-14 14:16:26 -0600 |
commit | 0d6c99e7152c64c624f5662bf6074e15ab71bf80 (patch) | |
tree | 8ea24e532e836ca60dfb5853b7f2e041336e1ff3 /main/asterisk.c | |
parent | bc2104819ccb394e88f02705d2a4829f9500ee4b (diff) | |
parent | ea8a610776ca80ddb2302543e32b487896ad2f5c (diff) |
Merge "cli: Fix various CLI documentation and completion issues" into 13
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 24 |
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(®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: |