| 14 | #include <lyra/lyra.hpp> |
| 15 | |
| 16 | int main(int argc, const char ** argv) |
| 17 | { |
| 18 | using namespace lyra; |
| 19 | |
| 20 | bool show_help = false; |
| 21 | std::vector<int> input_shape; |
| 22 | |
| 23 | auto parse_shape_value = [&](std::string shape) { |
| 24 | std::istringstream s(shape); |
| 25 | std::string i; |
| 26 | while (std::getline(s, i, ',')) |
| 27 | { |
| 28 | int x = 0; |
| 29 | if (lyra::detail::from_string(i, x)) input_shape.push_back(x); |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | lyra::cli cli; |
| 34 | cli.add_argument( |
| 35 | help(show_help).description("Parse many values into a vector.")); |
| 36 | cli.add_argument( |
| 37 | opt(parse_shape_value, "input-shape").name("--input-shape")); |
| 38 | |
| 39 | auto result = cli.parse({ argc, argv }); |
| 40 | |
| 41 | if (!result) std::cerr << result.message() << "\n\n"; |
| 42 | if (show_help or !result) |
| 43 | std::cout << cli << "\n"; |
| 44 | else |
| 45 | { |
| 46 | std::cout << "input shape : "; |
| 47 | for (auto x : input_shape) std::cout << x << " "; |
| 48 | std::cout << "\n"; |
| 49 | } |
| 50 | |
| 51 | return 0; |
| 52 | } |