-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_cmd.cpp
More file actions
47 lines (35 loc) · 1.06 KB
/
Copy pathuser_cmd.cpp
File metadata and controls
47 lines (35 loc) · 1.06 KB
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
45
46
// **************************************************************************
// File [ test_cmd.cpp ]
// Author [ littleshamoo ]
// Synopsis [ ]
// Date [ 2012/04/10 created ]
// **************************************************************************
#include "user_cmd.h"
using namespace std;
using namespace CommonNs;
TestCmd::TestCmd(const char * const name) : Cmd(name) {
optMgr_.setShortDes("test");
optMgr_.setDes("test");
Opt *opt = new Opt(Opt::BOOL, "print usage", "");
opt->addFlag("h");
opt->addFlag("help");
optMgr_.regOpt(opt);
opt = new Opt(Opt::STR_REQ, "print the string of -s", "[string]");
opt->addFlag("s");
optMgr_.regOpt(opt);
}
TestCmd::~TestCmd() {}
bool TestCmd::exec(int argc, char **argv) {
optMgr_.parse(argc, argv);
if (optMgr_.getParsedOpt("h")) {
optMgr_.usage();
return true;
}
if (optMgr_.getParsedOpt("s")) {
printf("%s\n", optMgr_.getParsedValue("s"));
return true;
}
else
printf("hello world !!\n");
return true;
}