Commit Graph

36 Commits

Author SHA1 Message Date
Eyal Rozenberg
e976f964c3
Fix issue #240: Multiple long option names / aliases (#349)
* Fixes #240: Multiple long option names / aliases

* We now use a vector of long option names instead of a single name
* When specifying an option, you can provide multiple names separated by commas, at most one of which may have a length of 1 (not necessarily the first specified name). The length-1 name is the single-hyphen switch (the "short name").
* Hashing uses the first long name
* Option help currently only uses the first long name.
2022-07-14 16:42:18 +10:00
Jarryd Beck
43ebb49475 Add changelog entry 2022-07-13 07:22:01 +10:00
Jarryd Beck
548d6196f5 Add clang format to changelog 2022-07-11 20:46:01 +10:00
Jarryd Beck
5f72b525c2 Add changelog note 2022-05-11 17:47:37 +10:00
Jarryd Beck
4e208b95b7 Add a program function
Fixes 323. Adds a function to retrieve the program name.
2022-01-14 16:26:48 +11:00
Jarryd Beck
e8b5befff8 Add changes for 3.0 release 2021-10-21 07:47:55 +11:00
Jarryd Beck
31b77f11af Prepare notes for v3 2020-10-01 17:14:39 +10:00
Kjetil Andresen
15e8a74e95
Support 'const char**' arguments in Options::parse (#250)
`cxxopts` doesn't modify the contents of the argv strings. This changes
the parse function to take a reference to a `const char**`.
2020-08-11 08:01:29 +10:00
Jarryd Beck
4a0af0e950 Fix parsing char type
Fixes #201. Parse char type correctly and check for length.
2019-08-23 08:26:16 +10:00
Jarryd Beck
cb60381e84 Add to changelog 2019-08-08 08:27:14 +10:00
Jarryd Beck
fce82fb035 Fix duplicate default option
Fixes #197. Don't parse default options twice when there is a short and
long option.
2019-08-08 08:21:52 +10:00
Jarryd Beck
0d4bb2871a Add to Changelog 2019-08-01 08:29:40 +10:00
Jarryd Beck
e6858d3429 Add to changelog for #170 2019-06-18 18:17:24 +10:00
Jarryd Beck
9064fdf459 Add to changelog 2019-06-18 18:00:16 +10:00
Jarryd Beck
4f3fda4bf9 Add to changelog for #182 2019-06-18 08:17:26 +10:00
Jarryd Beck
3e5ecf1d2a Fix a couple of out of range errors
These were detected using -fsanitize=undefined parsing values equal to
INT_MAX and INT_MIN.
2019-06-14 08:12:29 +10:00
Jarryd Beck
5da5d67111 Throw exception on invalid positional argument
Fixes #169. It seems reasonable to throw an exception when an attempt is
made to parse into positional parameters that don't exist.
2019-05-01 18:34:29 +10:00
Jarryd Beck
287d1e39e0 Add to changelog for exception fix 2018-11-20 08:25:24 +11:00
Jarryd Beck
84feb4bd87 Throw in ParseResult::as when option isn't present
Fixes #124.
2018-11-19 17:45:51 +11:00
Jarryd Beck
b528324107 Fix option matching 2018-11-08 08:18:54 +11:00
Jarryd Beck
cd65c459ec Build the tests by default.
Fixes #143. There is no reason to make the tests optional.
2018-11-07 18:52:40 +11:00
Jarryd Beck
7c468aaf68 Allow iterator inputs to parse_positional 2018-08-07 08:00:41 +10:00
Jarryd Beck
95a48de820 Remove unused get_option
Fixes #121. Removes the unused `ParseResult::get_option`.
2018-08-03 08:46:48 +10:00
Jarryd Beck
cde83be99b Fix version numbering in CMakeLists.txt
Fixes #115. Read the version number out of `cxxopts.hpp` instead of
having to duplicate it in CMakeLists.txt.
2018-07-05 17:55:51 +10:00
Jarryd Beck
e725ea3084 Use unsigned type for integer digit
Fixes #109. Although we always used numbers in the ASCII range, it was
in a `size_t`, leading to a warning about possible loss of data on some
compilers.
2018-05-08 07:59:17 +10:00
Jarryd Beck
d47101a101 Allow leading zeroes in integers
Fixes #101. Allows leading zeroes in the integer parser.
2018-05-07 18:46:26 +10:00
Jarryd Beck
a3ccf3e1f7 Add revert to changelog 2018-04-10 08:50:17 +10:00
Jarryd Beck
0fe1dc892b Prepare changelog for release 2018-04-09 08:17:56 +10: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
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
70b9230639 fix changelog and readme
add booleans into the changelog and the readme
2017-11-15 17:56:25 +11:00
Jarryd Beck
4ebfa25915 Improve version and changelog 2017-11-13 17:57:26 +11:00
Jarryd Beck
b1f0cb806c fix default 2017-10-27 12:31:18 +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