mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 19:39:28 +00:00
Fix optional arguments with description interactions
Ticket: CM-6659 Reviewed by: CCR-3203 Testing: See bug If you have a cli like this: "neighbor WORD interface {v6only}" When in the cli you hit ? after entering v6only you get this: tor-11(config-router)# neighbor swp1 interface v6only % There is no matched command. tor-11(config-router)# neighbor swp1 interface v6only With this fix we now see: tor-22(config-router)# neighbor swp1 interface v6only <cr> tor-22(config-router)# neighbor swp1 interface v6only This behavior is now consistent with non-optional last arguments.
This commit is contained in:
parent
6e9197093c
commit
16cf945a50
@ -2102,6 +2102,8 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status)
|
||||
char *command;
|
||||
vector matches = NULL;
|
||||
vector match_vector;
|
||||
uint32_t command_found = 0;
|
||||
const char *last_word;
|
||||
|
||||
/* Set index. */
|
||||
if (vector_active (vline) == 0)
|
||||
@ -2187,13 +2189,13 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status)
|
||||
}
|
||||
|
||||
/* Make description vector. */
|
||||
for (i = 0; i < vector_active (matches); i++)
|
||||
for (i = 0; i < vector_active (matches); i++) {
|
||||
if ((cmd_element = vector_slot (cmd_vector, i)) != NULL)
|
||||
{
|
||||
unsigned int j;
|
||||
const char *last_word;
|
||||
vector vline_trimmed;
|
||||
|
||||
command_found++;
|
||||
last_word = vector_slot(vline, vector_active(vline) - 1);
|
||||
if (last_word == NULL || !strlen(last_word))
|
||||
{
|
||||
@ -2222,6 +2224,18 @@ cmd_describe_command_real (vector vline, struct vty *vty, int *status)
|
||||
vector_set(matchvec, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We can get into this situation when the command is complete
|
||||
* but the last part of the command is an optional piece of
|
||||
* cli.
|
||||
*/
|
||||
last_word = vector_slot(vline, vector_active(vline) - 1);
|
||||
if (command_found == 0 && (last_word == NULL || !strlen(last_word))) {
|
||||
vector_set(matchvec, &token_cr);
|
||||
}
|
||||
|
||||
vector_free (cmd_vector);
|
||||
cmd_matches_free(&matches);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user