summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2017-02-14 14:34:03 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-02-14 14:34:03 -0600
commit182c7373535acae9a89f82538659a655041566b5 (patch)
treec87f5e0245249efb0d5eea77d4705589c578e9e9 /main
parentcea835e565ea690b99dfbc3240900a47694e186b (diff)
parent3f9437377809a8c1476a1195474eb3178b2c7934 (diff)
Merge "cli: Fix various CLI documentation and completion issues"
Diffstat (limited to 'main')
-rw-r--r--main/astmm.c21
-rw-r--r--main/bridge.c14
-rw-r--r--main/ccss.c9
-rw-r--r--main/cli.c33
-rw-r--r--main/pbx_app.c3
-rw-r--r--main/pbx_hangup_handler.c2
6 files changed, 39 insertions, 43 deletions
diff --git a/main/astmm.c b/main/astmm.c
index 0ad29a6fb..9c26f0fa7 100644
--- a/main/astmm.c
+++ b/main/astmm.c
@@ -691,17 +691,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;
}
@@ -728,7 +723,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"
@@ -740,11 +735,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;
}
@@ -1043,7 +1033,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"
@@ -1051,11 +1041,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;
}
diff --git a/main/bridge.c b/main/bridge.c
index 13c01fa27..b6ba0a2bf 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -5170,12 +5170,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);
@@ -5197,6 +5191,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) {
@@ -5213,7 +5209,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;
}
diff --git a/main/ccss.c b/main/ccss.c
index 6c3e6cbee..f96d7aa1d 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -4566,11 +4566,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"
@@ -4578,10 +4576,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;
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)) {
diff --git a/main/pbx_app.c b/main/pbx_app.c
index 0c030d12d..e0609db70 100644
--- a/main/pbx_app.c
+++ b/main/pbx_app.c
@@ -313,7 +313,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:
@@ -325,7 +324,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);
diff --git a/main/pbx_hangup_handler.c b/main/pbx_hangup_handler.c
index 554cb342f..84b53d0c1 100644
--- a/main/pbx_hangup_handler.c
+++ b/main/pbx_hangup_handler.c
@@ -258,7 +258,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) {