| 9 | #include <vector> |
| 10 | |
| 11 | int main(int argc, char **argv) { |
| 12 | |
| 13 | CLI::App app{"App to demonstrate exclusionary option groups."}; |
| 14 | |
| 15 | std::vector<int> range; |
| 16 | app.add_option("--range,-R", range, "A range")->expected(-2); |
| 17 | |
| 18 | auto *ogroup = app.add_option_group("min_max_step", "set the min max and step"); |
| 19 | int min{0}, max{0}, step{1}; |
| 20 | ogroup->add_option("--min,-m", min, "The minimum")->required(); |
| 21 | ogroup->add_option("--max,-M", max, "The maximum")->required(); |
| 22 | ogroup->add_option("--step,-s", step, "The step")->capture_default_str(); |
| 23 | |
| 24 | app.require_option(1); |
| 25 | |
| 26 | CLI11_PARSE(app, argc, argv); |
| 27 | |
| 28 | if(!range.empty()) { |
| 29 | if(range.size() == 2) { |
| 30 | min = range[0]; |
| 31 | max = range[1]; |
| 32 | } |
| 33 | if(range.size() >= 3) { |
| 34 | step = range[0]; |
| 35 | min = range[1]; |
| 36 | max = range[2]; |
| 37 | } |
| 38 | } |
| 39 | std::cout << "range is [" << min << ':' << step << ':' << max << "]\n"; |
| 40 | return 0; |
| 41 | } |
nothing calls this directly
no test coverage detected