mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Merge "cli: Fix various CLI documentation and completion issues"
This commit is contained in:
@@ -637,29 +637,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"
|
||||
@@ -667,7 +651,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))
|
||||
|
@@ -19587,7 +19587,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"
|
||||
@@ -19777,7 +19777,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"
|
||||
@@ -19916,7 +19916,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"
|
||||
@@ -20630,7 +20630,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);
|
||||
}
|
||||
@@ -20800,7 +20805,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);
|
||||
}
|
||||
@@ -21171,7 +21181,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)
|
||||
|
@@ -3921,24 +3921,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;
|
||||
@@ -4580,7 +4596,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:
|
||||
|
Reference in New Issue
Block a user