mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
b55f4d2df2
commit
9ea9dd0d5f
|
@ -2010,9 +2010,18 @@ static char **cmd_complete_command_real(vector vline, struct vty *vty,
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue