tests/vty: demonstrate a problem with optional-multi-choice

Change-Id: I6ad93a304ce498ba9d57fc7e2fd238e6c16e29e0
Related: b55f4d2df2
Related: OS#6360
This commit is contained in:
Vadim Yanitskiy 2024-02-14 04:59:06 +07:00
parent 9d73503bd0
commit 1f806f241b
2 changed files with 34 additions and 0 deletions

View File

@ -207,6 +207,14 @@ DEFUN(multi2, multi2_cmd,
return CMD_SUCCESS;
}
DEFUN(multi3, multi3_cmd,
"multi3 (foo|bar) [(one|two|three)]",
"multi3 test command\n" "foo\nbar\n" "1\n2\n3\n")
{
vty_out(vty, "ok argc=%d%s%s%s", argc, argc ? " " : "", argc ? argv[0] : "", VTY_NEWLINE);
return CMD_SUCCESS;
}
#define X(f) (1 << f)
enum {
@ -380,6 +388,7 @@ static void init_vty_cmds(void)
install_element_ve(&multi0_cmd);
install_element_ve(&multi1_cmd);
install_element_ve(&multi2_cmd);
install_element_ve(&multi3_cmd);
install_element(CONFIG_NODE, &cfg_attr_test_cmd);
install_node(&attr_test_node, NULL);

View File

@ -3,6 +3,7 @@ vty_transcript_test> list
multi0 (one|two|three)
multi1 ([one]|[two]|[three])
multi2 [(one|two|three)]
multi3 (foo|bar) [(one|two|three)]
vty_transcript_test> multi0 ?
one 1
@ -67,6 +68,27 @@ ok argc=1 two
vty_transcript_test> multi2
ok argc=0
vty_transcript_test> multi3 ?
foo foo
bar bar
vty_transcript_test> multi3 foo ?
[one] 1
[two] 2
[three] 3
vty_transcript_test> multi3 foo
ok argc=1 foo
vty_transcript_test> multi3 bar
ok argc=1 bar
vty_transcript_test> multi3 foo one
ok argc=2 foo one
vty_transcript_test> multi3 bar three
ok argc=2 foo three
vty_transcript_test> multi0 thr
ok argc=1 three
@ -76,6 +98,9 @@ ok argc=1 one
vty_transcript_test> multi2 t
% Ambiguous command.
vty_transcript_test> multi3 foo t
% Ambiguous command.
vty_transcript_test> single0 one
ok argc=1 one