Commit Graph

411 Commits

Author SHA1 Message Date
Pranav
f1ccf8e1ee
Merge pull request #77 from lichray/fix-ci
Avoid use of cmd.exe in Travis
2020-05-12 23:20:57 -05:00
Zhihao Yuan
15e4d44f11
Avoid use of cmd.exe in Travis 2020-05-12 22:42:57 -05:00
Pranav Srinivas Kumar
33101e7972 Closes #73 2020-05-08 14:35:05 -05:00
Pranav Srinivas Kumar
9bbd58c6ad Closes #76 2020-05-08 14:27:20 -05:00
Pranav Srinivas Kumar
3734fc6fca Closes #74 2020-04-23 07:36:22 -07:00
Pranav Srinivas Kumar
4c69ebf3fe Placing definitions in unnamed namespace to prevent multiple definition linker error #75 2020-04-12 09:38:21 -05:00
Pranav
45664c4e9f
Update README.md 2020-01-02 20:58:10 -06:00
Pranav
f01beb872e
Merge pull request #72 from CrustyAuklet/text-pre-post
Add the option to add text before and after help output
2020-01-02 20:55:39 -06:00
Ethan Slattery
c521ebeaf8 add extra space to match python formatting 2020-01-02 18:42:25 -08:00
Ethan Slattery
7ef0de410b Better naming: follow python naming convention. 2020-01-02 15:14:20 -08:00
Ethan Slattery
89b9e22f9a add pre and post text options
add variables, assignment functions, and printing for text before and after the argument lists.
2020-01-02 14:15:44 -08:00
Pranav
c13e83d0b3
Merge pull request #71 from lichray/simplify-misc
Simplify a few internals
2020-01-02 05:33:26 -06:00
Zhihao Yuan
7c57e1e852
Record used names with copies of string_view 2020-01-02 02:19:09 -06:00
Zhihao Yuan
03a0ce831d
Simplify Argument exposition-only constructors
Although they are public, they are not meant for end-users
to use, so we can change its interface to use less sfinae.
2020-01-02 02:19:08 -06:00
Pranav
e06890af97
Update README.md 2019-12-01 16:56:19 -06:00
Pranav
aed278419d
Merge pull request #68 from zhihaoy/std-optional
Get arguments in optional<T> with .present<T>()
2019-12-01 16:55:32 -06:00
Zhihao Yuan
e6c6c9b31c
Get arguments in optional<T> with .present<T>()
fixes: p-ranav/argparse#66
2019-12-01 02:14:13 -06:00
Pranav
4277e68e57
Merge pull request #65 from lichray/scan
Simplify parsing numeric arguments with .scan
2019-11-26 08:12:24 -06:00
Zhihao Yuan
e8a44d289d
Parse floating-point numbers in .scan
fixes: p-ranav/argparse#63
2019-11-26 00:11:21 -06:00
Zhihao Yuan
426a5dbb76
Parse integers in the .scan fluent interface 2019-11-25 23:45:55 -06:00
Zhihao Yuan
ea2f16d264
Upgrade and describe supported toolchains 2019-11-25 17:23:28 -06:00
Pranav
c851668339
Merge pull request #64 from lichray/negative
Determine negative numeric values with a grammar
2019-11-24 19:53:53 -06:00
Zhihao Yuan
964790cf3c
Determine negative numeric values with a grammar
Two differences that diverge from the existing behavior:

  1. Leading zeros are not allowed for integers.  Negative
     octal numbers such as `-066` are not meant to be treated
     as positional arguments, but existing code recognize them
     as decimal numbers.  Note that negative floating-point
     numbers with leading zeros (`-003.`) are unambiguous and
     are recognized.
  2. Inf and NaN are not recognized.  This is because options
     like `-inf` is indistinguishable from a compound argument
     that meant to be a shorthand for `-i -n -f`.

fixes: p-ranav/argparse#55
2019-11-24 00:31:05 -06:00
Pranav
473d550ea3
Merge pull request #61 from zhihaoy/exit-on-help
Default --help to print help and exit
2019-11-22 18:01:23 -06:00
Zhihao Yuan
77f3bd9b8d
Default --help to print help and exit
The change also fixes a rare bug introduced in 9007958:
when there are duplicated keys, insert_or_update overrides
previously inserted ones, emplace doesn't.

fixes: p-ranav/argparse#59
2019-11-22 16:54:58 -06:00
Pranav
4cc2c75dec
Merge pull request #60 from zhihaoy/fix-help
Fix print_help for printing nothing
2019-11-22 15:45:58 -06:00
Zhihao Yuan
36003197c7
Fix print_help for printing nothing 2019-11-22 15:33:15 -06:00
Pranav
9cac1d0fed
Update README.md 2019-11-22 08:02:44 -06:00
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