mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 12:13:52 +00:00
in progress: formatters Getting closer Working on apps One test actually runs All builds, added filter functions Reverting a few behavours as needed Repairs All tests pass Fixing error with adding help flag Labels are simpler mappings, normalized setters Adding help_all Adding a few more tests One more line tested Adding one more check Adding to readme Simplify naming Adding default constructors Fixing spacing issues with subcommand all printout Adding a couple of tests
31 lines
828 B
C++
31 lines
828 B
C++
#include <CLI/CLI.hpp>
|
|
|
|
class MyFormatter : public CLI::OptionFormatter {
|
|
public:
|
|
std::string make_opts(const CLI::Option *) const override { return " OPTION"; }
|
|
};
|
|
|
|
int main(int argc, char **argv) {
|
|
CLI::App app;
|
|
app.set_help_all_flag("--help-all", "Show all help");
|
|
|
|
app.option_defaults()->formatter(MyFormatter());
|
|
|
|
CLI::AppFormatter fmt;
|
|
fmt.column_width(15);
|
|
app.formatter(fmt);
|
|
|
|
app.add_flag("--flag", "This is a flag");
|
|
|
|
auto sub1 = app.add_subcommand("one", "Description One");
|
|
sub1->add_flag("--oneflag", "Some flag");
|
|
auto sub2 = app.add_subcommand("two", "Description Two");
|
|
sub2->add_flag("--twoflag", "Some other flag");
|
|
|
|
CLI11_PARSE(app, argc, argv);
|
|
|
|
std::cout << "This app was meant to show off the formatter, run with -h" << std::endl;
|
|
|
|
return 0;
|
|
}
|