14 if (CMD_ARGC < 1 || CMD_ARGC > 2)
20 const char *msg =
"<unchanged>";
24 msg = enable ?
"enable" :
"disable";
42 .handler = &handle_foo_command,
44 .usage =
"address ['enable'|'disable']",
45 .help =
"an example command",
49 .handler = &handle_foo_command,
51 .usage =
"address ['enable'|'disable']",
52 .help =
"a sample command",
56 .handler = &handle_flag_command,
78 const char *sep, *
name;
88 .handler = handle_hello_command,
90 .help =
"prints a warm welcome",
96 .help =
"example command handler skeleton",
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
#define CMD_NAME
Use this macro to access the name of the command being handled, rather than accessing the variable di...
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_ENABLE(in, out)
parses an enable/disable command argument
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
COMMAND_HANDLER(handle_foo_command)
static const struct command_registration foo_command_handlers[]
static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name)
const struct command_registration hello_command_handlers[]
Export the registration for the hello command group, so it can be embedded in example drivers.
#define LOG_INFO(expr ...)
const char * usage
a string listing the options and arguments, required or optional