vlib: process startup config exec scripts line by line

This fixes long standing annoyance that CLIs with optional args cannot
be executed from file, as they cannot distinguish between valid optional
args and next line in the file.

Multiline statements can be provided simply by using backslash before \n.
Also comments are supported - everything after # is ignored up to the
end of the line.

Example:

 # multiline cli using backslash
show version \
       verbose # end of line comment

packet-generator new { \
   name x \
   limit 5 \
   # comment inside cmultiline cli \
   size 128-128 \
   interface local0 \
   node null-node \
   data { \
       incrementing 30 \
   } \
}

Type: fix

Change-Id: Ia6d588169bae14e6e3f18effe94820d05ace1dbf
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2022-05-08 20:48:37 +02:00
committed by Dave Wallace
parent c0a08cadee
commit c50bcbd6c2
4 changed files with 73 additions and 2 deletions

View File

@ -205,6 +205,7 @@ clib_error_t *vlib_cli_register_parse_rule (struct vlib_main_t *vm,
vlib_cli_parse_rule_t * c);
uword unformat_vlib_cli_args (unformat_input_t *i, va_list *va);
unformat_function_t unformat_vlib_cli_line;
uword unformat_vlib_cli_sub_input (unformat_input_t * i, va_list * args);
/* Return an vector of strings consisting of possible auto-completions