-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.cpp
More file actions
44 lines (39 loc) · 1005 Bytes
/
demo.cpp
File metadata and controls
44 lines (39 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Author: luoqi
* Created Date: 2026-04-06 21:26:25
* Last Modified: 2026-04-06 21:33:50
* Modified By: luoqi at <**@****>
* Copyright (c) 2026 <*****>
* Description:
*/
#include "cmdmgr.hpp"
static int args_dump(int argc, char **argv)
{
std::printf(" dump:\r\n");
for(int i = 0; i < argc; i++) {
std::printf(" argv[%d]: %s\r\n", i, argv[i]);
}
return 0;
}
static CmdTable table[] = {
{ "dump", args_dump, "dump topic" },
};
static int cmd_demo(int argc, char **argv)
{
if(argc == 1) {
for(int i = 0; i < argc; i++) {
std::printf(" argv[%d]: %s\r\n", i, argv[i]);
}
}
CMD_ARGS_TRICK(argc, argv, table)
}
CMD_REGIST("demo", cmd_demo, "demo command");
static int subcmd_demo_dump(int argc, char **argv)
{
std::printf(" subcmd:\r\n");
for(int i = 0; i < argc; i++) {
std::printf(" argv[%d]: %s\r\n", i, argv[i]);
}
return 0;
}
CMD_SUB_REGIST("demo", "subdemo", subcmd_demo_dump, "sub-command demo");