19 enum optionIndex { UNKNOWN, HELP, PLUS };
27 " example --unknown -- --this_is_no_option\n" 28 " example -unk --plus -ppp file1 file2\n" },
32 int main(
int argc,
char* argv[])
34 argc-=(argc>0); argv+=(argc>0);
36 std::vector<option::Option> options(stats.options_max);
37 std::vector<option::Option> buffer(stats.buffer_max);
43 if (options[HELP] || argc == 0) {
48 std::cout <<
"--plus count: " <<
49 options[PLUS].count() <<
"\n";
52 std::cout <<
"Unknown option: " << std::string(opt->name,opt->namelen) <<
"\n";
54 for (
int i = 0; i < parse.nonOptionsCount(); ++i)
55 std::cout <<
"Non-option #" << i <<
": " << parse.nonOption(i) <<
"\n";
Determines the minimum lengths of the buffer and options arrays used for Parser.
This is the only file required to use The Lean Mean C++ Option Parser. Just #include it and you're se...
static ArgStatus None(const Option &, bool)
For options that don't take an argument: Returns ARG_NONE.
A parsed option from the command line together with its argument if it has one.
Option * next()
Returns a pointer to the next element of the linked list or NULL if called on last().
Checks argument vectors for validity and parses them into data structures that are easier to work wit...
Describes an option, its help text (usage) and how it should be parsed.
void printUsage(OStream &prn, const Descriptor usage[], int width=80, int last_column_min_percent=50, int last_column_own_line_max_percent=75)
Outputs a nicely formatted usage string with support for multi-column formatting and line-wrapping...