-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequired-command-help.cpp
39 lines (32 loc) · 1 KB
/
required-command-help.cpp
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
#include <stdexcept>
#include <iostream>
#include <string>
#include "../args.h"
using std::vector;
int main(int argc, const char** argv) {
auto a = ""s;
auto b = ""s;
auto c = ""s;
auto d = ""s;
auto arg1 = ""s;
auto rest = std::vector<std::string>{};
auto carg1 = ""s;
auto crest = std::vector<std::string>{};
args::parser p = args::parser{}
.name("cli-cmd")
.command_required()
.arg(args::required, "arg1", "Global arg 1", &arg1)
.arg("arg2", "Global arg 2", &arg1)
.rest("rest", "Rest global args", &rest)
.option(args::required, "-a", "Global option A", &a)
.option("-b", "--bb", "Global option B", &b);
p.command("list", "l", "List command")
.arg(args::required, "carg1", "List command arg1", &carg1)
.rest("crest", "List command rest args", &crest)
.option("-c", "Option C", &c)
.option(args::required, "-d", "--dd", "Option D", &d);
p.command("get", "g", "Get command")
.arg(args::required, "smt", "What to get", &carg1)
.option("-h", "How to get", &c);
p.parse(argc, argv);
}