Change in libosmocore[master]: vty: enable tab-completion for optional-multi-choice args

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Feb 4 16:43:59 UTC 2019


Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/12771 )

Change subject: vty: enable tab-completion for optional-multi-choice args
......................................................................

vty: enable tab-completion for optional-multi-choice args

In cmd_complete_command_real(), detect and strip square braces from
multi-choice arguments, to enable tab-completion for commands like

 > list
 cmd [(alpha|beta)]
 > cmd <TAB>
 alpha beta
 > cmd be<TAB>
 > cmd beta

Change-Id: I8c304300b3633bb6e9b3457fcfa42121c8272ac0
---
M src/vty/command.c
1 file changed, 10 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/vty/command.c b/src/vty/command.c
index 2242e76..de084ab 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -2010,9 +2010,18 @@
 				descvec = vector_slot(strvec, index);
 				for (j = 0; j < vector_active(descvec); j++)
 					if ((desc = vector_slot(descvec, j))) {
-						if ((string = cmd_entry_function(vector_slot(vline, index), desc->cmd)))
+						const char *cmd = desc->cmd;
+						char *tmp = NULL;
+
+						if (CMD_OPTION(desc->cmd)) {
+							tmp = cmd_deopt(tall_vty_cmd_ctx, desc->cmd);
+							cmd = tmp;
+						}
+						if ((string = cmd_entry_function(vector_slot(vline, index), cmd)))
 							if (cmd_unique_string (matchvec, string))
 								vector_set (matchvec, talloc_strdup(tall_vty_cmd_ctx, string));
+						if (tmp)
+							talloc_free(tmp);
 					}
 			}
 		}

-- 
To view, visit https://gerrit.osmocom.org/12771
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8c304300b3633bb6e9b3457fcfa42121c8272ac0
Gerrit-Change-Number: 12771
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190204/076c8885/attachment.htm>


More information about the gerrit-log mailing list