v2.0.0
The Structure
The v2 version of the library no longer uses a single-header approach, however it is still a header-only library. With this change it is now required to download the entire library - either with CMake or from the releases page.
Range-based Approach
Aligned functions to use a generic range-based approach, which allows for more flexibility in using the library.
| Function | Description |
|---|---|
argument_parser::parse_args( |
New Parses the command-line arguments passed through a range of string-convertible objects.NOTE: The parse_args(argc, argv) function is still available. |
argument::positional::choices( |
Aligned Sets the choices parameter of a positional argument.NOTE: Previously the function used std::vector<value_type>. |
argument::positional::choices( |
New Sets the choices parameter of a positional argument using a range of value_type-convertible objects. |
argument::optional::choices( |
Aligned Sets the choices parameter of an optional argument.NOTE: Previously the function used std::vector<value_type>. |
argument::optional::choices( |
New Sets the choices parameter of an optional argument using a range of value_type-convertible objects. |
New Utility Functions
Added utility functions to the argument_parser class that encapsulate common behavior, reducing the need to write boilerplate code and simplifying the argument-parsing logic.
| Function | Description |
|---|---|
void try_parse_args(int argc, char* argv[]) |
Parses the command-line arguments and, in case of an error, prints the error message and exits with a failure status. |
void handle_help_action() |
Checks the value of the help boolean flag argument and exits with success status if the value is true. |
T value_or<T, U>( |
Returns the argument's value if possible and default_value otherwise. |
A more detailed explanation of these functions is available in the Tutorial section.