forked from CLIUtils/CLI11
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change the move function to _move_option and add an additional test add a validation check on min options to make sure it is even possible to succeed. add some additional tests to cover code paths and potential errors. add a number of additional tests and checks and fix some issues with the add function in option_groups clean up example and help formatting add option_groups example to play with move create_option_group to a member function using a dummy template add some optionGroup tests add min and max options calls and an associated Error call * add ranges example, add excludes to app for options and subcommands. * add some tests on ranges, and some subcommand tests with exclusion * add tests in optionGroups for some invalid inputs * add required option to subcommands and option_groups * add disabled flag * add disable option to subcommands and some more tests * start work on ReadMe modifications * update the readme with descriptions of function and methods added for option_groups * clear up gcc 4.7 warnings * some update to the Readme and a few more warnings fixed * Minor readme touchup
- Loading branch information
Showing
14 changed files
with
1,158 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "CLI/CLI.hpp" | ||
|
||
int main(int argc, char **argv) { | ||
|
||
CLI::App app("data output specification"); | ||
app.set_help_all_flag("--help-all", "Expand all help"); | ||
|
||
auto format = app.add_option_group("output_format", "formatting type for output"); | ||
auto target = app.add_option_group("output target", "target location for the output"); | ||
bool csv = false; | ||
bool human = false; | ||
bool binary = false; | ||
format->add_flag("--csv", csv, "specify the output in csv format"); | ||
format->add_flag("--human", human, "specify the output in human readable text format"); | ||
format->add_flag("--binary", binary, "specify the output in binary format"); | ||
// require one of the options to be selected | ||
format->require_option(1); | ||
std::string fileLoc; | ||
std::string networkAddress; | ||
target->add_option("-o,--file", fileLoc, "specify the file location of the output"); | ||
target->add_option("--address", networkAddress, "specify a network address to send the file"); | ||
|
||
// require at most one of the target options | ||
target->require_option(0, 1); | ||
CLI11_PARSE(app, argc, argv); | ||
|
||
std::string format_type = (csv) ? std::string("CSV") : ((human) ? "human readable" : "binary"); | ||
std::cout << "Selected " << format_type << "format" << std::endl; | ||
if(fileLoc.empty()) { | ||
std::cout << " sent to file " << fileLoc << std::endl; | ||
} else if(networkAddress.empty()) { | ||
std::cout << " sent over network to " << networkAddress << std::endl; | ||
} else { | ||
std::cout << " sent to std::cout" << std::endl; | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "CLI/CLI.hpp" | ||
|
||
int main(int argc, char **argv) { | ||
|
||
CLI::App app{"App to demonstrate exclusionary option groups."}; | ||
|
||
std::vector<int> range; | ||
app.add_option("--range,-R", range, "A range")->expected(-2); | ||
|
||
auto ogroup = app.add_option_group("min_max_step", "set the min max and step"); | ||
int min, max, step = 1; | ||
ogroup->add_option("--min,-m", min, "The minimum")->required(); | ||
ogroup->add_option("--max,-M", max, "The maximum")->required(); | ||
ogroup->add_option("--step,-s", step, "The step", true); | ||
|
||
app.require_option(1); | ||
|
||
CLI11_PARSE(app, argc, argv); | ||
|
||
if(!range.empty()) { | ||
if(range.size() == 2) { | ||
min = range[0]; | ||
max = range[1]; | ||
} | ||
if(range.size() >= 3) { | ||
step = range[0]; | ||
min = range[1]; | ||
max = range[2]; | ||
} | ||
} | ||
std::cout << "range is [" << min << ':' << step << ':' << max << "]\n"; | ||
return 0; | ||
} |
Oops, something went wrong.