Commit Graph

643 Commits

Author SHA1 Message Date
Jonas Schulze
ae5de262d2 Add empty line above epilog 2022-07-25 16:43:58 +02:00
Pranav
f0e20fafdc
Merge pull request #183 from eidelen/eidelen-cmake-fetchcontent
Extend Readme with CMake FetchContent integration of argparse.
2022-07-10 09:59:03 -05:00
Adrian Schneider
17d567c283
Extend Readme with CMake FetchContent integration of argparse. 2022-07-09 17:04:02 +02:00
Pranav
4801fd0bdc
Merge pull request #182 from skrobinson/wip-post-2.6-cleanups
Post-2.6 cleanups
2022-07-07 10:19:13 -05:00
Sean Robinson
14097df904 Clean miscellaneous source styling
Clears warnings for the following checks in clang-tidy:
  readability-braces-around-statements
  readability-else-after-return checks

Also adds hints about code style to CONTRIBUTING document.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-07-06 10:03:56 -07:00
Sean Robinson
2460019e2e Update copyright date
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-06-22 14:02:00 -07:00
Pranav Srinivas Kumar
40a3888f15 Bumped version to v2.6 2022-06-22 10:59:52 -07:00
Pranav
24c599dfde
Merge pull request #125 from hokacci/feature/variable-length-nargs
Improve nargs
2022-06-22 10:57:38 -07:00
Yoshihiro Hokazono
ed84d90d89 Move NArgsRange to private: because it is detail of implementation 2022-06-22 09:30:36 +09:00
Yoshihiro Hokazono
25d24c731b SizeRange -> NArgsRange 2022-06-22 09:26:43 +09:00
Yoshihiro Hokazono
acff046fc5 Use optional instead of zero_or_one 2022-06-22 09:24:51 +09:00
Yoshihiro Hokazono
e44023f424 Explain variable-length arguments in README 2022-06-22 07:55:48 +09:00
Yoshihiro Hokazono
7b5084c454 Fix a typo 2022-06-22 07:16:41 +09:00
Yoshihiro Hokazono
df6e7de86a Prefer empty() to size() == 0 2022-06-22 07:15:50 +09:00
Yoshihiro Hokazono
5d6544a04e Retrieve changes on 37a1f3b9e6 2022-06-22 07:11:52 +09:00
Yoshihiro Hokazono
b869b5a209 NArgsPattern -> nargs_pattern (to snake case) 2022-06-22 07:07:59 +09:00
Yoshihiro Hokazono
08943f47ab Merge branch 'master' into feature/variable-length-nargs 2022-06-21 08:36:33 +09:00
Yoshihiro Hokazono
3459eec647 Make throw_* funcs and make validate() clearer 2022-06-21 07:14:09 +09:00
Yoshihiro Hokazono
12fcae66a7 Prefer pre-const to post-const 2022-06-21 06:48:13 +09:00
Yoshihiro Hokazono
0195a5065c Complete "remainig" backward compatibility 2022-06-21 06:45:26 +09:00
Yoshihiro Hokazono
6dfaa1c20c Restore a "remaining" test case for compat 2022-06-21 06:44:29 +09:00
Pranav
234f0cde82
Bumped version to v2.5 2022-05-27 07:30:25 -05:00
Pranav
571f8e3bff
Bumped version to v2.5 2022-05-27 07:29:42 -05:00
Pranav
162866eb4b
Bumped version to v2.5 2022-05-27 07:29:23 -05:00
Pranav
5d093dcdc5
Merge pull request #176 from peckato1/master
Add missing <utility> include
2022-05-19 21:17:32 +02:00
Tomáš Pecka
95d4850683 Add missing <utility> include
After upgrading g++ package to 12.1.0 on archlinux I see the following
compilation error:

  /usr/include/argparse/argparse.hpp: In member function ‘void argparse::ArgumentParser::index_argument(list_iterator)’:
  /usr/include/argparse/argparse.hpp:1167:34: error: ‘as_const’ is not a member of ‘std’; did you mean ‘is_const’?
   1167 |     for (const auto &name : std::as_const(it->m_names)) {
        |                                  ^~~~~~~~
        |                                  is_const

It turns out that std::as_const comes from <utility> header [1] which
was not explicitly included.

[1] https://en.cppreference.com/w/cpp/utility/as_const
2022-05-15 16:04:38 +02:00
Pranav
f5ea927f6b
Merge pull request #174 from ericonr/unused2
Fix remaining unused argument warnings.
2022-05-09 13:58:44 -05:00
Érico Nogueira
82eed31d3f Fix remaining unused argument warnings.
Commit 5c5c55b83c missed one such
occurrence.
2022-05-09 14:35:50 -03:00
Pranav
6ba201e210
Merge pull request #172 from skrobinson/fix-minor-cleanups
Fix minor cleanups
2022-04-27 15:12:36 -07:00
Sean Robinson
8b2357475f Add documentation for add_description and add_epilog
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-04-27 08:01:25 -07:00
Sean Robinson
c4faf29feb Replace cend with std::cend
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-04-27 08:00:51 -07:00
Sean Robinson
37a1f3b9e6 Remove unused code in Argument::validate
As far as I can tell, this statement is never true.

When m_values.size() < *expected, ::consume has already thrown "Too few
arguments..." before ::validate is called.

When m_values.size() > *expected, ArgumentParser::parse_args_internal
has already thrown "Maximum number of positional arguments exceeded"
before ::validate is called.

If ::remaining is used to avoid the last exception, this Argument will
always consume the expected number of values, hence this expression is
again false.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-04-27 08:00:17 -07:00
Pranav
b9dd1ef8e3
Merge pull request #162 from skrobinson/wip-port-aayush749-fixes
Port aayush749 fixes
2022-04-25 16:17:16 -07:00
Pranav
e0d656ec71
Merge pull request #171 from Dennis-Bbg/master
Update README.md
2022-04-21 22:51:07 -05:00
Dennis-Bbg
71a9a7a53e
Update README.md
Fixed the example in section" #### Deciding if the value was given by the user".
2022-04-21 11:52:12 +02:00
Pranav Srinivas Kumar
4af831ef72 Bumped library version to v2.4 2022-04-20 08:37:27 -05:00
Pranav
d2acb6aa44
Merge pull request #169 from AmeyaVS/fix/update_doctest
Updates doctest from v2.3.5 to v2.4.8
2022-04-19 14:03:07 -05:00
Pranav
a39f660502
Merge pull request #170 from ericonr/unused
Fix unused argument warnings.
2022-04-19 14:02:50 -05:00
Érico Nogueira
5c5c55b83c Fix unused argument warnings.
Solution suggested by skrobinson. This way, GCC and clang-tidy don't
generate warnings.

Fixes: https://github.com/p-ranav/argparse/issues/167
2022-04-19 13:59:08 -03:00
Ameya Vikram Singh
f56aec307f Updates doctest from v2.3.5 to v2.4.8
Fixes the build error on latest GNU/Linux Systems: (https://github.com/doctest/doctest/issues/473)

Signed-off-by: Ameya Vikram Singh <ameya.v.singh@gmail.com>
2022-04-16 20:35:37 +05:30
Pranav
2312342a62
Merge pull request #166 from ericonr/fix-version
Fix regression in version printing.
2022-04-14 10:48:31 -05:00
Érico Nogueira
3b89546fd0 Fix regression in version printing.
This regression was caused by commit
ea1f7ef663, which didn't add "\n" to the
version printing statement. We use std::endl now for compatibility
across platforms.
2022-04-13 10:29:37 -03:00
Pranav Srinivas Kumar
1a552dfd60 Bumped library version to v2.3 2022-04-01 19:05:46 -05:00
Pranav
7f11534e39
Merge pull request #163 from skrobinson/wip-disable-sa
Remove StaticAnalysis Action
2022-03-28 18:00:27 -05:00
Sean Robinson
eaa8214962 Remove StaticAnalysis Action
I am seeing too many errors due to bad tool configuration, not from
problems in project code.  So, disable SA until I can make it work more
reliably.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-28 13:03:05 -07:00
Sean Robinson
67d2e4476f Annotate range-for loops' structured bindings as [[maybe_unused]]
The 'unused' variable in both cases is most-definitely unused in the loop.
This is a cppcheck warning that appeared after moving these two loops to
range-for.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-24 14:21:14 -07:00
Sean Robinson
843e4eefb0 Move ArgumentParser::parse_args_validate logic into ::parse_args
This code was previously moved from ::parse_args to its own method, but
has since been simplified.  Moving the actual work to Argument::validate
in commit 603e87ae6 leaves a single loop that fits back into ::parse_args.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-24 14:19:20 -07:00
Sean Robinson
063d708c3e Modify ArgumentParser::get_length_of_longest_argument method run in O(1) space
Closes #124

Reported-by: Aayush Anand <aaayushanand5@gmail.com>
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-23 15:02:42 -07:00
Aayush Anand
0d868fdca8 Modify ArgumentParser::parse_args_validate() method to use a for loop instead of std::for_each()
Suggested-by: Aayush Anand <aaayushanand5@gmail.com>
[skrobinson: Updated for latest formatting and naming conventions]
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-23 15:02:42 -07:00
Pranav
cba0a1b3c7
Merge pull request #160 from skrobinson/wip-tidy
Enable clang-tidy readability-braces-around-statements check
2022-03-23 16:55:52 -05:00