A simple and minimalistic UNIX-style command-line parsing library. More...
A simple and minimalistic UNIX-style command-line parsing library.
This functionality is included as follows:
| struct sourcemeta::core::OptionsModifiers |
| class sourcemeta::core::Options |
This class performs basic command-line argument parsing based on options, flags, and aliases. For example:
Public Member Functions | |
| Options (const Options &)=delete | |
| Options (Options &&) noexcept=default | |
| Move constructor. | |
| auto | option (std::string &&name, std::initializer_list< std::string > aliases) -> void |
| Declare a new option, which must take a value. | |
| auto | flag (std::string &&name, std::initializer_list< std::string > aliases) -> void |
| Declare a new flag, which must not take a value. | |
| auto | at (const std::string_view name) const -> const std::vector< std::string_view > & |
| Access the values (if any) set for an option or flag, by its main name. | |
| auto | contains (const std::string_view name) const -> bool |
| Check if an option or flag was set, by its main name. | |
| auto | positional () const -> const std::vector< std::string_view > & |
| Access the positional arguments, if any. | |
| auto | parse (const int argc, const char *const argv[], const OptionsModifiers options={}) -> void |
| Parse program arguments given the declared options and flags. | |
| class sourcemeta::core::OptionsError |
This class represents a general options error
| struct sourcemeta::core::OptionsUnknownOptionError |
This class represents a unknown option error
Public Member Functions | |
| OptionsUnknownOptionError (const std::string_view option) | |
| Construct the error given the offending option. | |
| auto | option () const noexcept -> std::string_view |
| The offending option. | |
| Public Member Functions inherited from sourcemeta::core::OptionsError | |
| OptionsError (const char *message) | |
| Construct the error given a message. | |
| OptionsError (std::string message)=delete | |
| OptionsError (std::string &&message)=delete | |
| OptionsError (std::string_view message)=delete | |
| struct sourcemeta::core::OptionsUnexpectedValueFlagError |
This class represents a value being passed to a flag
Public Member Functions | |
| OptionsUnexpectedValueFlagError (const std::string_view option) | |
| Construct the error given the offending option. | |
| auto | option () const noexcept -> std::string_view |
| The offending option. | |
| Public Member Functions inherited from sourcemeta::core::OptionsError | |
| OptionsError (const char *message) | |
| Construct the error given a message. | |
| OptionsError (std::string message)=delete | |
| OptionsError (std::string &&message)=delete | |
| OptionsError (std::string_view message)=delete | |
| struct sourcemeta::core::OptionsMissingOptionValueError |
This class represents a missing value from an option
Public Member Functions | |
| OptionsMissingOptionValueError (const std::string_view option) | |
| Construct the error given the offending option. | |
| auto | option () const noexcept -> std::string_view |
| The offending option. | |
| Public Member Functions inherited from sourcemeta::core::OptionsError | |
| OptionsError (const char *message) | |
| Construct the error given a message. | |
| OptionsError (std::string message)=delete | |
| OptionsError (std::string &&message)=delete | |
| OptionsError (std::string_view message)=delete | |