Commit Graph

383 Commits

Author SHA1 Message Date
Jarryd Beck
16e3968e1a update readme 2018-03-21 18:14:09 +11:00
Jesús González
0f819a5cab Added const to argv type for better interoperability. (#99)
* Added const to argv type for better interoperability.
2018-03-09 08:07:29 +11:00
Jarryd Beck
e40645e084 Don't show default when boolean false
Fixes #102. Don't show the default value when it is a boolean and the
value is false. Note that this is a bit of a hack and the
implementation should probably be reevaluated in the future.
2018-03-08 08:53:26 +11:00
Jarryd Beck
76bd60dc17 Add support for std::optional
Fixes #93. This adds C++17 only support for `std::optional` values for
command line parameters.
2018-01-31 18:25:52 +11:00
Jarryd Beck
e792760ab9 Changes default values so that they aren't counted
Fixes #96. Default values of options not specified on the command line
had a `count` of 1. It would be better if they had a count of 0 because
they were not actually specified, so that count is only for options
given by the user.
2018-01-30 18:55:49 +11:00
Jesús González
76717cb3dd Add default "default" value to boolean options (#94)
* Add default "default" value of "false" to boolean options, therefore allowing to call result["boolOpt"].as<bool>() without throwing an exception.
2018-01-17 07:55:45 +11:00
Jarryd Beck
24162899c9 fix some types 2017-12-15 17:43:31 +11:00
Addy
ec7db35ac6 fixed “possible loss of data” warning on Visual Studio (#89) 2017-12-15 08:02:02 +11:00
Jarryd Beck
c69ca9166d version bump 2017-12-06 18:28:32 +11:00
Jarryd Beck
9c2e41a4e2 add clang back to travis 2017-12-04 18:14:40 +11:00
Masashi Fujita
ec9e62c2c8 | should be inside of (…) (#87)
* `|` should be inside of `(…)`

It's possible to use `(t|true|T|True)` as `truthy_pattern` but still failing `true` as a truthy under my environment :-(

```
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```
2017-12-04 18:15:20 +11:00
Jarryd Beck
fab3bae2ff Clarify ParseResult being in scope 2017-12-01 07:58:15 +11:00
Jarryd Beck
346956eff1 Fix overly strict shadows in GCC 4.9
Fixes #86. Rename some variables so that the overly strict shadows warning
on GCC 4.9 is not triggered.
2017-11-30 08:45:00 +11:00
Jarryd Beck
2015a7438a Add GCC 4.9 to travis build 2017-11-30 08:39:58 +11:00
Jarryd Beck
5b774d7a7e Allow help string to be customised
Fixes #82. This allows the help string after the program name to be
completely replaced by the user.
2017-11-28 18:07:23 +11:00
Jarryd Beck
2ca68adeaf Fix positional arguments overload
Fixes #83.

Adds an overload for positional arguments taking a
`std::initializer_list`. When using an `initializer_list` with one
argument, the function call is ambiguous matching both `std::string`
and `std::vector<std::string>`.
2017-11-28 18:01:41 +11:00
Jarryd Beck
abe9ebd6b4 Fix handling of implicit values
Fixes #84. Implicit values are not handled very well. For example:

    --foo false true
    --foo --bar

In the first, `false` is an argument to `--foo`, and then `true` is a
positional argument. In the second, because of the hyphen in `--bar`, `--foo`
is parsed with its implicit value. This seems inconsistent and unintuitive.

Better is that implicit values *never* consume the next parameter to be
completely consistent. This means that values with an implicit parameter
*must* be specified using the `--option=value` form.
2017-11-28 08:43:55 +11:00
Jarryd Beck
0a49b82072 add a test for broken boolean options
The parsing for boolean options was broken by 6c9bae4a07 which added implicit
and default values, and the ability to parse boolean strings. Having an option
after the boolean tried to parse that into the boolean instead of as a
positional parameter.

See #84 for the bug report.
2017-11-27 08:36:34 +11:00
Jarryd Beck
92779bef66 Remove clang for now
It appears that the `libc++` available on Ubuntu 14.04 is broken and
doesn't handle the boolean regex correctly. Newer versions appear to be
correct but I have to work out how to get 14.04 to use it.
2017-11-27 08:33:46 +11:00
Jarryd Beck
8893afe13c Merge branch '2_0' 2017-11-15 18:04:20 +11:00
Jarryd Beck
70b9230639 fix changelog and readme
add booleans into the changelog and the readme
2017-11-15 17:56:25 +11:00
Jarryd Beck
6c9bae4a07 Parse strings for booleans
Fixes #54. Allow default and implicit values for booleans with multiple
boolean strings matched as values.
2017-11-15 17:51:38 +11:00
Jarryd Beck
8d6a91ee27 improve documentation for default and implicit 2017-11-14 08:03:46 +11:00
Jarryd Beck
24450d183a Allow positional arguments to show in help
Fixes #72. This adds an option for positional arguments to be
shown in the help output.
2017-11-13 18:47:12 +11:00
Jarryd Beck
4ebfa25915 Improve version and changelog 2017-11-13 17:57:26 +11:00
Jarryd Beck
d74a2c65a5 Add ability to iterate through parsed options
Fixes #74.
2017-11-13 08:10:22 +11:00
Jarryd Beck
f0406578bd clean up extraneous comment 2017-11-02 08:34:49 +11:00
DevCodeOne
d7b930846c Fix some strange issues in integer_parser (#80)
* Prevent malformed numbers from being parsed as correct numbers.

Fixes #78. If you passed a string for example "test" it would get parsed to 1400.
The problem was that the parser did not throw an exception when an incorrect char was encountered.
Also a number without 0x in front with hexadecimal digits in it got parsed.
The number was treated as a hexadecimal number but it was still calculated with base 10.
So now before the current char is used, it is checked if it is valid in the current base.
Furthermore the number 0x0 was not a valid number, it now is a special case in the `integer_pattern`.

* Fixed `integer_pattern` so it works correctly under clang. Added testcase for invalid integers and for 0x0 being a valid number.
2017-11-02 08:14:21 +11:00
Alcaro
8ce9a587fa __GNU__ isn't a thing (#79)
Fixes a typo that never unsilenced the non virtual destructor warning.
2017-11-01 08:07:28 +11:00
Jarryd Beck
c2e19fc210 add a version define
Fixes #77.
2017-10-31 18:23:15 +11:00
Jarryd Beck
3c6bcb9046 Some cleanup 2017-10-31 18:21:18 +11:00
Jarryd Beck
3f5bbb3062 update the readme 2017-10-31 18:19:15 +11:00
Jarryd Beck
ef1dfdee33 remove some unused code 2017-10-30 08:46:45 +11:00
Jarryd Beck
7c32b9c5fc add option name to OptionDetails 2017-10-30 08:45:36 +11:00
Jarryd Beck
b1f0cb806c fix default 2017-10-27 12:31:18 +11:00
Jarryd Beck
65beaeb2e9 test that fails 2017-10-27 08:47:08 +11:00
Jarryd Beck
acbce8e363 all tests pass 2017-10-27 08:38:29 +11:00
Jarryd Beck
3fed557cf2 much closer to working 2017-10-27 07:58:57 +11:00
Jarryd Beck
e31c9af607 add clone to options
This is broken at the moment; it needs a complete rewrite.

The problem is that multiple options point to the same `OptionDetails`.
I really need to separate parsing results from describing options.
2017-10-20 08:29:55 +11:00
Jarryd Beck
1d6d1c97f0 clean up standard_value class a bit
This removes the `final` on the class, and the `virtual` keyword on the
functions that made `final` necessary. They shouldn't have been
virtual in the first place since nothing derives from it.

This hopefully doesn't reintroduce the non-virtual-destructor warning.
2017-10-19 18:36:42 +11:00
Jarryd Beck
38b4b1bee4 improve changelog 2017-10-18 18:42:49 +11:00
Jarryd Beck
8010e06952 Move parse result to an immutable object
This is far from ideal, but it's the first step in moving the parse
result to an immutable object so that the parser can be reused.
2017-10-18 18:37:58 +11:00
Jarryd Beck
d8458a8c1a remove non virtual destructor silence for GCC
This was fixed in 37fab4ee7a.
2017-10-18 08:07:10 +11:00
Jarryd Beck
33c4d509f1 fix Unicode multiple definition 2017-10-18 08:07:10 +11:00
Jarryd Beck
70ceea57e3 Cleanup uses of inline 2017-10-18 08:07:10 +11:00
Benjamin Buch
37fab4ee7a avoid warning about non-virtual destructor (#75)
´Value´ and ´standard_value´ don't have a virtual destructor. When I understand the code right, this is intended, because they are used through ´shared_ptr´ and so its not required. Nevertheless, clang does warn about it, since at the point of the destructor call it can not check if the object has a final type. Adding the C++11 keyword ´final´ to ´standard_value´ avoids this warning.
2017-10-10 11:58:40 +11:00
Jarryd Beck
0b7686949d Fix compiler warnings for MSVC
Fixes #62. This fixes compiler warnings that are raised by MSVC.

In one case the code that was warned about was never executed, but
this compiles it out in that case to silence the warning.
2017-09-04 17:55:52 +10:00
Jarryd Beck
1e51db16b5 Minor tweaks 2017-08-29 18:20:28 +10:00
giumas
52e2f8b140 Remove curly single-quotes only on Windows (#68)
This uses normal single quotes when on a Windows platform.
2017-08-29 18:16:28 +10:00
Jarryd Beck
c2c2262626 remove osx for now 2017-08-18 08:35:44 +10:00