Commit Graph

681 Commits

Author SHA1 Message Date
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
Pranav
c20621489d
Merge pull request #157 from Sam4uk/cmake_edit
edit CMakeLists.txt
2022-02-23 21:21:45 +05:30
Sean Robinson
ce3c43eb9b Rename identifiers
There are no functional changes in this commit.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-10 09:41:20 -07:00
Sean Robinson
985ea8666d Update identifier names for structs
The new naming pattern is CamelCase for structs, except parse_number as a
primarily callable interface.  Trait structs are named Has*Traits
and constexpr variables to the struct template are named Is*.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
c50346c1df Remove is_representable_v trait
This trait is unused and removing it does not cause any tests to fail.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
cb2777db6e Update header source format with clang-format
Most changes are to better fit within "ColumnLimit: 80".

The change from "T &&... var" to "T &&...var" is caused by
"PointerAlignment: Right".

Member functions chained from add_argument() use ContinuationIndentWidth,
which is set to 4.  Setting ContinuationIndentWidth to 2 causes many
other continuation lines to change.  So, this commit uses the original
value (i.e. 4) as the preferred size.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
486bfdaf8d Update clang-format configuration standard to C++17
The "Cpp11" alias is deprecated for Latest (a rolling standard).  For now,
stick to C++17.

Includes end-of-line whitespace removal.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
a915728da0 Enable clang-tidy cppcoreguidelines-avoid-c-arrays check
Also converts most C-style arrays to a std::array onjects.  The check is
disabled for ArgumentParser::parse_args(int, const char *const[]) as this
is a helper function to convert away from a common input format.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
6564839971 Enable clang-tidy readability-function-cognitive-complexity check
The two functions previously flagged by this check,
Argument::is_decimal_literal and Argument::validate, fell below the
default Cognitive Complexity threshold as a result of the branch
simplification for the readability-else-after-return check.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
d0a492ccba Enable clang-tidy readability-else-after-return check
A common pattern in the previous code was goto/return/throw if a condition
is true, else goto/return/throw something different.  The new pattern
uses the fact that the second goto/return/throw is only reachable when the
first goto/return/throw is not called.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
3c317ddd2d Enable clang-tidy clang-analyzer default checks
Surprisingly, no fixes are required in argparse when turning on this suite
of checks.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
0b74da54d4 Enable clang-tidy cppcoreguidelines-special-member-functions check
Also adds a default destructor, as recommended by the check.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
c25a959597 Enable clang-tidy readability-static-accessed-through-instance check
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00