-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.cpp
More file actions
31 lines (28 loc) · 1.27 KB
/
hello.cpp
File metadata and controls
31 lines (28 loc) · 1.27 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
#include <fmt/format.h>
#include <fmt/ranges.h>
#include "opzioni/cmd.hpp"
int main(int argc, char const *argv[]) {
auto hello_cmd = opz::new_cmd("hello", "1.0")
.intro("Greeting people since the dawn of computing")
.pos<"pos1">({.help = "Positional 1"})
.pos<"pos2">({.help = "Positional 2"})
.opt<"opt1", "O", std::vector<int>, opz::act::append>({.help = "Option 1"})
.opt<"opt2", "P", std::vector<int>, opz::act::csv>({.help = "Option 2"})
.flg<"flg1", "f">({.help = "Flag 1"})
.flg<"flg2", "g", int, opz::act::count>({.help = "Flag 2"})
.flg<"help", "h">(opz::default_help)
.flg<"version", "v">(opz::default_version);
auto const map = hello_cmd(argc, argv);
auto const pos1 = map.get<"pos1">();
auto const pos2 = map.get<"pos2">();
auto const opt1 = map.get<"opt1">();
auto const opt2 = map.get<"opt2">();
auto const flg1 = map.get<"flg1">();
auto const flg2 = map.get<"flg2">();
fmt::print("pos1=`{}`\n", pos1);
fmt::print("pos2=`{}`\n", pos2);
fmt::print("opt1=`{}`\n", opt1);
fmt::print("opt2=`{}`\n", opt2);
fmt::print("flg1=`{}`\n", flg1);
fmt::print("flg2=`{}`\n", flg2);
}