|
The Lean Mean C++ Option Parser
|
The Lean Mean C++ Option Parser handles the program's command line arguments (argc, argv). It supports the short and long option formats of getopt(), getopt_long() and getopt_long_only() but has a more convenient interface.
optionparser-feedback(a)lists.sourceforge.net#include "optionparser.h" and you're set. option::* identifiers are links that take you to their documentation.) getopt() conventions and supports GNU-style getopt_long() long options as well as Perl-style single-minus long options (getopt_long_only()). -X where X is any character that fits in a char. -X -Y is equivalent to -XY. -X foo) or attached (-Xfoo). You can make the parser accept the additional format -X=foo by registering X as a long option (in addition to being a short option) and enabling single-minus long options. -ABCXfoo or -ABCX foo (foo is the argument to the -X option). '-' is not treated as an option. It is customarily used where a file name is expected to refer to stdin or stdout. –option-name. = characters will work, but don't do that. –option arg ) or attached ( –option=arg ). In the attached form the equals sign is mandatory. –option-name= . Note the distinction between an empty string as argument and no argument at all. '-' character. E.g. -X-X , -X -X or –long-X=-X . If -X and –long-X take an argument, that argument will be "-X" in all 3 cases. – (i.e. without a name) terminates the list of options. Everything that follows is a non-option argument, even if it starts with a '-' character. The – itself will not appear in the parse results. '-' or '–' and does not belong to a preceding argument-taking option, will terminate the option list and is the first non-option argument. All following command line arguments are treated as non-option arguments, even if they start with '-' . true as first argument to e.g. Parser::parse(). '-' followed by at least 1 character) but aren't, are NOT treated as non-option arguments. They are treated as unknown options and are collected into a list of unknown options for error reporting. – special option, e.g. –strange-filename is a non-option argument. If the – were omitted, it would be treated as an unknown option.
1.8.11