| 11 | #include <lyra/lyra.hpp> |
| 12 | |
| 13 | int 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[] |