[asterisk-commits] cli: Fix various CLI documentation and completion issues (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 14 14:34:04 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4937 )

Change subject: cli: Fix various CLI documentation and completion issues
......................................................................


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
---
M apps/app_minivm.c
M apps/app_voicemail.c
M apps/confbridge/conf_config_parser.c
M channels/chan_alsa.c
M channels/chan_sip.c
M channels/chan_skinny.c
M funcs/func_odbc.c
M main/astmm.c
M main/bridge.c
M main/ccss.c
M main/cli.c
M main/pbx_app.c
M main/pbx_hangup_handler.c
M res/res_sorcery_memory_cache.c
14 files changed, 118 insertions(+), 97 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index a060ad1..4cc2f47 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -3014,11 +3014,9 @@
 	struct minivm_account *vmu;
 	const char *domain = "";
 
-	/* 0 - voicemail; 1 - list; 2 - accounts; 3 - for; 4 - <domain> */
+	/* 0 - minivm; 1 - list; 2 - accounts; 3 - for; 4 - <domain> */
 	if (pos > 4)
 		return NULL;
-	if (pos == 3)
-		return (state == 0) ? ast_strdup("for") : NULL;
 	wordlen = strlen(word);
 	AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) {
 		if (!strncasecmp(word, vmu->domain, wordlen)) {
@@ -3040,9 +3038,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "minivm list accounts";
+		e->command = "minivm list accounts [for]";
 		e->usage =
-			"Usage: minivm list accounts\n"
+			"Usage: minivm list accounts [for <domain>]\n"
 			"       Lists all mailboxes currently set up\n";
 		return NULL;
 	case CLI_GENERATE:
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 37f8aa9..3016f65 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -12745,11 +12745,9 @@
 	struct ast_vm_user *vmu;
 	const char *context = "";
 
-	/* 0 - show; 1 - voicemail; 2 - users; 3 - for; 4 - <context> */
+	/* 0 - voicemail; 1 - show; 2 - users; 3 - for; 4 - <context> */
 	if (pos > 4)
 		return NULL;
-	if (pos == 3)
-		return (state == 0) ? ast_strdup("for") : NULL;
 	wordlen = strlen(word);
 	AST_LIST_TRAVERSE(&users, vmu, list) {
 		if (!strncasecmp(word, vmu->context, wordlen)) {
@@ -12772,7 +12770,7 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "voicemail show users";
+		e->command = "voicemail show users [for]";
 		e->usage =
 			"Usage: voicemail show users [for <context>]\n"
 			"       Lists all mailboxes currently set up\n";
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index 1749b58..29d7b7f 100644
--- a/apps/confbridge/conf_config_parser.c
+++ b/apps/confbridge/conf_config_parser.c
@@ -1371,7 +1371,7 @@
 	case CLI_INIT:
 		e->command = "confbridge show profile users";
 		e->usage =
-			"Usage confbridge show profile users\n";
+			"Usage: confbridge show profile users\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -1401,7 +1401,7 @@
 	case CLI_INIT:
 		e->command = "confbridge show profile user";
 		e->usage =
-			"Usage confbridge show profile user [<profile name>]\n";
+			"Usage: confbridge show profile user [<profile name>]\n";
 		return NULL;
 	case CLI_GENERATE:
 		if (a->pos == 4) {
@@ -1522,7 +1522,7 @@
 	case CLI_INIT:
 		e->command = "confbridge show profile bridges";
 		e->usage =
-			"Usage confbridge show profile bridges\n";
+			"Usage: confbridge show profile bridges\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -1554,7 +1554,7 @@
 	case CLI_INIT:
 		e->command = "confbridge show profile bridge";
 		e->usage =
-			"Usage confbridge show profile bridge <profile name>\n";
+			"Usage: confbridge show profile bridge <profile name>\n";
 		return NULL;
 	case CLI_GENERATE:
 		if (a->pos == 4) {
@@ -1706,7 +1706,7 @@
 	case CLI_INIT:
 		e->command = "confbridge show menus";
 		e->usage =
-			"Usage confbridge show profile menus\n";
+			"Usage: confbridge show profile menus\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -1740,7 +1740,7 @@
 	case CLI_INIT:
 		e->command = "confbridge show menu";
 		e->usage =
-			"Usage confbridge show menu [<menu name>]\n";
+			"Usage: confbridge show menu [<menu name>]\n";
 		return NULL;
 	case CLI_GENERATE:
 		if (a->pos == 3) {
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index d09dc1c..c50b540 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -637,29 +637,13 @@
 	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 @@
 			"       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))
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3bb6e74..7dcb48b 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -19585,7 +19585,7 @@
 
 	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"
@@ -19775,7 +19775,7 @@
 
 	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"
@@ -19914,7 +19914,7 @@
 {
 	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"
@@ -20628,7 +20628,12 @@
 			"       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);
 }
@@ -20798,7 +20803,12 @@
 			"       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);
 }
@@ -21169,7 +21179,12 @@
 			"       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)
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 0ef0166..a3a2f87 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -3921,24 +3921,40 @@
 
 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 @@
 	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:
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index e014b63..06e4a6a 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -1417,7 +1417,8 @@
 			AST_RWLIST_UNLOCK(&queries);
 			return NULL;
 		} else if (a->pos == 4) {
-			return a->n == 0 ? ast_strdup("exec") : NULL;
+			static const char * const completions[] = { "exec", NULL };
+			return ast_cli_complete(a->word, completions, a->n);
 		} else {
 			return NULL;
 		}
@@ -1623,7 +1624,8 @@
 			AST_RWLIST_UNLOCK(&queries);
 			return NULL;
 		} else if (a->pos == 5) {
-			return a->n == 0 ? ast_strdup("exec") : NULL;
+			static const char * const completions[] = { "exec", NULL };
+			return ast_cli_complete(a->word, completions, a->n);
 		} else {
 			return NULL;
 		}
diff --git a/main/astmm.c b/main/astmm.c
index 0ad29a6..9c26f0f 100644
--- a/main/astmm.c
+++ b/main/astmm.c
@@ -691,17 +691,12 @@
 {
 	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 @@
 
 	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 @@
 			"       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 @@
 {
 	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 @@
 			"       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 13c01fa..b6ba0a2 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -5170,12 +5170,6 @@
 		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 *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 @@
 			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 6c3e6cb..f96d7aa 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -4566,11 +4566,9 @@
 
 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 @@
 			"       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 632883d..ccdbb97 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -916,6 +916,7 @@
 
 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 @@
 	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 @@
 	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_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 @@
 			"       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 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 @@
 			"       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 0c030d1..e0609db 100644
--- a/main/pbx_app.c
+++ b/main/pbx_app.c
@@ -313,7 +313,6 @@
 	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 @@
 			"       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 554cb34..84b53d0 100644
--- a/main/pbx_hangup_handler.c
+++ b/main/pbx_hangup_handler.c
@@ -258,7 +258,7 @@
 			"       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) {
diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c
index 5f7ffb6..bf2347c 100644
--- a/res/res_sorcery_memory_cache.c
+++ b/res/res_sorcery_memory_cache.c
@@ -1866,6 +1866,7 @@
 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 @@
 			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;
 		}
@@ -1888,6 +1892,14 @@
 
 	if (a->argc < 5 || a->argc > 7) {
 		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);
@@ -1910,7 +1922,7 @@
 		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);

-- 
To view, visit https://gerrit.asterisk.org/4937
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iee58c7392f6fec34ad9d596109117af87697bbca
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list