Please don't be this person:

static clib_error_t *
my_cli_command_fn (vlib_main_t * vm,
                       unformat_input_t * input,
                       vlib_cli_command_t * cmd)
{
  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    {
      if (unformat (input, "mystuff"))
      else
         return (clib_error_return (0, "unknown input '%U'",
                        format_unformat_error, input));
    }
  return (NULL);
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (my_command, static) =
{
  .path = "my command",
  .function = my_cli_command_fn,
};

Commands coded like this work fine when typed one at a time, but they blow 
chunks when scripted...

Script:
my command mystuff
comment { ouch my_cli_command_fn ate the word comment and threw up! }

Instead, wrap the while(...) loop with the unformat_line_input guitar lick:

  elib_error_t *e = 0;
  /* Get a line of input. */
  if (!unformat_user (input, unformat_line_input, line_input))
    return 0;

  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
    {
      if (unformat (line_input, "mystuff"))
        ;
      else {
        e = clib_error_return (0, "unknown input '%U'",
                      format_unformat_error, input);
        goto done;
      }
    }


done:
  unformat_free (line_input);
  return e;

Thanks... Dave
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#17532): https://lists.fd.io/g/vpp-dev/message/17532
Mute This Topic: https://lists.fd.io/mt/77125668/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to