]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
cli: Fix various CLI documentation and completion issues 36/4936/1
authorSean Bright <sean.bright@gmail.com>
Sat, 11 Feb 2017 15:57:03 +0000 (10:57 -0500)
committerSean Bright <sean.bright@gmail.com>
Mon, 13 Feb 2017 16:24:24 +0000 (11:24 -0500)
* 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/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

14 files changed:
apps/app_minivm.c
apps/app_voicemail.c
apps/confbridge/conf_config_parser.c
channels/chan_alsa.c
channels/chan_sip.c
channels/chan_skinny.c
funcs/func_odbc.c
main/astmm.c
main/bridge.c
main/ccss.c
main/cli.c
main/pbx_app.c
main/pbx_hangup_handler.c
res/res_sorcery_memory_cache.c

index c84b7d7dd637c338de1f8d12e78a9776a42ed683..5a017d6032cc04852e1a759ad9030b40d87a2ef6 100644 (file)
@@ -3016,11 +3016,9 @@ static char *complete_minivm_show_users(const char *line, const char *word, int
        struct minivm_account *vmu;
        const char *domain = "";
 
-       /* 0 - voicemail; 1 - list; 2 - accounts; 3 - for; 4 - <domain> */
+       /* 0 - minivm; 1 - list; 2 - accounts; 3 - for; 4 - <domain> */
        if (pos > 4)
                return NULL;
-       if (pos == 3)
-               return (state == 0) ? ast_strdup("for") : NULL;
        wordlen = strlen(word);
        AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) {
                if (!strncasecmp(word, vmu->domain, wordlen)) {
@@ -3042,9 +3040,9 @@ static char *handle_minivm_show_users(struct ast_cli_entry *e, int cmd, struct a
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "minivm list accounts";
+               e->command = "minivm list accounts [for]";
                e->usage =
-                       "Usage: minivm list accounts\n"
+                       "Usage: minivm list accounts [for <domain>]\n"
                        "       Lists all mailboxes currently set up\n";
                return NULL;
        case CLI_GENERATE:
index fe76bc0e3ccc063453e7ebfb4924df095112ff23..05d82d9735353e44dd553f86963e91ff6af73cb3 100644 (file)
@@ -12747,11 +12747,9 @@ static char *complete_voicemail_show_users(const char *line, const char *word, i
        struct ast_vm_user *vmu;
        const char *context = "";
 
-       /* 0 - show; 1 - voicemail; 2 - users; 3 - for; 4 - <context> */
+       /* 0 - voicemail; 1 - show; 2 - users; 3 - for; 4 - <context> */
        if (pos > 4)
                return NULL;
-       if (pos == 3)
-               return (state == 0) ? ast_strdup("for") : NULL;
        wordlen = strlen(word);
        AST_LIST_TRAVERSE(&users, vmu, list) {
                if (!strncasecmp(word, vmu->context, wordlen)) {
@@ -12774,7 +12772,7 @@ static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struc
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "voicemail show users";
+               e->command = "voicemail show users [for]";
                e->usage =
                        "Usage: voicemail show users [for <context>]\n"
                        "       Lists all mailboxes currently set up\n";
index 69d6f69eafd37c0025447d5f263cfde92ae26cca..c272a9057f11cb80b97a4922f4ab48f248331371 100644 (file)
@@ -1365,7 +1365,7 @@ static char *handle_cli_confbridge_show_user_profiles(struct ast_cli_entry *e, i
        case CLI_INIT:
                e->command = "confbridge show profile users";
                e->usage =
-                       "Usage confbridge show profile users\n";
+                       "Usage: confbridge show profile users\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
@@ -1395,7 +1395,7 @@ static char *handle_cli_confbridge_show_user_profile(struct ast_cli_entry *e, in
        case CLI_INIT:
                e->command = "confbridge show profile user";
                e->usage =
-                       "Usage confbridge show profile user [<profile name>]\n";
+                       "Usage: confbridge show profile user [<profile name>]\n";
                return NULL;
        case CLI_GENERATE:
                if (a->pos == 4) {
@@ -1516,7 +1516,7 @@ static char *handle_cli_confbridge_show_bridge_profiles(struct ast_cli_entry *e,
        case CLI_INIT:
                e->command = "confbridge show profile bridges";
                e->usage =
-                       "Usage confbridge show profile bridges\n";
+                       "Usage: confbridge show profile bridges\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
@@ -1548,7 +1548,7 @@ static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e,
        case CLI_INIT:
                e->command = "confbridge show profile bridge";
                e->usage =
-                       "Usage confbridge show profile bridge <profile name>\n";
+                       "Usage: confbridge show profile bridge <profile name>\n";
                return NULL;
        case CLI_GENERATE:
                if (a->pos == 4) {
@@ -1700,7 +1700,7 @@ static char *handle_cli_confbridge_show_menus(struct ast_cli_entry *e, int cmd,
        case CLI_INIT:
                e->command = "confbridge show menus";
                e->usage =
-                       "Usage confbridge show profile menus\n";
+                       "Usage: confbridge show profile menus\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
@@ -1734,7 +1734,7 @@ static char *handle_cli_confbridge_show_menu(struct ast_cli_entry *e, int cmd, s
        case CLI_INIT:
                e->command = "confbridge show menu";
                e->usage =
-                       "Usage confbridge show menu [<menu name>]\n";
+                       "Usage: confbridge show menu [<menu name>]\n";
                return NULL;
        case CLI_GENERATE:
                if (a->pos == 3) {
index 0e2b2577fbe53980cd5cae9f05e3e104c1156c82..5c028c3b317eb2980143471bf4317b0b911375ce 100644 (file)
@@ -639,29 +639,13 @@ static struct ast_channel *alsa_request(const char *type, struct ast_format_cap
        return tmp;
 }
 
-static char *autoanswer_complete(const char *line, const char *word, int pos, int state)
-{
-       switch (state) {
-               case 0:
-                       if (!ast_strlen_zero(word) && !strncasecmp(word, "on", MIN(strlen(word), 2)))
-                               return ast_strdup("on");
-               case 1:
-                       if (!ast_strlen_zero(word) && !strncasecmp(word, "off", MIN(strlen(word), 3)))
-                               return ast_strdup("off");
-               default:
-                       return NULL;
-       }
-
-       return NULL;
-}
-
 static char *console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
        char *res = CLI_SUCCESS;
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "console autoanswer";
+               e->command = "console autoanswer [on|off]";
                e->usage =
                        "Usage: console autoanswer [on|off]\n"
                        "       Enables or disables autoanswer feature.  If used without\n"
@@ -669,7 +653,7 @@ static char *console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli
                        "       The default value of autoanswer is in 'alsa.conf'.\n";
                return NULL;
        case CLI_GENERATE:
-               return autoanswer_complete(a->line, a->word, a->pos, a->n);
+               return NULL;
        }
 
        if ((a->argc != 2) && (a->argc != 3))
index 709d5ab45c4b4ff2fbb6c6d45b7bb63b88c3e41a..b23d60c6bb6335c65e51cd790feabee4bb70a0ce 100644 (file)
@@ -19584,7 +19584,7 @@ static char *sip_show_inuse(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "sip show inuse";
+               e->command = "sip show inuse [all]";
                e->usage =
                        "Usage: sip show inuse [all]\n"
                        "       List all SIP devices usage counters and limits.\n"
@@ -19774,7 +19774,7 @@ static char *sip_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "sip show users";
+               e->command = "sip show users [like]";
                e->usage =
                        "Usage: sip show users [like <pattern>]\n"
                        "       Lists all known SIP users.\n"
@@ -19913,7 +19913,7 @@ static char *sip_show_peers(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "sip show peers";
+               e->command = "sip show peers [like]";
                e->usage =
                        "Usage: sip show peers [like <pattern>]\n"
                        "       Lists all known SIP peers.\n"
@@ -20627,7 +20627,12 @@ static char *sip_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args
                        "       Option \"load\" forces lookup of peer in realtime storage.\n";
                return NULL;
        case CLI_GENERATE:
-               return complete_sip_show_peer(a->line, a->word, a->pos, a->n);
+               if (a->pos == 4) {
+                       static const char * const completions[] = { "load", NULL };
+                       return ast_cli_complete(a->word, completions, a->n);
+               } else {
+                       return complete_sip_show_peer(a->line, a->word, a->pos, a->n);
+               }
        }
        return _sip_show_peer(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
 }
@@ -20797,7 +20802,12 @@ static char *sip_qualify_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_a
                        "       Option \"load\" forces lookup of peer in realtime storage.\n";
                return NULL;
        case CLI_GENERATE:
-               return complete_sip_show_peer(a->line, a->word, a->pos, a->n);
+               if (a->pos == 4) {
+                       static const char * const completions[] = { "load", NULL };
+                       return ast_cli_complete(a->word, completions, a->n);
+               } else {
+                       return complete_sip_show_peer(a->line, a->word, a->pos, a->n);
+               }
        }
        return _sip_qualify_peer(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
 }
@@ -21168,7 +21178,12 @@ static char *sip_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args
                        "       Option \"load\" forces lookup of peer in realtime storage.\n";
                return NULL;
        case CLI_GENERATE:
-               return complete_sip_show_user(a->line, a->word, a->pos, a->n);
+               if (a->pos == 4) {
+                       static const char * const completions[] = { "load", NULL };
+                       return ast_cli_complete(a->word, completions, a->n);
+               } else {
+                       return complete_sip_show_user(a->line, a->word, a->pos, a->n);
+               }
        }
 
        if (a->argc < 4)
index fb6e619a1e5c4d7742deab3029e2b3aeec4d0950..56e6596902aafa0ef91ec6362d97d622671e5fcd 100644 (file)
@@ -3923,24 +3923,40 @@ static char *complete_skinny_show_device(const char *line, const char *word, int
 
 static char *complete_skinny_reset(const char *line, const char *word, int pos, int state)
 {
-       return (pos == 2 ? complete_skinny_devices(word, state) : NULL);
+       if (pos == 2) {
+               static const char * const completions[] = { "all", NULL };
+               char *ret = ast_cli_complete(word, completions, state);
+               if (!ret) {
+                       ret = complete_skinny_devices(word, state - 1);
+               }
+               return ret;
+       } else if (pos == 3) {
+               static const char * const completions[] = { "restart", NULL };
+               return ast_cli_complete(word, completions, state);
+       }
+
+       return NULL;
 }
 
 static char *complete_skinny_show_line(const char *line, const char *word, int pos, int state)
 {
-       struct skinny_device *d;
-       struct skinny_line *l;
-       int wordlen = strlen(word), which = 0;
+       if (pos == 3) {
+               struct skinny_device *d;
+               struct skinny_line *l;
+               int wordlen = strlen(word), which = 0;
 
-       if (pos != 3)
-               return NULL;
-
-       AST_LIST_TRAVERSE(&devices, d, list) {
-               AST_LIST_TRAVERSE(&d->lines, l, list) {
-                       if (!strncasecmp(word, l->name, wordlen) && ++which > state) {
-                               return ast_strdup(l->name);
+               AST_LIST_TRAVERSE(&devices, d, list) {
+                       AST_LIST_TRAVERSE(&d->lines, l, list) {
+                               if (!strncasecmp(word, l->name, wordlen) && ++which > state) {
+                                       return ast_strdup(l->name);
+                               }
                        }
                }
+       } else if (pos == 4) {
+               static const char * const completions[] = { "on", NULL };
+               return ast_cli_complete(word, completions, state);
+       } else if (pos == 5) {
+               return complete_skinny_devices(word, state);
        }
 
        return NULL;
@@ -4582,7 +4598,7 @@ static char *handle_skinny_show_line(struct ast_cli_entry *e, int cmd, struct as
        case CLI_INIT:
                e->command = "skinny show line";
                e->usage =
-                       "Usage: skinny show line <Line> [ on <DeviceID|DeviceName> ]\n"
+                       "Usage: skinny show line <Line> [on <DeviceID|DeviceName>]\n"
                        "       List all lineinformation of a specific line known to the Skinny subsystem.\n";
                return NULL;
        case CLI_GENERATE:
index 224cd7a7f683873027af1a396aa637a20cd5563e..bc892595c4ceb22b4c05828d55337351abc3acdb 100644 (file)
@@ -1419,7 +1419,8 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
                        AST_RWLIST_UNLOCK(&queries);
                        return NULL;
                } else if (a->pos == 4) {
-                       return a->n == 0 ? ast_strdup("exec") : NULL;
+                       static const char * const completions[] = { "exec", NULL };
+                       return ast_cli_complete(a->word, completions, a->n);
                } else {
                        return NULL;
                }
@@ -1625,7 +1626,8 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
                        AST_RWLIST_UNLOCK(&queries);
                        return NULL;
                } else if (a->pos == 5) {
-                       return a->n == 0 ? ast_strdup("exec") : NULL;
+                       static const char * const completions[] = { "exec", NULL };
+                       return ast_cli_complete(a->word, completions, a->n);
                } else {
                        return NULL;
                }
index 1599d107a7e1ab5be410c3fdb057d3f889fbb73b..924df7ed50269fc72a6f387f0d72aab4defd7d7a 100644 (file)
@@ -693,17 +693,12 @@ static char *handle_memory_atexit_list(struct ast_cli_entry *e, int cmd, struct
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "memory atexit list";
+               e->command = "memory atexit list {on|off}";
                e->usage =
                        "Usage: memory atexit list {on|off}\n"
                        "       Enable dumping a list of still allocated memory segments at exit.\n";
                return NULL;
        case CLI_GENERATE:
-               if (a->pos == 3) {
-                       const char * const options[] = { "off", "on", NULL };
-
-                       return ast_cli_complete(a->word, options, a->n);
-               }
                return NULL;
        }
 
@@ -730,7 +725,7 @@ static char *handle_memory_atexit_summary(struct ast_cli_entry *e, int cmd, stru
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "memory atexit summary";
+               e->command = "memory atexit summary {off|byline|byfunc|byfile}";
                e->usage =
                        "Usage: memory atexit summary {off|byline|byfunc|byfile}\n"
                        "       Summary of still allocated memory segments at exit options.\n"
@@ -742,11 +737,6 @@ static char *handle_memory_atexit_summary(struct ast_cli_entry *e, int cmd, stru
                        "       Note: byline, byfunc, and byfile are cumulative enables.\n";
                return NULL;
        case CLI_GENERATE:
-               if (a->pos == 3) {
-                       const char * const options[] = { "off", "byline", "byfunc", "byfile", NULL };
-
-                       return ast_cli_complete(a->word, options, a->n);
-               }
                return NULL;
        }
 
@@ -1045,7 +1035,7 @@ static char *handle_memory_backtrace(struct ast_cli_entry *e, int cmd, struct as
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "memory backtrace";
+               e->command = "memory backtrace {on|off}";
                e->usage =
                        "Usage: memory backtrace {on|off}\n"
                        "       Enable dumping an allocation backtrace with memory diagnostics.\n"
@@ -1053,11 +1043,6 @@ static char *handle_memory_backtrace(struct ast_cli_entry *e, int cmd, struct as
                        "       can be CPU intensive.\n";
                return NULL;
        case CLI_GENERATE:
-               if (a->pos == 2) {
-                       const char * const options[] = { "off", "on", NULL };
-
-                       return ast_cli_complete(a->word, options, a->n);
-               }
                return NULL;
        }
 
index ce1c97aaf2036008dbf4e68b74682c972deb3ea1..ef0da013c36cf4dd4a9f338eb287b20ac694985a 100644 (file)
@@ -5172,12 +5172,6 @@ static char *complete_bridge_participant(const char *bridge_name, const char *li
                return NULL;
        }
 
-       if (!state) {
-               ao2_ref(bridge, -1);
-               return ast_strdup("all");
-       }
-       state--;
-
        {
                SCOPED_LOCK(bridge_lock, bridge, ast_bridge_lock, ast_bridge_unlock);
 
@@ -5199,6 +5193,8 @@ static char *complete_bridge_participant(const char *bridge_name, const char *li
 
 static char *handle_bridge_kick_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
+       static const char * const completions[] = { "all", NULL };
+       char *complete;
        struct ast_bridge *bridge;
 
        switch (cmd) {
@@ -5215,7 +5211,11 @@ static char *handle_bridge_kick_channel(struct ast_cli_entry *e, int cmd, struct
                        return complete_bridge_live(a->word, a->n);
                }
                if (a->pos == 3) {
-                       return complete_bridge_participant(a->argv[2], a->line, a->word, a->pos, a->n);
+                       complete = ast_cli_complete(a->word, completions, a->n);
+                       if (!complete) {
+                               complete = complete_bridge_participant(a->argv[2], a->line, a->word, a->pos, a->n - 1);
+                       }
+                       return complete;
                }
                return NULL;
        }
index 307f71b96a1d4fe1840904baa72274d687aed3b6..fb7318d5ae6bb06a5c228d76aae1430a807354ce 100644 (file)
@@ -4572,11 +4572,9 @@ static char *complete_core_id(const char *line, const char *word, int pos, int s
 
 static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-       static const char * const option[] = { "core", "all", NULL };
-
        switch (cmd) {
        case CLI_INIT:
-               e->command = "cc cancel";
+               e->command = "cc cancel [core|all]";
                e->usage =
                        "Usage: cc cancel can be used in two ways.\n"
                        "       1. 'cc cancel core [core ID]' will cancel the CC transaction with\n"
@@ -4584,10 +4582,7 @@ static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
                        "       2. 'cc cancel all' will cancel all active CC transactions.\n";
                return NULL;
        case CLI_GENERATE:
-               if (a->pos == 2) {
-                       return ast_cli_complete(a->word, option, a->n);
-               }
-               if (a->pos == 3) {
+               if (a->pos == 3 && !strcasecmp(a->argv[2], "core")) {
                        return complete_core_id(a->line, a->word, a->pos, a->n);
                }
                return NULL;
index 3ba743d75d4a498164ea80a0b1d5c8e91ef8e4cc..26a2bac810ba9c56bfc1c369d8606b8c11d65cee 100644 (file)
@@ -918,6 +918,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;
 
@@ -925,7 +926,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"
@@ -935,7 +936,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 */
@@ -1105,7 +1106,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:
@@ -1118,7 +1121,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) {
@@ -1430,6 +1440,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,
        };
@@ -1442,10 +1454,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)) {
index b7e797d88b7e6f18aa97816fc96fba1f724532f8..7dabda30d95fabc0697d63681f7fd9616eac1315 100644 (file)
@@ -315,7 +315,6 @@ static char *handle_show_applications(struct ast_cli_entry *e, int cmd, struct a
        int like = 0, describing = 0;
        int total_match = 0;    /* Number of matches in like clause */
        int total_apps = 0;     /* Number of apps registered */
-       static const char * const choices[] = { "like", "describing", NULL };
 
        switch (cmd) {
        case CLI_INIT:
@@ -327,7 +326,7 @@ static char *handle_show_applications(struct ast_cli_entry *e, int cmd, struct a
                        "       If 'describing', <text> will be a substring of the description\n";
                return NULL;
        case CLI_GENERATE:
-               return (a->pos != 3) ? NULL : ast_cli_complete(a->word, choices, a->n);
+               return NULL;
        }
 
        AST_RWLIST_RDLOCK(&apps);
index e013f319445a9559bc66d4d6cdb0e9f4b8c1811c..7bfd9f048404f252964e9b1cf5f010ab186d2936 100644 (file)
@@ -260,7 +260,7 @@ static char *handle_show_hangup_all(struct ast_cli_entry *e, int cmd, struct ast
                        "       Show hangup handlers for all channels.\n";
                return NULL;
        case CLI_GENERATE:
-               return ast_complete_channels(a->line, a->word, a->pos, a->n, e->args);
+               return NULL;
        }
 
        if (a->argc < 4) {
index b6fdc8e6fa98a38ec6033d021d208eb50127dec0..00ddcdfd991471f660d860e193f71846650a0060 100644 (file)
@@ -1868,6 +1868,7 @@ static char *sorcery_memory_cache_expire(struct ast_cli_entry *e, int cmd, struc
 static char *sorcery_memory_cache_stale(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
        struct sorcery_memory_cache *cache;
+       int reload = 0;
 
        switch (cmd) {
        case CLI_INIT:
@@ -1883,6 +1884,9 @@ static char *sorcery_memory_cache_stale(struct ast_cli_entry *e, int cmd, struct
                        return sorcery_memory_cache_complete_name(a->word, a->n);
                } else if (a->pos == 5) {
                        return sorcery_memory_cache_complete_object_name(a->argv[4], a->word, a->n);
+               } else if (a->pos == 6) {
+                       static const char * const completions[] = { "reload", NULL };
+                       return ast_cli_complete(a->word, completions, a->n);
                } else {
                        return NULL;
                }
@@ -1892,6 +1896,14 @@ static char *sorcery_memory_cache_stale(struct ast_cli_entry *e, int cmd, struct
                return CLI_SHOWUSAGE;
        }
 
+       if (a->argc == 7) {
+               if (!strcasecmp(a->argv[6], "reload")) {
+                       reload = 1;
+               } else {
+                       return CLI_SHOWUSAGE;
+               }
+       }
+
        cache = ao2_find(caches, a->argv[4], OBJ_SEARCH_KEY);
        if (!cache) {
                ast_cli(a->fd, "Specified sorcery memory cache '%s' does not exist\n", a->argv[4]);
@@ -1912,7 +1924,7 @@ static char *sorcery_memory_cache_stale(struct ast_cli_entry *e, int cmd, struct
                if (!mark_object_as_stale_in_cache(cache, a->argv[5])) {
                        ast_cli(a->fd, "Successfully marked object '%s' in memory cache '%s' as stale\n",
                                a->argv[5], a->argv[4]);
-                       if (a->argc == 7 && ast_true(a->argv[6])) {
+                       if (reload) {
                                struct sorcery_memory_cached_object *cached;
 
                                cached = ao2_find(cache->objects, a->argv[5], OBJ_SEARCH_KEY | OBJ_NOLOCK);