Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lmclmc committed May 8, 2023
1 parent cb80f0f commit 4c9eb51
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@
## build
./build.sh
## cmdline
### normal usage
// add specified type of variable.
// 1st argument is short name
// 2nd argument is long name
// 3rd argument is description
// 4th argument is depends option
// 5th argument is paramter ranage
cmd->add<std::unordered_multiset<int>>("-unmint", "--unorderdmsetint",
"get unordered_multiset int",
{"-dix"}, {44, 99});
// add specified type of variable.
// 1st argument is long name
// 2nd argument is short name (no short name if '\0' specified)
// 3rd argument is description
// 4th argument is depends option
cmd->add("-n", "--none", "get none", {"-s", "-us", "-i"});
// add specified type of variable.
// 1st argument is long name
// 2nd argument is short name (no short name if '\0' specified)
// 3rd argument is description
// 4th argument is depends option
// 5th argument is paramter ranage
cmd->add<std::string>("-sns", "--singlestring", "get single string",
{"-s", "-us", "-i"},
{"aaa", "vvv", "bbb", "rrr", "ttt"});
//parse paramter argv
cmd->parse(false, argc, argv);
//get value
std::string singleStr;
bool ret = cmd->get("--singlestring", singleStr);

### cmdline execution results
./build/install/demo/cmdline/cmdline
usage: ./build/install/demo/cmdline/cmdline [options] ...
options:
Expand Down
19 changes: 18 additions & 1 deletion demo/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,27 @@ int main(int argc, char *argv[])
"get unordered_multiset string",
{},
{"aaa", "vvv", "bbb", "rrr"});
// add specified type of variable.
// 1st argument is short name
// 2nd argument is long name
// 3rd argument is description
// 4th argument is depends option
// 5th argument is paramter ranage
cmd->add<std::unordered_multiset<int>>("-unmint", "--unorderdmsetint",
"get unordered_multiset int",
{}, {44, 99});
{"-dix"}, {44, 99});
// add specified type of variable.
// 1st argument is long name
// 2nd argument is short name (no short name if '\0' specified)
// 3rd argument is description
// 4th argument is depends option
cmd->add("-n", "--none", "get none", {"-s", "-us", "-i"});
// add specified type of variable.
// 1st argument is long name
// 2nd argument is short name (no short name if '\0' specified)
// 3rd argument is description
// 4th argument is depends option
// 5th argument is paramter ranage
cmd->add<std::string>("-sns", "--singlestring", "get single string",
{"-s", "-us", "-i"},
{"aaa", "vvv", "bbb", "rrr", "ttt"});
Expand Down

0 comments on commit 4c9eb51

Please sign in to comment.