Commit Graph

684 Commits

Author SHA1 Message Date
He Shiming
3d7596765b implements column-aligned multi-line help message for arguments (issue #248) 2023-01-30 19:28:07 +08:00
Sean Robinson
d0beb40d64 Fix cmake option command by including help text
The option() command expects a help string between the variable and the
initial value.

Closes #241

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-17 14:26:14 -07:00
Sean Robinson
be705d191b Remove cmake option for removable '-v'
This was made obsolete by commit ea1f7ef663.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-17 14:15:05 -07:00
Sean Robinson
6974f46851 Revert "Use references for any_cast"
This attempts to fix Issue #225-1 by reverting the change that turned a
std::bad_any_cast exception into a nullptr.

Reverts commit 357068156e.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-17 13:57:59 -07:00
Sean Robinson
7ed952f4fe Add test for ArgumentParser::get() with inappropriate type
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-17 13:57:59 -07:00
Sean Robinson
d845381028 Fix Argument bool bit fields
The intent of ": 1" is to use individual bits to store the bool state of
these class values. Because true != 0, this worked. But it was likely to
bite someone sometime. (My bad: 0fe17e22f6.)

This commit also adds m_accepts_optional_like_value to the bit field and
sets the default false value in the constructor.

Because we cannot set a default value during declaration (until C++20).
make sure future coders know to set the preferred default in the
constructor.

Closes #213

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-17 13:57:59 -07:00
Sean Robinson
04ac1fe366 Refactor Parent Parsers documentation
This replaces the verbiage copied from the Python argparse documentation
and makes the code sample more concrete. This illustrates how to avoid the
multiple help output problem reported in #165.

Closes #165

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-17 13:57:59 -07:00
Sean Robinson
a5ab5b0ce8 Update minimum supported MSVC version
https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170

Closes #228

Reported-by: @c0rn1ie
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-17 13:57:59 -07:00
Pranav
15d745f584
Merge pull request #255 from serge-sans-paille/fix/cmake-install-dir
Install cmake export file in CMAKE_INSTALL_DIR
2023-01-17 08:48:50 -06:00
serge-sans-paille
a442a74569 Install cmake export file in CMAKE_INSTALL_DIR
Per https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#exporting-targets
this is the standard way to do so, no need to hack CMAKE_INSTALL_LIBDIR_ARCHIND
2023-01-15 22:03:22 +01:00
Sean Robinson
cb3da173f6 Fix crash with char[] default values
Closes #249

Reported-by: @pfeatherstone
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2023-01-05 13:02:40 -07:00
Pranav
af0f7cb25f
Merge pull request #252 from skrobinson/fix-help-arg-docs
Highlight default arguments and their default behavior
2022-12-20 14:29:32 -06:00
Sean Robinson
ecba90a4eb Highlight default arguments and their default behavior
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-12-20 09:44:34 -07:00
Pranav
d1d006f8f1
Merge pull request #245 from skrobinson/feat-at-function
Add ArgumentParser::at to retrieve arguments and subparsers
2022-11-30 08:55:47 -06:00
Sean Robinson
5f22faa973 Add ArgumentParser::at to retrieve arguments and subparsers
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>
2022-11-29 13:43:16 -07:00
Pranav
6992b3b0df
Merge pull request #244 from skrobinson/fix-tidy-checks
Fix tidy checks
2022-11-29 14:37:09 -06:00
Sean Robinson
a832ac3496 Analyze only argparse header in PR clang-tidy action
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-11-29 10:40:39 -07:00
Sean Robinson
4f47631525 Update clang-tidy configuration to only include main header
The previous regex would also analyze doctest.hpp.  We don't need to check
a vendored library.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-11-29 10:40:29 -07:00
Pranav
f901d9edb4
Merge pull request #238 from aayush749/fix#235
Added a fix for issue #235
2022-11-13 16:14:44 -06:00
Aayush Anand
6eb0ea7738 added fix for issue #235 2022-11-12 20:24:36 +05:30
Pranav
a8aa3cc999
Merge pull request #231 from BryanFlynt/master
No install when used as third party
2022-11-08 09:42:30 -06:00
Pranav
2ed761a201
Merge pull request #233 from SergiusTheBest/is-subcommand-used-overload
Add is_subcommand_used overload
2022-11-08 09:41:19 -06:00
Sergey Podobry
8e6a36dd0d Add is_subcommand_used overload
It's useful for removing string literals duplication in a code.
2022-11-08 01:31:45 +02:00
BryanFlynt
d201a3e1df
Update CMakeLists.txt
Default ON for ARGPARSE_INSTALL
2022-11-05 15:47:39 -06:00
BryanFlynt
764442f0f4
Update CMakeLists.txt
Added ARGPARSE_INSTALL
This allows a separate project using argparse through CMake FetchContent_Declare(...) to install the project without having to also install argparse.
2022-11-05 15:45:17 -06:00
Pranav
6960571156
Merge pull request #229 from marzer/fix-sv-is-container
Fix std::string_view being identified as a container
2022-11-05 08:53:04 -05:00
Pranav
9c830b9bac
Merge pull request #230 from skrobinson/fix-tidy-check
Fix tidy check
2022-11-04 20:27:32 -05:00
Sean Robinson
784aa7916e Use C++17 standard with clang-tidy in PR checks
Needed for std::string_view.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-11-04 10:19:11 -07:00
Mark Gillard
04faefeae3 Fix std::string_view being identified as a container 2022-11-04 16:41:29 +02:00
Pranav
ed2953aa3d
Merge pull request #218 from skrobinson/feat-bool-argparser
Allow check if ArgumentParser has parsed values
2022-10-11 17:46:05 -05:00
Pranav
f53d8690de
Merge pull request #216 from skrobinson/maint-cleaning
Maint cleaning
2022-10-11 17:44:45 -05:00
Pranav
caa3186556
Merge pull request #220 from skrobinson/fix-tidy-missing-header
Tell clang-tidy where to find argparse.hpp in PR action
2022-10-11 17:43:47 -05:00
Sean Robinson
3fce18503b Tell clang-tidy where to find argparse.hpp in PR action
Resolves the following error during stage one of clang-tidy-pr-comments:

  "error: 'argparse/argparse.hpp' file not found [clang-diagnostic-error]"

Closes #219

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-10-11 10:13:33 -07:00
Sean Robinson
f710bbdacf Add operator bool for ArgumentParser
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>
2022-10-10 15:26:42 -07:00
Sean Robinson
0c83c631c5 Update CMake version in README example for FetchContent
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>
2022-10-06 13:57:34 -07:00
Sean Robinson
7af2342d94 Remove link library from add_sample function
Resolves the following build error:

  CMake Error at CMakeLists.txt:26 (ADD_EXECUTABLE):
    Target "ARGPARSE_SAMPLE_custom_assignment_characters" links to target
    "argparse::argparse" but the target was not found.  Perhaps a
    find_package() call is missing for an IMPORTED target, or an
    ALIAS target is missing?

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-10-06 13:57:25 -07:00
Pranav
537f5e0d3c
Merge pull request #215 from skrobinson/feat-pr-tidy
Add clang-tidy analysis of pull requests
2022-10-06 11:48:44 -05:00
Sean Robinson
f1d75bbb32 Remove unneeded explicit Compare function from map declarations
std::less<Key> is the standard's default comparison function, we do not
need to re-declare the same function.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-10-06 09:18:47 -07:00
Sean Robinson
99057b09a1 Add clang-tidy analysis of pull requests
This action runs clang-tidy with results saved to a file which is then
parsed in stage two to post code comments.  This multistage process lets
us post PR comments on code from forks.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-10-05 15:22:44 -07:00
Pranav
e9ae471ea4
Merge pull request #209 from skrobinson/fix-issue-208
Fix issue 208
2022-09-23 12:57:02 -05:00
Pranav
168bc9d189
Merge pull request #210 from skrobinson/feat-add-sample-licenses
Add an explicit MIT license to each sample source file
2022-09-23 12:56:10 -05:00
Sean Robinson
74b95bc11a Add an explicit MIT license to each sample source file
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-09-23 08:10:06 -07:00
Sean Robinson
50e3afd81d Replace vector::operator[] use with vector::front
This is mostly a style change to match other parts of the code.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-09-23 08:05:33 -07:00
Sean Robinson
2a15178bb7 Include canonical argument name in nargs range validation error
The name of a positional argument is never used.

Closes #208

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-09-23 07:54:58 -07:00
Pranav Srinivas Kumar
997da92556 Bumped version to v2.9 2022-09-21 19:24:04 -07:00
Pranav
d6c3f3b704
Updated cmake command for building samples 2022-09-21 21:17:24 -05:00
Pranav
ce0b491571
Merge pull request #206 from p-ranav/feature/metavar_help_and_usage
METAVAR, Improved help, Samples (Based on #187)
2022-09-21 21:16:37 -05:00
Pranav Srinivas Kumar
b1c7483cf5 Added additional samples and fixed parse_known_args API 2022-09-21 19:08:06 -07:00
Pranav Srinivas Kumar
6f1e89885e Added nargs to help output, added test samples 2022-09-21 18:48:11 -07:00
Pranav Srinivas Kumar
05232b7487 Started adding samples 2022-09-21 18:09:25 -07:00