diff options
author | Corey Farrell <git@cfware.com> | 2018-03-14 13:38:01 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-03-15 07:25:28 -0400 |
commit | b45bb476bb985909d7d891ceb1a9cccfb7763ec6 (patch) | |
tree | 9d359f888c468a01fc2fbb552bcb783e9c5c5be6 /main/cli.c | |
parent | 1a9ed413a104a6390d5088fe5c5a1ebb0dea55a3 (diff) |
cli: Enable ast_cli_completion_add on public completion generators.
* ast_cli_complete
* ast_complete_channels
* ast_complete_applications
These generators will now use ast_cli_completion_add if state == -1.
Change-Id: I7ff311f0873099be0e43a3dc5415c0cd06d15756
Diffstat (limited to 'main/cli.c')
-rw-r--r-- | main/cli.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/main/cli.c b/main/cli.c index 80c184328..e46d3427c 100644 --- a/main/cli.c +++ b/main/cli.c @@ -1655,8 +1655,15 @@ char *ast_cli_complete(const char *word, const char * const choices[], int state len = ast_strlen_zero(word) ? 0 : strlen(word); for (i = 0; choices[i]; i++) { - if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state) - return ast_strdup(choices[i]); + if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state) { + if (state != -1) { + return ast_strdup(choices[i]); + } + + if (ast_cli_completion_add(ast_strdup(choices[i]))) { + return NULL; + } + } } return NULL; } @@ -1682,9 +1689,16 @@ char *ast_complete_channels(const char *line, const char *word, int pos, int sta struct ast_channel_snapshot *snapshot = stasis_message_data(msg); if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) { - ret = ast_strdup(snapshot->name); - ao2_ref(msg, -1); - break; + if (state != -1) { + ret = ast_strdup(snapshot->name); + ao2_ref(msg, -1); + break; + } + + if (ast_cli_completion_add(ast_strdup(snapshot->name))) { + ao2_ref(msg, -1); + break; + } } } ao2_iterator_destroy(&iter); |