15 if (CMD_ARGC < 1 || CMD_ARGC > 2)
21 const char *msg =
"<unchanged>";
25 msg = enable ?
"enable" :
"disable";
43 .handler = &handle_foo_command,
45 .usage =
"address ['enable'|'disable']",
46 .help =
"an example command",
50 .handler = &handle_foo_command,
52 .usage =
"address ['enable'|'disable']",
53 .help =
"a sample command",
57 .handler = &handle_flag_command,
79 const char *sep, *
name;
89 .handler = handle_hello_command,
91 .help =
"prints a warm welcome",
97 .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