1 /*
2 * Copyright (c) 2022 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 #include <zephyr/shell/shell.h>
7
cmd2_handler(const struct shell * sh,size_t argc,char ** argv)8 static int cmd2_handler(const struct shell *sh, size_t argc, char **argv)
9 {
10 ARG_UNUSED(sh);
11 ARG_UNUSED(argc);
12 ARG_UNUSED(argv);
13
14 return 20;
15 }
16
17 SHELL_SUBCMD_ADD((section_cmd), cmd2, NULL, "help for cmd2", cmd2_handler, 1, 0);
18
sub_cmd1_handler(const struct shell * sh,size_t argc,char ** argv)19 static int sub_cmd1_handler(const struct shell *sh, size_t argc, char **argv)
20 {
21 ARG_UNUSED(sh);
22 ARG_UNUSED(argc);
23 ARG_UNUSED(argv);
24
25 return 11;
26 }
27
28 SHELL_SUBCMD_COND_ADD(1, (section_cmd, cmd1), sub_cmd1, NULL,
29 "help for sub cmd1", sub_cmd1_handler, 1, 0);
30
sub_cmd2_handler(const struct shell * sh,size_t argc,char ** argv)31 static int sub_cmd2_handler(const struct shell *sh, size_t argc, char **argv)
32 {
33 ARG_UNUSED(sh);
34 ARG_UNUSED(argc);
35 ARG_UNUSED(argv);
36
37 return 12;
38 }
39
40 /* Flag set to 0, command will not be compiled. Add to validate that setting
41 * flag to 0 does not add command and does not generate any warnings.
42 */
43 SHELL_SUBCMD_COND_ADD(0, (section_cmd, cmd1), sub_cmd2, NULL,
44 "help for sub cmd2", sub_cmd2_handler, 1, 0);
45