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

Function main

examples/doc_example1_alt.cpp:13–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include <lyra/lyra.hpp>
12
13int main(int argc, const char** argv)
14{
15 // Where we read in the argument value:
16 int width = 0;
17
18 // The parser with the one option argument:
19 auto cli = lyra::cli();
20 cli.add_argument(
21 lyra::opt(width, "width")
22 .name("-w")
23 .name("--width")
24 .help("How wide should it be?"));
25
26 // Parse the program arguments:
27 auto result = cli.parse({ argc, argv });
28
29 // Check that the arguments where valid:
30 if (!result)
31 {
32 std::cerr << "Error in command line: " << result.message() << std::endl;
33 return 1;
34 }
35
36 std::cout << "width = " << width << "\n";
37 return 0;
38}
39// end::doc[]

Callers

nothing calls this directly

Calls 6

cliClass · 0.50
optClass · 0.50
helpMethod · 0.45
nameMethod · 0.45
parseMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected