diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-08-10 20:31:15 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-08-10 20:31:15 +0200 |
commit | ca90e051043f819fe974cd110e15cf38edd63f2e (patch) | |
tree | 1886b09b8fa62f36604050a1c142a35bf2db8393 /lib/grammar_sandbox.c | |
parent | debian: Add bison and flex to Build-Depends (diff) | |
download | frr-ca90e051043f819fe974cd110e15cf38edd63f2e.tar.xz frr-ca90e051043f819fe974cd110e15cf38edd63f2e.zip |
lib: Add completion string convenience functions
And set END_GN default text to <cr>, and scrub
a coupld of extraneous files
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/grammar_sandbox.c')
-rw-r--r-- | lib/grammar_sandbox.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 6473fc12e..899d0469a 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -91,31 +91,22 @@ DEFUN (grammar_test_complete, char *cmdstr = argv_concat (argv, argc, 0); vector command = cmd_make_strvec (cmdstr); - struct list *completions; - enum matcher_rv result = match_command_complete (nodegraph, command, &completions); + vector completions = vector_init (VECTOR_MIN_SIZE); + enum matcher_rv result = + match_command_complete_str (nodegraph, command, completions); // print completions or relevant error message - if (completions) + if (!MATCHER_ERROR(result)) { - struct listnode *ln; - struct graph_node *gn; - for (ALL_LIST_ELEMENTS_RO(completions,ln,gn)) - { - if (gn->type == END_GN) - zlog_info ("<cr> (%p)", gn->element->func); - else - zlog_info ("%-30s%s", gn->text, gn->doc); - } - list_delete (completions); + for (unsigned int i = 0; i < vector_active (completions); i++) + zlog_info ((char *) vector_slot (completions, i)); } else - { - assert(MATCHER_ERROR(result)); - zlog_info ("%% No match for \"%s\"", cmdstr); - } + zlog_info ("%% No match for \"%s\"", cmdstr); // free resources cmd_free_strvec (command); + cmd_free_strvec (completions); free (cmdstr); return CMD_SUCCESS; |