Skip to content

v2.0.0

Choose a tag to compare

@SpectraL519 SpectraL519 released this 15 Feb 12:51
· 32 commits to master since this release

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(
const AR& argv
)
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(
std::initializer_list<value_type> choices
)
Aligned
Sets the choices parameter of a positional argument.
NOTE: Previously the function used std::vector<value_type>.
argument::positional::choices(
const CR& choices
)
New
Sets the choices parameter of a positional argument using a range of value_type-convertible objects.
argument::optional::choices(
std::initializer_list<value_type> choices
)
Aligned
Sets the choices parameter of an optional argument.
NOTE: Previously the function used std::vector<value_type>.
argument::optional::choices(
const CR& 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[])
void try_parse_args(const AR& 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>(
std::string_view arg_name, U&& default_value
)
Returns the argument's value if possible and default_value otherwise.

A more detailed explanation of these functions is available in the Tutorial section.