Commit Graph

252 Commits

Author SHA1 Message Date
Alexey Ismagilov
33146122a2 NEW: suppress flag for subcommand
resolve #258
2023-11-05 15:23:15 +03:00
Pranav Srinivas Kumar
a9869150fd Changed from using std::set to std::vector for mutex_args elements 2023-11-04 15:51:22 -05:00
Pranav Srinivas Kumar
ecccae530c Using size_t for levenshtein distance 2023-11-04 15:48:13 -05:00
Pranav Srinivas Kumar
b43c0a7e83 Addressed clang-tidy issues 2023-11-04 15:46:41 -05:00
Pranav Srinivas Kumar
de4239483d Added logic and unit tests for the required flag in mutex_args 2023-11-04 15:36:01 -05:00
Pranav Srinivas Kumar
eea95c0e3a Added mutex args to copy constructor, changed to ordered set for data structure 2023-11-04 15:19:10 -05:00
Pranav Srinivas Kumar
39988ec62d Initial commit for implementing MutuallyExclusiveGroup 2023-11-04 14:57:01 -05:00
Pranav Srinivas Kumar
281f1ab017 Closes #113, add custom std::ostream& argument to ArgumentParser constructor 2023-11-04 09:31:13 -05:00
Pranav Srinivas Kumar
c6e64ae36d Simplified logic in error reporting, asking user if they meant to use a specific optional argument 2023-11-04 09:11:34 -05:00
Pranav Srinivas Kumar
62052fefcb Closes #285 2023-11-04 09:01:31 -05:00
Pranav Srinivas Kumar
7657a22001 Updated formatting of error message, showing all variations of argument name 2023-11-03 22:18:08 -05:00
Pranav Srinivas Kumar
78ba5e9828 Removed brackets and quotes in error message 2023-11-03 22:12:00 -05:00
Pranav Srinivas Kumar
4111905a74 Improved error reporting for #299 2023-11-03 22:05:46 -05:00
cobyj33
9e647254f8 More descriptive parse_number errors 2023-10-28 00:26:08 -05:00
Pranav Srinivas Kumar
716ec60291 Added flag() shorthand function 2023-10-27 16:37:20 -05:00
Pranav Srinivas Kumar
5e7ce61ca7 Closes #278 2023-10-27 12:59:04 -05:00
Pranav Srinivas Kumar
d28188f4d5 Closes #247 2023-10-27 12:34:57 -05:00
Pranav Srinivas Kumar
fd726fd341 Fixed clang tidy warning about struct name 2023-10-27 10:53:52 -05:00
Pranav Srinivas Kumar
6d49d5ee1b Limiting choices support to string type or integer type 2023-10-27 10:35:04 -05:00
Pranav Srinivas Kumar
0b8d0e2426 Added support for integer type in choices 2023-10-27 10:28:54 -05:00
Pranav Srinivas Kumar
9bb553b882 #277 Added in-built support for string_type choices 2023-10-27 09:16:25 -05:00
Christoph Hindermann
6c4bddb990 CMakefile: Use -Wpedantic, -Werror and -Wextra for compilation in gcc. Fixed warnings 2023-10-20 19:57:12 +02:00
Pranav
57b63b09fa
Merge pull request #290 from Arthapz/master
Add C++20 module
2023-10-20 08:06:14 -05:00
Kian-Meng Ang
aa25a2f3ac Fix typos
Found via `codespell -L seh`
2023-10-19 13:09:11 +08:00
Arthur LAURENT
23aff1938a
add argparse C++20 module 2023-10-15 17:13:56 +02:00
Arthur LAURENT
7a13042264
use inline constexpr instead of static constexpr for free constants 2023-10-15 17:08:22 +02:00
Pranav
b0930ab028
Merge pull request #268 from fanurs/align_multiline_message
Fix issue #248: Align multiline help messages
2023-07-11 08:15:12 -05:00
Fanurs
e82653c2d9 Fixed test for multiline help message alignment 2023-04-22 19:23:17 -04:00
Fanurs
5595375786 Changed padding from \t to spaces 2023-04-22 15:15:39 -04:00
Fanurs
aa996952bb Fixed clang-tidy issues
See https://github.com/p-ranav/argparse/pull/259#pullrequestreview-1284243420
2023-04-22 02:35:46 -04:00
Pranav
0b513829ac
Merge pull request #264 from skrobinson/feat-exit-choice
Add exit_on_default_arguments parameter to ArgumentParser
2023-03-29 11:54:15 -05:00
Sean Robinson
0ae3c7d919 Add exit_on_default_arguments parameter to ArgumentParser
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>
2023-03-22 09:07:45 -07:00
Nicholas Treffer
1c266d2791 Resolves the std::numeric_limits<std::size_t>::max)()} error
similar to this one https://github.com/microsoft/cppwinrt/issues/479
2023-03-17 14:16:08 +13:00
Pranav
e516556733
Merge pull request #254 from skrobinson/fix-maintenance
Various maintenance tasks
2023-02-19 10:29:59 -06:00
He Shiming
3d7596765b implements column-aligned multi-line help message for arguments (issue #248) 2023-01-30 19:28:07 +08: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
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
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
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
Aayush Anand
6eb0ea7738 added fix for issue #235 2022-11-12 20:24:36 +05:30
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
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
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
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
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
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
3b9df0b1e7 Added support for metavar and improved help/usage based on #187 2022-09-21 18:01:36 -07:00