This example shows the usage of the retired and deprecated option helper methods
| 11 | |
| 12 | // This example shows the usage of the retired and deprecated option helper methods |
| 13 | int main(int argc, char **argv) { |
| 14 | |
| 15 | CLI::App app("example for retired/deprecated options"); |
| 16 | std::vector<int> x; |
| 17 | auto *opt1 = app.add_option("--retired_option2", x); |
| 18 | |
| 19 | std::pair<int, int> y; |
| 20 | auto *opt2 = app.add_option("--deprecate", y); |
| 21 | |
| 22 | app.add_option("--not_deprecated", x); |
| 23 | |
| 24 | // specify that a non-existing option is retired |
| 25 | CLI::retire_option(app, "--retired_option"); |
| 26 | |
| 27 | // specify that an existing option is retired and non-functional: this will replace the option with another that |
| 28 | // behaves the same but does nothing |
| 29 | CLI::retire_option(app, opt1); |
| 30 | |
| 31 | // deprecate an existing option and specify the recommended replacement |
| 32 | CLI::deprecate_option(opt2, "--not_deprecated"); |
| 33 | |
| 34 | CLI11_PARSE(app, argc, argv); |
| 35 | |
| 36 | if(!x.empty()) { |
| 37 | std::cout << "Retired option example: got --not_deprecated values:"; |
| 38 | for(auto &xval : x) { |
| 39 | std::cout << xval << " "; |
| 40 | } |
| 41 | std::cout << '\n'; |
| 42 | } else if(app.count_all() == 1) { |
| 43 | std::cout << "Retired option example: no arguments received\n"; |
| 44 | } |
| 45 | return 0; |
| 46 | } |
nothing calls this directly
no test coverage detected