1 /*
2  * Copyright (c) 2018 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/logging/log.h>
8 #include <zephyr/shell/shell.h>
9 LOG_MODULE_REGISTER(app_test);
10 
foo(void)11 void foo(void)
12 {
13 	LOG_INF("info message");
14 	LOG_WRN("warning message");
15 	LOG_ERR("err message");
16 }
17 
18 /* Commands below are added using memory section approach which allows to build
19  * a set of subcommands from multiple files.
20  */
cmd2_handler(const struct shell * sh,size_t argc,char ** argv)21 static int cmd2_handler(const struct shell *sh, size_t argc, char **argv)
22 {
23 	ARG_UNUSED(sh);
24 	ARG_UNUSED(argc);
25 	ARG_UNUSED(argv);
26 
27 	shell_print(sh, "cmd2 executed");
28 
29 	return 0;
30 }
31 
32 SHELL_SUBCMD_ADD((section_cmd), cmd2, NULL, "help for cmd2", cmd2_handler, 1, 0);
33 
sub_cmd1_handler(const struct shell * sh,size_t argc,char ** argv)34 static int sub_cmd1_handler(const struct shell *sh, size_t argc, char **argv)
35 {
36 	ARG_UNUSED(sh);
37 	ARG_UNUSED(argc);
38 	ARG_UNUSED(argv);
39 
40 	shell_print(sh, "sub cmd1 executed");
41 
42 	return 0;
43 }
44 
45 SHELL_SUBCMD_COND_ADD(1, (section_cmd, cmd1), sub_cmd1, NULL, "help for cmd2",
46 			sub_cmd1_handler, 1, 0);
47