From ea8a610776ca80ddb2302543e32b487896ad2f5c Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Sat, 11 Feb 2017 10:57:03 -0500 Subject: 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 --- res/res_sorcery_memory_cache.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'res/res_sorcery_memory_cache.c') diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c index 5f7ffb64e..bf2347ccd 100644 --- a/res/res_sorcery_memory_cache.c +++ b/res/res_sorcery_memory_cache.c @@ -1866,6 +1866,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: @@ -1881,6 +1882,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; } @@ -1890,6 +1894,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]); @@ -1910,7 +1922,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); -- cgit v1.2.3