Allows users to opt-out of std::exit call in default arguments without
needing to replace with new --help and --version arguments.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
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>
Upstream StaticAnalysis looks to be changing for more flexibility with
source files to process. While these changes may eventually benefit
argparse, the public interfaces are in flux and we need a stable tool.
argparse also needs a SA change which is not yet upstream.
Trying to run clang-tidy via StaticAnalysis on a single file in a
directory with many source file is not easy, so move the analysis kernel
to a location (i.e. tools) where it is the only C++ source file.
Another benefit is cppcheck no longer needs to be told to ignore the test
sources.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
clang-tidy needs compile_commands.json to generate a set of source files
to parse. tidy-base is not built but is used as a source file in which
included headers can be parsed. Without this process, clang-tidy will
process many other source files (e.g. doctest.hpp) that we do not want
to worry about.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
Now message contains information which argument is the source of error.
It's easier to spot typo/understand which part of more complex command
is the source of problem.
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>
Because program.parse_args( { "test", "--version" }) calls std::exit(0),
the REQUIRE line never runs and this test is less useful. Because tests
execution stops here, the doctest status report is not output. If
--version can be made to not exit during this test, then the test could
be restored.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
If the developer forgot to call ArgumentParser::parse_args<>, attempts to
use ::get, ::present, etc., would raise "No value provided...". With this
change, the error better describes what went wrong.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
Here, the user gave an argument name but failed to provide the required
parameters to the argument. Tell the user which argument wants more.
This is an API change that may affect programs trying to match the
specific "Too few arguments" message. The new error message appends the
user-supplied argument that caused the error.
A solution which works with both versions is to look for "Too few
arguments" at the beginning of the error message.
- if (err.what() == "Too few arguments")
+ if (std:string(err.what()).rfind("Too few arguments", 0) == 0)
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>