-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ability to specify deprecated or retired options. * add retired example and tests * update some formatting and a few more test executions * fix formatting on retired.cpp * add another test to fill coverage gap for existing options that are being retired. * add example comments * Update readme with the descriptions of the new helper functions * fix space on readme * Apply suggestions from code review Co-Authored-By: Christoph Bachhuber <cbachhuber89@gmail.com> * add some flags to the code coverage report and update some names and add more descriptions to deprecated options * update formatting on App
- Loading branch information
Showing
7 changed files
with
260 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "CLI/CLI.hpp" | ||
#include <vector> | ||
|
||
// This example shows the usage of the retired and deprecated option helper methods | ||
int main(int argc, char **argv) { | ||
|
||
CLI::App app("example for retired/deprecated options"); | ||
std::vector<int> x; | ||
auto opt1 = app.add_option("--retired_option2", x); | ||
|
||
std::pair<int, int> y; | ||
auto opt2 = app.add_option("--deprecate", y); | ||
|
||
app.add_option("--not_deprecated", x); | ||
|
||
// specify that a non-existing option is retired | ||
CLI::retire_option(app, "--retired_option"); | ||
|
||
// specify that an existing option is retired and non-functional: this will replace the option with another that | ||
// behaves the same but does nothing | ||
CLI::retire_option(app, opt1); | ||
|
||
// deprecate an existing option and specify the recommended replacement | ||
CLI::deprecate_option(opt2, "--not_deprecated"); | ||
|
||
CLI11_PARSE(app, argc, argv); | ||
|
||
if(!x.empty()) { | ||
std::cout << "Retired option example: got --not_deprecated values:"; | ||
for(auto &xval : x) { | ||
std::cout << xval << " "; | ||
} | ||
std::cout << '\n'; | ||
} else if(app.count_all() == 1) { | ||
std::cout << "Retired option example: no arguments received\n"; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters