This allows updating attached object properties without holding external
references to the various Argument and ArgumentParser objects.
Closes#227
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This allows checking whether user input was processed into the parser
or any attached subparsers.
Closes#212
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
FetchContent_MakeAvailable was added in CMake v3.14. Also includes
end-of-line whitespace clean-ups.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
Help output has changed format over time. This updates the README
example to reflect current practice by running the example code
and copy-pasting its output.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
The help and version arguments are still included by default, but which
default arguments to include can be overridden at ArgumentParser creation.
argparse generally copies Python argparse behavior. This includes a
default `--help`/`-h` argument to print a help message and exit. Some
developers using argparse find the automatic exit to be undesirable.
The Python argparse has an opt-out parameter when constructing an
ArgumentParser. Using `add_help=False` avoids adding a default `--help`
argument and allows the developer to implement a custom help.
This commit adds a similar opt-out to our C++ argparse, but keeps the
current behavior as the default. The `--help`/`-h` and `--version`/`-v`
Arguments handle their own output and exit rather than specially treating
them in ArgumentParser::parse_args_internal.
Closes#119Closes#138Closes#139
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
Previously, only arguments with one or more parameters would run actions.
But, at times it can be useful to run an action when an argument does not
expect any parameters.
Closes#104
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
These examples give a false impression that a space in the middle of the
application name is well handled. While a space might be possible, it
must be escaped in shells, i.e. a common environment for a CLI argument
parser.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
argparse seems to use the "std::" qualifier for std namespace members,
continue that in the documentation.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
IMHO, the .scan function and its supporting functions are beautiful
metaprogramming that needs to be more visible to argparse users. As a
start, document the function, with simple examples.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
.present returns std::nullopt if the optional argument is not given by the
user -- as long as a .default_value is not defined. With a .default_value,
.present cannot be used to determine if a value is user-provided or the
default.
.is_used fills that role and only returns true if the argument was passed
by the user.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
The default behavior with optional arguments is to allow only a single use
per invocation. One alternative is to use .nargs, but this requires
previously knowing, and limiting, the quantity of values. The .append
method removes the restriction on repeats for a single Argument.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>