Nitin Kumar
a0f13a1528
fix: Fix short options parsing with equal sign ( #488 )
...
* feat: Add test for short options parsing
* fix: Update option parsing to allow = with short options
* fix: Fix custom option parsing in case of CXXOPTS_NO_REGEX
2026-02-02 17:37:12 +11:00
Nitin Kumar
89985f820e
feat: Switch to stable_partition to ensure that only first long options is printed in help ( #481 )
...
* feat: Add test for Ordering of multiple long options
* fix: Use stable_partition for deterministic ordering
2026-01-14 06:57:04 +11:00
Victor Proon
5e6d1e29f7
fix the issue with default empty vectors behaviour. update unit test ( #460 )
2025-07-18 07:09:03 +10:00
Nigel Stewart
7795b6a47b
C++17 std::filesystem::path support added ( #447 )
2025-01-14 17:56:41 +11:00
Nigel Stewart
f029892dab
C++17 std::optional test coverage fixups ( #446 )
2024-12-23 07:53:42 +11:00
levonwaveye
10a7a64779
Add ParseResult::contains method ( #440 )
2024-10-24 07:14:32 +11:00
權少
59656709c0
Fix example and test compiled warnings and error in MSVC. ( #428 )
...
* Fix example and test compiled warnings and error in MSVC.
2024-04-27 12:11:52 +10:00
Nigel Stewart
70fb4e4814
Extend cxxopts API to support as_optional in addition to as query of values ( #421 )
...
Co-authored-by: Nigel Stewart <nigel.stewart@emesent.io>
2024-02-29 20:27:19 +11:00
jarro2783
1e175bc1db
Fix ordering of parse_value functions ( #420 )
...
Fixes #419 . Put the definitions of parse_value functions before they
are called so that the right ones are chosen.
2024-02-20 19:38:44 +11:00
ololuki
e84ab5f67c
Fix overflow error in integer_parser. ( #417 )
...
Fixes #290 .
Checking for overflow should be done before integer overflows.
There are two checks:
(result > limit / base) is used for limits greater than rounded up to base,
e.g. for 65535 it will activate for 65540 and higher.
(result * base > limit - digit) is used for limit+1 to limit+n below
next base rounded number, e.g. 65536 up to 65539.
2024-02-01 16:51:32 +11:00
Jarryd Beck
7bf29108d5
Update catch2 to latest 2.x
2024-01-15 21:04:41 +11:00
Alexander Galanin
ddc695ebac
Don't split by list delimiter in positional lists ( #398 )
2023-06-15 07:34:26 +10:00
Jarryd Beck
4a3d4dbfe0
Fixes #362 .
...
Fix comparing iterators from a different container.
2023-02-01 06:56:03 +11:00
Jarryd Beck
32afbc6526
Fix default bool values
...
Fixes #382 . Keep boolean values when parsing into a reference.
2022-12-15 07:08:03 +11:00
Sourabh Mehta
1dcb44e79a
Fix an additional space in help generated ( #377 )
2022-11-10 07:24:19 +11:00
Ryan Leary
2e3c6991d3
add . as valid char in option names ( #358 )
2022-09-29 07:11:32 +10:00
jarro2783
a10bd5233b
Fix values attached to short options ( #360 )
...
Fixes #357 .
2022-08-13 07:51:41 +10:00
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
Eyal Rozenberg
628dc9202b
Fixes #345 , fixes #346 : Exception code tweaks ( #347 )
...
* Fixes #345 , fixes #346 , regards #340 : Put exceptions in a sub-namespace and renamed them accordingly.
* Also fixed some "loose ends" regarding namespace indentation which were missing in PR #350 .
* Dropped `required_option_missing` as it is unused.
2022-07-12 19:45:58 +10:00
Long Deng
c59e0c132c
Solve arguments() showing empty keys when only short-only option exists ( #318 )
...
* Solve `arguments()` showing empty keys when there is only a short option.
2022-05-11 17:44:25 +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
c74846a891
Fix short options adding into unmatched
...
Fixes #312 .
2021-10-21 08:06:53 +11:00
Jarryd Beck
c641241a87
Fixes to #204 .
2021-10-09 17:02:27 +11:00
Baojun Wang
4b7fccb5f2
Allow empty string to be valid positional arguments
...
Fixes #204 .
2021-10-09 17:02:27 +11:00
RonxBulld
97a4d5511f
Support options like `-j5`. ( #286 )
...
* Support option value being attached after the option without a space in between. e.g. -j5
2021-05-06 08:46:40 +10:00
Daniel Lemire
12e496da3d
Making sure that the library can compile without warnings even when crazy pedantic flags are set ( #238 )
...
Makes some fixes to satisfy various strict warnings.
2020-10-06 17:06:33 +11:00
jarro2783
3ef9fddc7b
Fix passing a const array to parse ( #258 )
...
Fixes #257 . The input array is not modified, so we can declare this as
`char const* const*`.
2020-10-03 20:54:06 +10:00
Jarryd Beck
fedf9d7b57
Refactor parser
...
Major refactor of the parsing code organisation to improve encapsulation
and not modify the input arguments. The returned result no longer has
pointers into the original option specification.
2020-10-01 17:12:03 +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
Eyal Rozenberg
5f43f4cbfe
Fixes #245 : Mention the option name when throwing on "no value" ( #246 )
...
* Fixes #245 :
* Added a new exception type: `option_has_no_value_exception`; throwing it when an option has no value we can cast with `as()`, instead of an `std::domain_error`.
* The `OptionValue` type now holds a pointer to the long option name (in its corresponding key within ParseResults's `m_results` field.
2020-07-23 17:27:04 +10:00
Jarryd Beck
23f56e2614
Fix conversion warning in test
2019-11-28 08:32:54 +11: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
Bartek
3c73d91c0b
add_options variant with initializer list ( #189 )
...
Allow adding options with a single initializer list.
2019-06-28 08:39:37 +10:00
Jean-Baptiste Bayle
6b6af4f561
Add a method to remove the implicit value of an option ( #178 )
2019-06-18 17:49:15 +10:00
Christian Lang
7b14d5f60b
Fix parsing of std::vector and add test, example and documentation ( #182 )
...
Improve parsing into std::vector so that a single argument can take a list.
2019-06-18 08:14:18 +10:00
Jarryd Beck
e17c6b0827
Fix integer parsing again
2019-06-14 18:20:22 +10:00
Jean-Baptiste Bayle
bd20573829
Parse 0 and 1 into booleans ( #177 )
...
* Parse 1 as "true" and 0 as "false" for boolean options.
2019-05-28 17:25:54 +10:00
Jarryd Beck
d58271c5fd
Allow invalid short option syntax
...
Fixes #171 . Allows invalid syntax for short options to be ignored.
2019-05-28 08:21:36 +10:00
Jarryd Beck
d31492e2cd
Catch exception using reference
2019-05-02 17:32:48 +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
Jean Guyomarc'h
51f9a94c91
Fix invalid exception type in catch ( #149 )
...
g++ 8.2.0 refuses to compile the test suite because of polymorphic types
that are caught by value. They shall be caught by reference instead.
2018-11-20 08:06:18 +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
7c468aaf68
Allow iterator inputs to parse_positional
2018-08-07 08:00:41 +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
Frank Schoenmann
ca6e9f70eb
Allow unrecognised options. ( #105 )
...
Allows unrecognised options to be left alone by the parser without throwing an exception.
2018-04-12 08:15:07 +10:00
Jarryd Beck
cc4914f065
Revert "Added const to argv type for better interoperability. ( #99 )"
...
This reverts commit 0f819a5cab .
2018-04-10 08:48:08 +10: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
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