Commit Graph

75 Commits

Author SHA1 Message Date
Zhihao Yuan
1af8b826c8
Annotate test cases with doctest::test_suite
This change also explicitly lists the source files
for CMake.  This is because `GLOB` does not remove
old files when switching branches in Git, and
`CONFIGURE_DEPENDS` will add unstaged files after
stashing.

See also: https://cmake.org/cmake/help/latest/command/file.html#glob
2019-11-21 14:24:50 -06:00
Pranav Srinivas Kumar
d5f48fa204 Minor test cases 2019-11-21 10:28:34 -06:00
Pranav Srinivas Kumar
c707bcc1c4 Closes #56 2019-11-21 10:25:41 -06:00
Pranav Srinivas Kumar
f9ab33d1a6 Closes #53 2019-11-21 09:08:49 -06:00
Zhihao Yuan
991df83d97
Support capturing remaining() arguments
This kind of argument works as if having the "remaining" nargs,
inspired by Python's `argparse.REMAINDER`.

This change also reduces the size of `Argument` by 8 bytes.

See also: https://docs.python.org/2/library/argparse.html#nargs

fixes: p-ranav/argparse#17
2019-11-20 17:47:20 -06:00
Zhihao Yuan
8201a18568
Fix various issues in Argument constructor
Before this change:

1. When the input is built-in string literal or cv-`char*`,
   `is_optional` constructs temporary `std::string` while
   `mNames` initializer is also constructing `std::string`
   due to the use of `std::initializer_list`.
2. When the input is `std::string_view`, doesn't compile.
3. When the input is `std::string`, `mNames` initializer
   moves `args`.  If argument name is longer than
   `std::string`'s SSO buffer, bad thing will happen because
   `is_optional` will be accessing `args` in moved-from
   states.

Because of the use of `strtol` which expects nul-terminated
input, `is_*` series functions must take `std::string`.  This
restriction may be removed after AppleClang adds `<charconv>`.
But for now, it complicates the patch.  My solution is to
create an array prvalue still, but use a array reference
rather than `std::initializer_list` to refer to it, so that
the code in delegated constructor can keep using fold
expressions after the necessary `std::string` objects being
created.
2019-11-17 01:51:36 -06:00
Zhihao Yuan
f84f17d719
Give ArgumentParser value semantics
fixes: p-ranav/argparse#50
2019-11-16 15:15:54 -06:00
Zhihao Yuan
3f949fc3f1
Stop sharing argument values with parent parsers
See also: p-ranav/argparse#50
2019-11-16 14:33:00 -06:00
Zhihao Yuan
f6e686b69c
Bind extra arguments to actions
closes: p-ranav/argparse#38
2019-11-14 01:30:04 -06:00
Zhihao Yuan
dc227448f6
Allow actions that return void
closes: p-ranav/argparse#39
2019-11-13 12:54:07 -06:00
Pranav Srinivas Kumar
883d6c75d5
Merge branch 'master' into help-stream 2019-11-13 08:32:19 -06:00
Pranav Srinivas Kumar
c4256afd4b Added test case for issue #37 2019-11-13 08:25:07 -06:00
Pranav Srinivas Kumar
39618d25a1 Added .clang-format. Closes #43 2019-11-13 08:24:51 -06:00
Zhihao Yuan
9d66976421
Print ArgumentParser help with stream insertion 2019-11-13 02:17:28 -06:00
Mio
3c7fcad146 Fix typo 2019-08-07 19:58:32 +08:00
Mio
466e3aa37c Include new tests 2019-08-07 19:58:25 +08:00
Mio
34165a8ed7 Add corresponding tests for required arguments 2019-08-07 19:53:35 +08:00
Pranav Srinivas Kumar
af1af7d5b7 Unit tests to parse floating point numbers in E-notation. Issue #24 2019-06-06 21:37:36 -04:00
Pranav Srinivas Kumar
73f6aa7538 Fixes Issue #24 2019-06-06 21:24:32 -04:00
Stephan van Veen
9e7b80034e Throw exception in case of unknown argument 2019-05-20 22:21:57 +02:00
Stephan van Veen
36bdfe4a55 Change test cases 2019-05-20 22:21:57 +02:00
Stephan van Veen
94ca8e2552 Unify container operations 2019-05-12 17:17:21 +02:00
Pranav Srinivas Kumar
3ea4c79137 Fixes core dump on optional arg (issue #10) 2019-05-04 11:49:30 -04:00
Pranav Srinivas Kumar
4b59010bd3
Update README.md 2019-04-01 22:03:59 -04:00
Pranav Srinivas Kumar
bb4a2dbba7 Renamed directories 2019-04-01 22:01:40 -04:00