summaryrefslogtreecommitdiff
path: root/main
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 11:24:24 -0500
commitdc8dd56684c53230cf0eeac0f6f24f6e0df42b8e (patch)
treec68dea58476def9e16045148b43cd0328721b94f /main
parent0aecb8759b9c7a9de2bf95137b2f8deaa5d5eca6 (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/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')
-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 1599d107a..924df7ed5 100644
--- a/main/astmm.c
+++ b/main/astmm.c
@@ -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;
}
diff --git a/main/bridge.c b/main/bridge.c
index ce1c97aaf..ef0da013c 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -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;
}
diff --git a/main/ccss.c b/main/ccss.c
index 307f71b96..fb7318d5a 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -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;
diff --git a/main/cli.c b/main/cli.c
index 3ba743d75..26a2bac81 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -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)) {
diff --git a/main/pbx_app.c b/main/pbx_app.c
index b7e797d88..7dabda30d 100644
--- a/main/pbx_app.c
+++ b/main/pbx_app.c
@@ -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);
diff --git a/main/pbx_hangup_handler.c b/main/pbx_hangup_handler.c
index e013f3194..7bfd9f048 100644
--- a/main/pbx_hangup_handler.c
+++ b/main/pbx_hangup_handler.c
@@ -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) {