MCPcopy Create free account
hub / github.com/bfgroup/Lyra / main

Function main

examples/doc_example6.cpp:12–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <lyra/lyra.hpp>
11
12int main(int argc, const char** argv)
13{
14 int choice = 5;
15 // Ex: <exe> --choice=3
16 auto cli = lyra::cli()
17 | lyra::opt(choice, "-c")["--choice"]
18 .choices([](int value) { return 1 <= value && value <= 10; });
19 auto result = cli.parse({ argc, argv });
20 if (result)
21 {
22 std::cout << "Your number between one and ten is " << choice << "\n";
23 return 0;
24 }
25 else
26 {
27 std::cerr << result.message() << "\n";
28 return 1;
29 }
30}
31// end::part1[]

Callers

nothing calls this directly

Calls 4

cliClass · 0.50
optClass · 0.50
parseMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected