-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
21 lines (18 loc) · 764 Bytes
/
main.cpp
File metadata and controls
21 lines (18 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// more-details: https://github.com/mcpplibs/cmdline
import std;
import mcpplibs.cmdline;
using namespace mcpplibs;
int main(int argc, char* argv[]) {
auto app = cmdline::App("myapp")
.version("1.0.0")
.description("A demo CLI")
.arg("input").required().help("Input file")
.option("verbose").short_name('v').help("Verbose output")
.option("config").short_name('c').takes_value().value_name("FILE").help("Config file")
.action([](const cmdline::ParsedArgs& p) {
if (p.is_flag_set("verbose")) std::println("Verbose on");
if (auto c = p.value("config")) std::println("Config: {}", *c);
std::println("Input: {}", p.positional(0));
});
return app.run(argc, argv);
}