2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 * cli.c: command line interface
18 * Copyright (c) 2008 Eliot Dresselhaus
20 * Permission is hereby granted, free of charge, to any person obtaining
21 * a copy of this software and associated documentation files (the
22 * "Software"), to deal in the Software without restriction, including
23 * without limitation the rights to use, copy, modify, merge, publish,
24 * distribute, sublicense, and/or sell copies of the Software, and to
25 * permit persons to whom the Software is furnished to do so, subject to
26 * the following conditions:
28 * The above copyright notice and this permission notice shall be
29 * included in all copies or substantial portions of the Software.
31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 #include <vlib/vlib.h>
42 /* Root of all show commands. */
43 VLIB_CLI_COMMAND (vlib_cli_show_command, static) = {
45 .short_help = "Show commands",
48 /* Root of all clear commands. */
49 VLIB_CLI_COMMAND (vlib_cli_clear_command, static) = {
51 .short_help = "Clear commands",
54 /* Root of all set commands. */
55 VLIB_CLI_COMMAND (vlib_cli_set_command, static) = {
57 .short_help = "Set commands",
60 /* Root of all test commands. */
61 VLIB_CLI_COMMAND (vlib_cli_test_command, static) = {
63 .short_help = "Test commands",
66 /* Returns bitmap of commands which match key. */
68 vlib_cli_sub_command_match (vlib_cli_command_t * c, unformat_input_t * input)
72 vlib_cli_parse_position_t * p;
74 unformat_skip_white_space (input);
80 k = unformat_get_input (input);
89 case ' ': case '\t': case '\r': case '\n':
90 case UNFORMAT_END_OF_INPUT:
91 /* White space or end of input removes any non-white
92 matches that were before possible. */
93 if (i < vec_len (c->sub_command_positions)
94 && clib_bitmap_count_set_bits (match) > 1)
96 p = vec_elt_at_index (c->sub_command_positions, i);
97 for (n = 0; n < vec_len (p->bitmaps); n++)
98 match = clib_bitmap_andnot (match, p->bitmaps[n]);
103 unformat_put_input (input);
107 if (i >= vec_len (c->sub_command_positions))
110 clib_bitmap_free (match);
114 p = vec_elt_at_index (c->sub_command_positions, i);
115 if (vec_len (p->bitmaps) == 0)
119 if (n < 0 || n >= vec_len (p->bitmaps))
123 match = clib_bitmap_dup (p->bitmaps[n]);
125 match = clib_bitmap_and (match, p->bitmaps[n]);
127 if (clib_bitmap_is_zero (match))
135 /* Looks for string based sub-input formatted { SUB-INPUT }. */
136 static uword unformat_vlib_cli_sub_input (unformat_input_t * i, va_list * args)
138 unformat_input_t * sub_input = va_arg (*args, unformat_input_t *);
144 c = unformat_get_input (i);
148 case '\n': case '\r':
154 /* Put back paren. */
155 if (c != UNFORMAT_END_OF_INPUT)
156 unformat_put_input (i);
158 if (c == '{' && unformat (i, "%v", &s))
160 unformat_init_vector (sub_input, s);
169 static vlib_cli_command_t *
170 get_sub_command (vlib_cli_main_t * cm, vlib_cli_command_t * parent, u32 si)
172 vlib_cli_sub_command_t * s = vec_elt_at_index (parent->sub_commands, si);
173 return vec_elt_at_index (cm->commands, s->index);
176 static uword unformat_vlib_cli_sub_command (unformat_input_t * i, va_list * args)
178 vlib_main_t * vm = va_arg (*args, vlib_main_t *);
179 vlib_cli_command_t * c = va_arg (*args, vlib_cli_command_t *);
180 vlib_cli_command_t ** result = va_arg (*args, vlib_cli_command_t **);
181 vlib_cli_main_t * cm = &vm->cli_main;
182 uword * match_bitmap, is_unique, index;
185 vlib_cli_sub_rule_t * sr;
186 vlib_cli_parse_rule_t * r;
187 vec_foreach (sr, c->sub_rules)
190 r = vec_elt_at_index (cm->parse_rules, sr->rule_index);
191 vec_add2 (cm->parse_rule_data, d, 1);
192 vec_reset_length (d[0]);
194 d[0] = _vec_resize (d[0],
195 /* length increment */ 1,
197 /* header_bytes */ 0,
198 /* data align */ sizeof (uword));
199 if (unformat_user (i, r->unformat_function, vm, d[0]))
201 *result = vec_elt_at_index (cm->commands, sr->command_index);
207 match_bitmap = vlib_cli_sub_command_match (c, i);
208 is_unique = clib_bitmap_count_set_bits (match_bitmap) == 1;
212 index = clib_bitmap_first_set (match_bitmap);
213 *result = get_sub_command (cm, c, index);
215 clib_bitmap_free (match_bitmap);
220 static u8 * format_vlib_cli_command_help (u8 * s, va_list * args)
222 vlib_cli_command_t * c = va_arg (*args, vlib_cli_command_t *);
223 int is_long = va_arg (*args, int);
224 if (is_long && c->long_help)
225 s = format (s, "%s", c->long_help);
226 else if (c->short_help)
227 s = format (s, "%s", c->short_help);
229 s = format (s, "%v commands", c->path);
233 static u8 * format_vlib_cli_parse_rule_name (u8 * s, va_list * args)
235 vlib_cli_parse_rule_t * r = va_arg (*args, vlib_cli_parse_rule_t *);
236 return format (s, "<%U>", format_c_identifier, r->name);
239 static u8 * format_vlib_cli_path (u8 * s, va_list * args)
241 u8 * path = va_arg (*args, u8 *);
244 for (i = 0; i < vec_len (path); i++)
250 vec_add1 (s, '<'); /* start of <RULE> */
254 /* _ -> space in rules. */
255 vec_add1 (s, in_rule ? ' ' : '_');
261 vec_add1 (s, '>'); /* end of <RULE> */
268 vec_add1 (s, path[i]);
274 vec_add1 (s, '>'); /* terminate <RULE> */
279 static vlib_cli_command_t *
280 all_subs (vlib_cli_main_t * cm,
281 vlib_cli_command_t * subs,
284 vlib_cli_command_t * c = vec_elt_at_index (cm->commands, command_index);
285 vlib_cli_sub_command_t * sc;
286 vlib_cli_sub_rule_t * sr;
289 vec_add1 (subs, c[0]);
291 vec_foreach (sr, c->sub_rules)
292 subs = all_subs (cm, subs, sr->command_index);
293 vec_foreach (sc, c->sub_commands)
294 subs = all_subs (cm, subs, sc->index);
300 vlib_cli_cmp_rule (void * a1, void * a2)
302 vlib_cli_sub_rule_t * r1 = a1;
303 vlib_cli_sub_rule_t * r2 = a2;
305 return vec_cmp (r1->name, r2->name);
309 vlib_cli_cmp_command (void * a1, void * a2)
311 vlib_cli_command_t * c1 = a1;
312 vlib_cli_command_t * c2 = a2;
314 return vec_cmp (c1->path, c2->path);
317 static clib_error_t *
318 vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
319 vlib_cli_main_t * cm,
320 unformat_input_t * input,
321 uword parent_command_index)
323 vlib_cli_command_t * parent, * c;
324 clib_error_t * error = 0;
325 unformat_input_t sub_input;
327 uword is_main_dispatch = cm == &vm->cli_main;
329 parent = vec_elt_at_index (cm->commands, parent_command_index);
330 if (is_main_dispatch && unformat (input, "help"))
332 uword help_at_end_of_line, i;
334 help_at_end_of_line = unformat_check_input (input) == UNFORMAT_END_OF_INPUT;
338 if (unformat_user (input, unformat_vlib_cli_sub_command, vm, c, &parent))
341 else if (! (unformat_check_input (input) == UNFORMAT_END_OF_INPUT))
348 /* help SUB-COMMAND => long format help.
349 "help" at end of line: show all commands. */
350 if (! help_at_end_of_line)
351 vlib_cli_output (vm, "%U", format_vlib_cli_command_help, c, /* is_long */ 1);
353 else if (vec_len (c->sub_commands) + vec_len (c->sub_rules) == 0)
354 vlib_cli_output (vm, "%v: no sub-commands", c->path);
358 vlib_cli_sub_command_t * sc;
359 vlib_cli_sub_rule_t * sr, * subs;
361 subs = vec_dup (c->sub_rules);
363 /* Add in rules if any. */
364 vec_foreach (sc, c->sub_commands)
366 vec_add2 (subs, sr, 1);
368 sr->command_index = sc->index;
372 vec_sort_with_function (subs, vlib_cli_cmp_rule);
374 for (i = 0; i < vec_len (subs); i++)
376 vlib_cli_command_t * d;
377 vlib_cli_parse_rule_t * r;
379 d = vec_elt_at_index (cm->commands, subs[i].command_index);
380 r = subs[i].rule_index != ~0 ? vec_elt_at_index (cm->parse_rules, subs[i].rule_index) : 0;
385 format_vlib_cli_parse_rule_name, r,
386 format_vlib_cli_command_help, d, /* is_long */ 0);
391 format_vlib_cli_command_help, d, /* is_long */ 0);
398 else if (is_main_dispatch && (unformat (input, "choices") || unformat (input, "?")))
400 vlib_cli_command_t * sub, * subs;
402 subs = all_subs (cm, 0, parent_command_index);
403 vec_sort_with_function (subs, vlib_cli_cmp_command);
404 vec_foreach (sub, subs)
405 vlib_cli_output (vm, " %-40U %U",
406 format_vlib_cli_path, sub->path,
407 format_vlib_cli_command_help, sub, /* is_long */ 0);
411 else if (unformat (input, "comment %v", &string))
416 else if (unformat (input, "uncomment %U",
417 unformat_vlib_cli_sub_input, &sub_input))
419 error = vlib_cli_dispatch_sub_commands (vm, cm, &sub_input, parent_command_index);
420 unformat_free (&sub_input);
423 else if (unformat_user (input, unformat_vlib_cli_sub_command, vm, parent, &c))
425 unformat_input_t * si;
426 uword has_sub_commands = vec_len (c->sub_commands) + vec_len (c->sub_rules) > 0;
429 if (unformat_user (input, unformat_vlib_cli_sub_input, &sub_input))
432 if (has_sub_commands)
433 error = vlib_cli_dispatch_sub_commands (vm, cm, si, c - cm->commands);
435 if (has_sub_commands && ! error)
436 /* Found valid sub-command. */;
438 else if (c->function)
440 clib_error_t * c_error;
442 /* Skip white space for benefit of called function. */
443 unformat_skip_white_space (si);
445 if (unformat (si, "?"))
447 vlib_cli_output (vm, " %-40U %U",
448 format_vlib_cli_path, c->path,
449 format_vlib_cli_command_help, c, /* is_long */ 0);
454 vlib_worker_thread_barrier_sync(vm);
456 c_error = c->function (vm, si, c);
459 vlib_worker_thread_barrier_release(vm);
463 error = clib_error_return (0, "%v: %v", c->path, c_error->what);
464 clib_error_free (c_error);
465 /* Free sub input. */
473 /* Free any previous error. */
474 clib_error_free (error);
478 error = clib_error_return (0, "%v: no sub-commands", c->path);
480 /* Free sub input. */
492 return clib_error_return (0, "%v: unknown input `%U'", parent->path, format_unformat_error, input);
494 return clib_error_return (0, "unknown input `%U'", format_unformat_error, input);
498 void vlib_unix_error_report (vlib_main_t *, clib_error_t *)
499 __attribute__ ((weak));
501 void vlib_unix_error_report (vlib_main_t * vm, clib_error_t * error) { }
503 /* Process CLI input. */
504 void vlib_cli_input (vlib_main_t * vm,
505 unformat_input_t * input,
506 vlib_cli_output_function_t * function,
509 vlib_cli_main_t * cm = &vm->cli_main;
510 clib_error_t * error;
511 vlib_cli_output_function_t * save_function;
512 uword save_function_arg;
514 save_function = cm->output_function;
515 save_function_arg = cm->output_function_arg;
517 cm->output_function = function;
518 cm->output_function_arg = function_arg;
521 vec_reset_length (cm->parse_rule_data);
522 error = vlib_cli_dispatch_sub_commands (vm, &vm->cli_main, input, /* parent */ 0);
523 } while (! error && ! unformat (input, "%U", unformat_eof));
527 vlib_cli_output (vm, "%v", error->what);
528 vlib_unix_error_report (vm, error);
529 clib_error_free (error);
532 cm->output_function = save_function;
533 cm->output_function_arg = save_function_arg;
536 /* Output to current CLI connection. */
537 void vlib_cli_output (vlib_main_t * vm, char * fmt, ...)
539 vlib_cli_main_t * cm = &vm->cli_main;
544 s = va_format (0, fmt, &va);
547 /* Terminate with \n if not present. */
548 if (vec_len (s) > 0 && s[vec_len (s)-1] != '\n')
551 if (! cm->output_function)
552 fformat (stdout, "%v", s);
554 cm->output_function (cm->output_function_arg, s, vec_len (s));
559 static clib_error_t *
560 show_memory_usage (vlib_main_t * vm,
561 unformat_input_t * input,
562 vlib_cli_command_t * cmd)
565 clib_error_t * error;
568 while (unformat_check_input(input) != UNFORMAT_END_OF_INPUT)
570 if (unformat (input, "verbose"))
573 error = clib_error_return (0, "unknown input `%U'",
574 format_unformat_error, input);
581 vlib_cli_output (vm, "Thread %d %v\n", index, vlib_worker_threads[index].name);
582 vlib_cli_output (vm, "%U\n", format_mheap, clib_per_cpu_mheaps[index], verbose);
588 VLIB_CLI_COMMAND (show_memory_usage_command, static) = {
589 .path = "show memory",
590 .short_help = "Show current memory usage",
591 .function = show_memory_usage,
594 static clib_error_t *
595 enable_disable_memory_trace (vlib_main_t * vm,
596 unformat_input_t * input,
597 vlib_cli_command_t * cmd)
599 clib_error_t * error = 0;
602 if (! unformat_user (input, unformat_vlib_enable_disable, &enable))
604 error = clib_error_return (0, "expecting enable/on or disable/off");
608 clib_mem_trace (enable);
614 VLIB_CLI_COMMAND (enable_disable_memory_trace_command, static) = {
615 .path = "memory-trace",
616 .short_help = "Enable/disable memory allocation trace",
617 .function = enable_disable_memory_trace,
621 static clib_error_t *
622 test_heap_validate (vlib_main_t * vm, unformat_input_t * input,
623 vlib_cli_command_t * cmd)
625 clib_error_t * error = 0;
629 if (unformat(input, "on")) {
631 heap = clib_per_cpu_mheaps[this_vlib_main->cpu_index];
632 mheap = mheap_header(heap);
633 mheap->flags |= MHEAP_FLAG_VALIDATE;
634 // Turn off small object cache because it delays detection of errors
635 mheap->flags &= ~MHEAP_FLAG_SMALL_OBJECT_CACHE;
638 } else if (unformat(input, "off")) {
640 heap = clib_per_cpu_mheaps[this_vlib_main->cpu_index];
641 mheap = mheap_header(heap);
642 mheap->flags &= ~MHEAP_FLAG_VALIDATE;
643 mheap->flags |= MHEAP_FLAG_SMALL_OBJECT_CACHE;
646 } else if (unformat(input, "now")) {
648 heap = clib_per_cpu_mheaps[this_vlib_main->cpu_index];
649 mheap = mheap_header(heap);
650 mheap_validate(heap);
652 vlib_cli_output(vm, "heap validation complete");
655 return clib_error_return(0, "unknown input `%U'",
656 format_unformat_error, input);
662 VLIB_CLI_COMMAND (cmd_test_heap_validate,static) = {
663 .path = "test heap-validate",
664 .short_help = "<on/off/now> validate heap on future allocs/frees or right now",
665 .function = test_heap_validate,
669 static uword vlib_cli_normalize_path (char * input, char ** result)
674 uword index_of_last_space = ~0;
679 /* Multiple white space -> single space. */
686 if (l > 0 && s[l-1] != ' ')
694 if (l > 0 && s[l-1] == ' ')
695 index_of_last_space = vec_len (s);
702 /* Remove any extra space at end. */
703 if (l > 0 && s[l-1] == ' ')
707 return index_of_last_space;
711 parent_path_len (char * path)
714 for (i = vec_len (path) - 1; i >= 0; i--)
722 static void add_sub_command (vlib_cli_main_t * cm,
726 vlib_cli_command_t * p, * c;
727 vlib_cli_sub_command_t * sub_c;
731 p = vec_elt_at_index (cm->commands, parent_index);
732 c = vec_elt_at_index (cm->commands, child_index);
734 l = parent_path_len (c->path);
736 sub_name = vec_dup ((u8 *) c->path);
739 ASSERT (l + 1 < vec_len (c->path));
741 vec_add (sub_name, c->path + l + 1, vec_len (c->path) - (l + 1));
744 if (sub_name[0] == '%')
747 vlib_cli_sub_rule_t * sr;
750 vec_delete (sub_name, 1, 0);
752 if (! p->sub_rule_index_by_name)
753 p->sub_rule_index_by_name
754 = hash_create_vec (/* initial length */ 32,
755 sizeof (sub_name[0]),
757 q = hash_get_mem (p->sub_rule_index_by_name, sub_name);
760 sr = vec_elt_at_index (p->sub_rules, q[0]);
761 ASSERT (sr->command_index == child_index);
765 q = hash_get_mem (cm->parse_rule_index_by_name, sub_name);
767 clib_error ("reference to unknown rule `%%%v' in path `%v'",
770 hash_set_mem (p->sub_rule_index_by_name, sub_name, vec_len (p->sub_rules));
771 vec_add2 (p->sub_rules, sr, 1);
773 sr->rule_index = q[0];
774 sr->command_index = child_index;
778 if (! p->sub_command_index_by_name)
779 p->sub_command_index_by_name
780 = hash_create_vec (/* initial length */ 32,
784 /* Check if sub-command has already been created. */
785 if (hash_get_mem (p->sub_command_index_by_name, sub_name))
791 vec_add2 (p->sub_commands, sub_c, 1);
792 sub_c->index = child_index;
793 sub_c->name = sub_name;
794 hash_set_mem (p->sub_command_index_by_name, sub_c->name, sub_c - p->sub_commands);
796 vec_validate (p->sub_command_positions, vec_len (sub_c->name) - 1);
797 for (i = 0; i < vec_len (sub_c->name); i++)
800 vlib_cli_parse_position_t * pos;
802 pos = vec_elt_at_index (p->sub_command_positions, i);
805 pos->min_char = sub_c->name[i];
807 n = sub_c->name[i] - pos->min_char;
810 pos->min_char = sub_c->name[i];
811 vec_insert (pos->bitmaps, -n, 0);
815 vec_validate (pos->bitmaps, n);
816 pos->bitmaps[n] = clib_bitmap_ori (pos->bitmaps[n], sub_c - p->sub_commands);
821 vlib_cli_make_parent (vlib_cli_main_t * cm, uword ci)
823 uword p_len, pi, * p;
825 vlib_cli_command_t * c, * parent;
827 /* Root command (index 0) should have already been added. */
828 ASSERT (vec_len (cm->commands) > 0);
830 c = vec_elt_at_index (cm->commands, ci);
831 p_len = parent_path_len (c->path);
833 /* No space? Parent is root command. */
836 add_sub_command (cm, 0, ci);
841 vec_add (p_path, c->path, p_len);
843 p = hash_get_mem (cm->command_index_by_path, p_path);
848 /* Parent does not exist; create it. */
849 vec_add2 (cm->commands, parent, 1);
850 parent->path = p_path;
851 hash_set_mem (cm->command_index_by_path, parent->path, parent - cm->commands);
852 pi = parent - cm->commands;
860 add_sub_command (cm, pi, ci);
862 /* Create parent's parent. */
864 vlib_cli_make_parent (cm, pi);
868 vlib_cli_command_is_empty (vlib_cli_command_t * c)
870 return (c->long_help == 0
871 && c->short_help == 0
872 && c->function == 0);
875 clib_error_t * vlib_cli_register (vlib_main_t * vm, vlib_cli_command_t * c)
877 vlib_cli_main_t * cm = &vm->cli_main;
878 clib_error_t * error = 0;
880 char * normalized_path;
882 if ((error = vlib_call_init_function (vm, vlib_cli_init)))
885 (void) vlib_cli_normalize_path (c->path, &normalized_path);
887 if (! cm->command_index_by_path)
888 cm->command_index_by_path = hash_create_vec (/* initial length */ 32,
892 /* See if command already exists with given path. */
893 p = hash_get_mem (cm->command_index_by_path, normalized_path);
896 vlib_cli_command_t * d;
899 d = vec_elt_at_index (cm->commands, ci);
901 /* If existing command was created via vlib_cli_make_parent
902 replaced it with callers data. */
903 if (vlib_cli_command_is_empty (d))
905 vlib_cli_command_t save = d[0];
907 ASSERT (! vlib_cli_command_is_empty (c));
909 /* Copy callers fields. */
912 /* Save internal fields. */
914 d->sub_commands = save.sub_commands;
915 d->sub_command_index_by_name = save.sub_command_index_by_name;
916 d->sub_command_positions = save.sub_command_positions;
917 d->sub_rules = save.sub_rules;
920 error = clib_error_return (0, "duplicate command name with path %v", normalized_path);
922 vec_free (normalized_path);
928 /* Command does not exist: create it. */
930 /* Add root command (index 0). */
931 if (vec_len (cm->commands) == 0)
933 /* Create command with index 0; path is empty string. */
934 vec_resize (cm->commands, 1);
937 ci = vec_len (cm->commands);
938 hash_set_mem (cm->command_index_by_path, normalized_path, ci);
939 vec_add1 (cm->commands, c[0]);
941 c = vec_elt_at_index (cm->commands, ci);
942 c->path = normalized_path;
944 /* Don't inherit from registration. */
946 c->sub_command_index_by_name = 0;
947 c->sub_command_positions = 0;
950 vlib_cli_make_parent (cm, ci);
955 vlib_cli_register_parse_rule (vlib_main_t * vm, vlib_cli_parse_rule_t * r_reg)
957 vlib_cli_main_t * cm = &vm->cli_main;
958 vlib_cli_parse_rule_t * r;
959 clib_error_t * error = 0;
963 if (! cm->parse_rule_index_by_name)
964 cm->parse_rule_index_by_name = hash_create_vec (/* initial length */ 32,
968 /* Make vector copy of name. */
969 r_name = format (0, "%s", r_reg->name);
971 if ((p = hash_get_mem (cm->parse_rule_index_by_name, r_name)))
974 return clib_error_return (0, "duplicate parse rule name `%s'", r_reg->name);
977 vec_add2 (cm->parse_rules, r, 1);
979 r->name = (char *) r_name;
980 hash_set_mem (cm->parse_rule_index_by_name, r->name, r - cm->parse_rules);
986 /* $$$ turn back on again someday, maybe */
987 static clib_error_t *
988 vlib_cli_register_parse_rules (vlib_main_t * vm,
989 vlib_cli_parse_rule_t * lo,
990 vlib_cli_parse_rule_t * hi)
992 __attribute__((unused))
994 clib_error_t * error = 0;
995 vlib_cli_parse_rule_t * r;
997 for (r = lo; r < hi; r = clib_elf_section_data_next (r, 0))
999 if (! r->name || strlen (r->name) == 0)
1001 error = clib_error_return (0, "parse rule with no name");
1005 error = vlib_cli_register_parse_rule (vm, r);
1015 static clib_error_t * vlib_cli_init (vlib_main_t * vm)
1017 vlib_cli_main_t * cm = &vm->cli_main;
1018 clib_error_t * error = 0;
1019 vlib_cli_command_t * cmd;
1021 cmd = cm->cli_command_registrations;
1025 error = vlib_cli_register (vm, cmd);
1028 cmd = cmd->next_cli_command;
1033 VLIB_INIT_FUNCTION (vlib_cli_init);