<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8527">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cli: Enable ast_cli_completion_add on public completion generators.<br><br>* ast_cli_complete<br>* ast_complete_channels<br>* ast_complete_applications<br><br>These generators will now use ast_cli_completion_add if state == -1.<br><br>Change-Id: I7ff311f0873099be0e43a3dc5415c0cd06d15756<br>---<br>M main/cli.c<br>M main/pbx_app.c<br>2 files changed, 35 insertions(+), 18 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/27/8527/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/cli.c b/main/cli.c<br>index 80c1843..e46d342 100644<br>--- a/main/cli.c<br>+++ b/main/cli.c<br>@@ -1655,8 +1655,15 @@<br> len = ast_strlen_zero(word) ? 0 : strlen(word);<br> <br> for (i = 0; choices[i]; i++) {<br>- if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state)<br>- return ast_strdup(choices[i]);<br>+ if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state) {<br>+ if (state != -1) {<br>+ return ast_strdup(choices[i]);<br>+ }<br>+<br>+ if (ast_cli_completion_add(ast_strdup(choices[i]))) {<br>+ return NULL;<br>+ }<br>+ }<br> }<br> return NULL;<br> }<br>@@ -1682,9 +1689,16 @@<br> struct ast_channel_snapshot *snapshot = stasis_message_data(msg);<br> <br> if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) {<br>- ret = ast_strdup(snapshot->name);<br>- ao2_ref(msg, -1);<br>- break;<br>+ if (state != -1) {<br>+ ret = ast_strdup(snapshot->name);<br>+ ao2_ref(msg, -1);<br>+ break;<br>+ }<br>+<br>+ if (ast_cli_completion_add(ast_strdup(snapshot->name))) {<br>+ ao2_ref(msg, -1);<br>+ break;<br>+ }<br> }<br> }<br> ao2_iterator_destroy(&iter);<br>diff --git a/main/pbx_app.c b/main/pbx_app.c<br>index ec6bc75..df8126c 100644<br>--- a/main/pbx_app.c<br>+++ b/main/pbx_app.c<br>@@ -275,7 +275,7 @@<br> * application at one time. You can type 'show application Dial Echo' and<br> * you will see informations about these two applications ...<br> */<br>- return ast_complete_applications(a->line, a->word, a->n);<br>+ return ast_complete_applications(a->line, a->word, -1);<br> }<br> <br> if (a->argc < 4) {<br>@@ -437,20 +437,23 @@<br> AST_RWLIST_RDLOCK(&apps);<br> AST_RWLIST_TRAVERSE(&apps, app, list) {<br> cmp = strncasecmp(word, app->name, wordlen);<br>- if (cmp > 0) {<br>- continue;<br>- }<br>- if (!cmp) {<br>- /* Found match. */<br>- if (++which <= state) {<br>- /* Not enough matches. */<br>- continue;<br>- }<br>- ret = ast_strdup(app->name);<br>+ if (cmp < 0) {<br>+ /* No more matches. */<br> break;<br>+ } else if (!cmp) {<br>+ /* Found match. */<br>+ if (state != -1) {<br>+ if (++which <= state) {<br>+ /* Not enough matches. */<br>+ continue;<br>+ }<br>+ ret = ast_strdup(app->name);<br>+ break;<br>+ }<br>+ if (ast_cli_completion_add(ast_strdup(app->name))) {<br>+ break;<br>+ }<br> }<br>- /* Not in container. */<br>- break;<br> }<br> AST_RWLIST_UNLOCK(&apps);<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8527">change 8527</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8527"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I7ff311f0873099be0e43a3dc5415c0cd06d15756 </div>
<div style="display:none"> Gerrit-Change-Number: 8527 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>