net: openthread: remove one subcommand level in shell
Currently OpenThread commands have to be prefixed in the shell by "ot cmd", for example "ot cmd state". With the new shell, it is possible to remove one subcommand level and change it to "ot state". At the same time validate the number of arguments using SHELL_CMD_ARG_REGISTER and improve the help message. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
ac3ff65a91
commit
e98e6a8a87
@ -31,6 +31,9 @@ int otConsoleOutputCallback(const char *aBuf, uint16_t aBufLength,
|
||||
return aBufLength;
|
||||
}
|
||||
|
||||
#define SHELL_HELP_OT "OpenThread subcommands\n" \
|
||||
"Use \"ot help\" to get the list of subcommands"
|
||||
|
||||
static int ot_cmd(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
char *buf_ptr = rx_buffer;
|
||||
@ -38,10 +41,6 @@ static int ot_cmd(const struct shell *shell, size_t argc, char *argv[])
|
||||
size_t arg_len = 0;
|
||||
int i;
|
||||
|
||||
if (argc < 2) {
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (arg_len) {
|
||||
buf_len -= arg_len + 1;
|
||||
@ -70,13 +69,7 @@ static int ot_cmd(const struct shell *shell, size_t argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHELL_CREATE_STATIC_SUBCMD_SET(ot_commands)
|
||||
{
|
||||
SHELL_CMD(cmd, NULL, "OpenThread command", ot_cmd),
|
||||
SHELL_SUBCMD_SET_END
|
||||
};
|
||||
|
||||
SHELL_CMD_REGISTER(ot, &ot_commands, "OpenThread commands", NULL);
|
||||
SHELL_CMD_ARG_REGISTER(ot, NULL, SHELL_HELP_OT, ot_cmd, 2, 255);
|
||||
|
||||
void platformShellInit(otInstance *aInstance)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user