Commit Graph

283 Commits

Author SHA1 Message Date
Pranav
423c0a225c
Merge pull request #58 from zhihaoy/test-suites
Annotate test cases with doctest::test_suite
2019-11-21 14:41:18 -06:00
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
7e70c43051 Merge branch 'master' of github.com:p-ranav/argparse 2019-11-21 10:25:50 -06:00
Pranav Srinivas Kumar
c707bcc1c4 Closes #56 2019-11-21 10:25:41 -06:00
Pranav Srinivas Kumar
da58b28ccb
Update README.md 2019-11-21 10:00:43 -06:00
Pranav Srinivas Kumar
f9ab33d1a6 Closes #53 2019-11-21 09:08:49 -06:00
Pranav Srinivas Kumar
c95835acf8
Update README.md 2019-11-21 08:37:47 -06:00
Pranav Srinivas Kumar
b42c6b7c7e
Update README.md 2019-11-21 08:37:04 -06:00
Pranav Srinivas Kumar
c803c32804
Update README.md 2019-11-21 08:29:34 -06:00
Pranav Srinivas Kumar
0cabe9569a
Merge pull request #57 from zhihaoy/remaining
Support capturing remaining() arguments
2019-11-21 07:57:12 -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
Pranav Srinivas Kumar
6ee8de5f4e
Merge pull request #54 from lichray/less-sfinae
Finishing cleanup by refactoring SFINAE into constexpr-if
2019-11-17 22:17:13 -06:00
Zhihao Yuan
f7dae0d93d
Refactor some uses of SFINAE into constexpr-if 2019-11-17 20:17:27 -06:00
Zhihao Yuan
93ddf85a7b
Factor out any_cast_container 2019-11-17 20:05:25 -06:00
Zhihao Yuan
3177f544f5
Default value is not a container of std::any 2019-11-17 19:11:09 -06:00
Zhihao Yuan
4c5ded8c84
Constrain Argument constructor better
Without this change, std::allocator can construct Argument
2019-11-17 18:55:52 -06:00
Zhihao Yuan
556d935491
Suppress MSVC warnings and a Codacy warning 2019-11-17 13:42:28 -06:00
Pranav Srinivas Kumar
d3127eb737
Merge pull request #52 from lichray/cleanup
Cleanup & allow creating and accessing arguments with string_view
2019-11-17 07:10:07 -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
7dd6655a9e
Avoid extra copy made by initializer_list 2019-11-17 01:51:36 -06:00
Zhihao Yuan
56c041707a
Use string_view in getter interface 2019-11-17 01:51:31 -06:00
Zhihao Yuan
f7fe9cf439
Remove unused space in Argument structure 2019-11-16 21:51:01 -06:00
Zhihao Yuan
daeca099e2
Remove undesired access control 2019-11-16 21:45:18 -06:00
Zhihao Yuan
955e1e1e6c
Simplify code with four-legged std::equal 2019-11-16 21:26:49 -06:00
Zhihao Yuan
50c91a0bcc
Clang-format the code 2019-11-16 21:17:53 -06:00
Pranav Srinivas Kumar
439b2d0941
Merge pull request #51 from lichray/value-semantics
Value semantics
2019-11-16 15:35:54 -06:00
Zhihao Yuan
f84f17d719
Give ArgumentParser value semantics
fixes: p-ranav/argparse#50
2019-11-16 15:15:54 -06:00
Zhihao Yuan
9007958c1f
Index arguments without storing their names twice 2019-11-16 14:35:35 -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
2208ec5b2d
Remove unused copy of parent parsers 2019-11-16 01:51:47 -06:00
Pranav Srinivas Kumar
5d1e80a7d0
Merge pull request #48 from lichray/bind-in-action
Bind in action
2019-11-14 06:55:57 -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
35ca16338b
Fix configuration for clang-format 8.0
See also https://reviews.llvm.org/D42098
2019-11-13 22:51:02 -06:00
Pranav Srinivas Kumar
77692fda8d
Merge pull request #46 from zhihaoy/void-action
Allow actions that return void
2019-11-13 14:26:42 -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
bda0866320
Merge pull request #44 from lichray/help-stream
Help stream
2019-11-13 08:36:58 -06:00
Pranav Srinivas Kumar
f889195b95
Merge pull request #45 from lichray/no-macro
Remove the undocumented PARSE_ARGS macro
2019-11-13 08:35:03 -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
c6cc306ec8
Remove the undocumented PARSE_ARGS macro
closes: p-ranav/argparse#41
2019-11-13 03:00:42 -06:00
Zhihao Yuan
dc74051832
Deprecate print_help()
closes: p-ranav/argparse#40
2019-11-13 02:40:15 -06:00
Zhihao Yuan
9d66976421
Print ArgumentParser help with stream insertion 2019-11-13 02:17:28 -06:00
Pranav Srinivas Kumar
79eba4e81f
Update README.md 2019-09-13 19:47:44 -05:00
Pranav Srinivas Kumar
61e9b644c0
Update README.md 2019-09-10 10:15:15 -05:00
Pranav Srinivas Kumar
acfa32e5c1
Merge pull request #36 from MU001999/update-namespace
Add a name for the anonymous namespace
2019-09-01 08:42:12 -05:00
mu001999
dd528a1d70 Add name for anonymous namespace 2019-09-01 21:16:59 +08:00
Pranav Srinivas Kumar
db9f81e19a
Update README.md 2019-08-27 10:28:40 -05:00
Pranav Srinivas Kumar
a9bc1c9a4a Closes #28 2019-08-17 17:56:29 -05:00