Command line parser which automatically fills variables and prints nice usage messages.
This is a straightforward command line parser in C++, which will recognize short options -s, long options –long and parameters, both required and optional. It will automatically parse integers and byte sizes with SI/IEC suffixes (e.g. 1 GiB). It also works with lists of strings, e.g. multiple filenames.
Maybe most important it will nicely format the options and parameters description using word wrapping.
- Examples:
- examples/applications/skew3.cpp, and examples/common/cmdline.cpp.
Definition at line 45 of file cmdline.h.
|
| cmdline_parser () |
| Construct new command line parser. More...
|
|
| ~cmdline_parser () |
| Delete all added arguments. More...
|
|
void | add_bytes (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, stxxl::uint32 &dest) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest More...
|
|
void | add_bytes (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, stxxl::uint64 &dest) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest More...
|
|
void | add_bytes (char key, const std::string &longkey, const std::string &desc, stxxl::uint32 &dest) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 32-bit dest More...
|
|
void | add_bytes (char key, const std::string &longkey, const std::string &desc, stxxl::uint64 &dest) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest More...
|
|
void | add_flag (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool &dest) |
| add boolean option flag -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_flag (char key, const std::string &longkey, const std::string &desc, bool &dest) |
| add boolean option flag -key, –longkey with description and store to dest More...
|
|
void | add_int (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, int &dest) |
| add signed integer option -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_int (char key, const std::string &longkey, const std::string &desc, int &dest) |
| add signed integer option -key, –longkey with description and store to dest More...
|
|
void | add_opt_param_bytes (const std::string &name, const std::string &desc, uint32 &dest) |
| add optional SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_opt_param_bytes (const std::string &name, const std::string &desc, uint64 &dest) |
| add optional SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_opt_param_int (const std::string &name, const std::string &desc, int &dest) |
| add optional signed integer parameter [name] with description and store to dest More...
|
|
void | add_opt_param_string (const std::string &name, const std::string &desc, std::string &dest) |
| add optional string parameter [name] with description and store to dest More...
|
|
void | add_opt_param_stringlist (const std::string &name, const std::string &desc, std::vector< std::string > &dest) |
| add optional string parameter [name] with description and store to dest More...
|
|
void | add_opt_param_uint (const std::string &name, const std::string &desc, unsigned int &dest) |
| add optional unsigned integer parameter [name] with description and store to dest More...
|
|
void | add_param_bytes (const std::string &name, const std::string &desc, uint32 &dest) |
| add SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_param_bytes (const std::string &name, const std::string &desc, uint64 &dest) |
| add SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_param_int (const std::string &name, const std::string &desc, int &dest) |
| add signed integer parameter [name] with description and store to dest More...
|
|
void | add_param_string (const std::string &name, const std::string &desc, std::string &dest) |
| add string parameter [name] with description and store to dest More...
|
|
void | add_param_stringlist (const std::string &name, const std::string &desc, std::vector< std::string > &dest) |
| add string list parameter [name] with description and store to dest. More...
|
|
void | add_param_uint (const std::string &name, const std::string &desc, unsigned int &dest) |
| add unsigned integer parameter [name] with description and store to dest More...
|
|
void | add_string (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, std::string &dest) |
| add string option -key, –longkey [keytype] and store to dest More...
|
|
void | add_string (char key, const std::string &longkey, const std::string &desc, std::string &dest) |
| add string option -key, –longkey [keytype] and store to dest More...
|
|
void | add_stringlist (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, std::vector< std::string > &dest) |
| add string list option -key, –longkey [keytype] and store to dest More...
|
|
void | add_stringlist (char key, const std::string &longkey, const std::string &desc, std::vector< std::string > &dest) |
| add string list option -key, –longkey [keytype] and store to dest More...
|
|
void | add_uint (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, unsigned int &dest) |
| add unsigned integer option -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_uint (char key, const std::string &longkey, const std::string &desc, unsigned int &dest) |
| add unsigned integer option -key, –longkey [keytype] with description and store to dest More...
|
|
void | print_result (std::ostream &os=std::cout) |
| print nicely formatted result of processing More...
|
|
void | print_usage (std::ostream &os=std::cout) |
| output nicely formatted usage information including description of all parameters and options. More...
|
|
bool | process (int argc, const char *const *argv, std::ostream &os=std::cout) |
| parse command line options as specified by the options and parameters added. More...
|
|
void | set_author (const std::string &author) |
| Set author of program, will be wrapped. More...
|
|
void | set_description (const std::string &description) |
| Set description of program, text will be wrapped. More...
|
|
void | set_verbose_process (bool verbose_process) |
| Set verbose processing of command line arguments. More...
|
|