mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-03 19:16:46 +00:00
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
This commit is contained in:
33
main/cli.c
33
main/cli.c
@@ -917,6 +917,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;
|
||||
|
||||
@@ -924,7 +925,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"
|
||||
@@ -934,7 +935,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 */
|
||||
@@ -1104,7 +1105,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:
|
||||
@@ -1117,7 +1120,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) {
|
||||
@@ -1429,6 +1439,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,
|
||||
};
|
||||
@@ -1441,10 +1453,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)) {
|
||||
|
Reference in New Issue
Block a user