[asterisk-commits] mmichelson: branch mmichelson/queue-reset r166950 - /team/mmichelson/queue-re...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 31 11:49:47 CST 2008
Author: mmichelson
Date: Wed Dec 31 11:49:46 2008
New Revision: 166950
URL: http://svn.digium.com/view/asterisk?view=rev&rev=166950
Log:
First attempt at tab-completion for queue reload CLI command.
It "works" but needs improvement.
Modified:
team/mmichelson/queue-reset/apps/app_queue.c
Modified: team/mmichelson/queue-reset/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_queue.c?view=diff&rev=166950&r1=166949&r2=166950
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Wed Dec 31 11:49:46 2008
@@ -6722,6 +6722,52 @@
return CLI_SUCCESS;
}
+static char *complete_queue_reload(const char *line, const char *word, int pos, int state)
+{
+ int wordlen;
+ int which = 0;
+ static int localstate = 0;
+
+ if (ast_strlen_zero(word)) {
+ switch (state) {
+ case 0:
+ return ast_strdup("rules");
+ case 1:
+ return ast_strdup("stats");
+ case 2:
+ return ast_strdup("parameters");
+ case 3:
+ return ast_strdup("members");
+ case 4:
+ {
+ char *ret = complete_queue(line, word, pos, localstate);
+ if (!ret) {
+ localstate = 0;
+ }
+ return ret;
+ }
+ }
+ }
+
+ wordlen = strlen(word);
+
+ if (!strncasecmp(word, "rules", wordlen) && (++which > state)) {
+ return ast_strdup("rules");
+ } else if (!strncasecmp(word, "stats", wordlen) && (++which > state)) {
+ return ast_strdup("stats");
+ } else if (!strncasecmp(word, "parameters", wordlen) && (++which > state)) {
+ return ast_strdup("parameters");
+ } else if (!strncasecmp(word, "members", wordlen) && (++which > state)) {
+ return ast_strdup("members");
+ } else {
+ char *ret = complete_queue(line, word, pos, localstate++);
+ if (!ret) {
+ localstate = 0;
+ }
+ return ret;
+ }
+}
+
static char *handle_queue_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_flags mask = {0,};
@@ -6752,7 +6798,7 @@
return NULL;
case CLI_GENERATE:
/* This will be a fun one to write :) */
- return NULL;
+ return complete_queue_reload(a->line, a->word, a->pos, a->n);
}
if (a->argc < 2 || a->argc > 6)
More information about the asterisk-commits
mailing list