Commit Graph

401 Commits

Author SHA1 Message Date
silvergasp
05ca8e1cac
Adding bazel build targets (#251)
Adding support for the bazel build system
2020-08-12 08:48:07 +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
Rosen Penev
07f5cb24f1
[clang-tidy] use nodiscard (#234)
Found with modernize-use-nodiscard

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-07-28 15:40:16 +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
Eyal Rozenberg
1b660d5680
Regards #244: Explain how vectors of values allow repeated use of the same option on the command-line. (#247) 2020-07-23 16:36:54 +10:00
Akos Kiss
9a454c8e4e
Improve help of short-only options (remove dangling comma) (#235) 2020-06-04 13:21:51 +10:00
Daniel Lemire
794c975287
Exit instead of abort (#233)
Uses std::exit instead of abort to terminate when exceptions are disabled.
2020-05-29 08:30:35 +10:00
Rosen Penev
12bc8d78e7
clang-tidy fixes (#231) 2020-05-12 14:59:47 +10:00
Tomas Barton
b0f67a06de
Code highlighting, add more examples (#220) 2020-02-14 08:02:27 +11:00
Jarryd Beck
6fa46a7488 Don't return parse result
Fixes #219. The example was wrong as ParseResult can't be returned out
of scope of the options parser.
2020-01-17 08:03:57 +11:00
Felix Esch
943cdcfbba Fix assertion failure (issue #217) (#218) 2020-01-08 17:14:46 +11:00
Jarryd Beck
23f56e2614 Fix conversion warning in test 2019-11-28 08:32:54 +11:00
Florin Iucha
9457b3de3a Fix -Wconversion warnings with GCC9 (#214) 2019-11-28 08:30:23 +11:00
Abhay Raj Singh
073dd3e645 Fixed empty default showing nothing in help (#205) 2019-10-14 18:08:11 +11: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
f4f4ece809 Improve README about supported compilers
Fixes #202.
2019-08-23 08:16:22 +10:00
Jarryd Beck
cb60381e84 Add to changelog 2019-08-08 08:27:14 +10:00
charlydelta
34784b01f7 Fix: Make CXXOPTS_NO_EXCEPTIONS compilable and print messages (#196)
Fix CXXOPTS_NO_EXCEPTIONS so that it doesn't warn about unused parameters, and print out error messages.
2019-08-08 08:25:34 +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
Anders
6e31c227e2 Add CMake option CXXOPTS_ENABLE_INSTALL (#195)
Install targets will not be generated if this option is set to OFF,
which is useful when including it as a bundled dependency of
another project.
2019-08-01 17:51:01 +10:00
Anders
531c00b96f Define alias target cxxopts::cxxopts (#194) 2019-08-01 17:50:05 +10:00
Jarryd Beck
0d4bb2871a Add to Changelog 2019-08-01 08:29:40 +10:00
charlydelta
37e7220fb4 Allow disabling exceptions and use std::abort instead (#190) 2019-08-01 08:19:59 +10:00
avemilia
c19e267790 CMake: search only for C++ compiler (#192)
This speeds up the CMake configuration step by not searching for a C
compiler. By default, CMake looks for C and C++ compilers, unless a set
of compilation languages is specified.
2019-07-31 18:15:58 +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
Jarryd Beck
e6858d3429 Add to changelog for #170 2019-06-18 18:17:24 +10:00
linus-sherrill
9910095719 Remove check for container when generating help message. (#170)
Some positional parameters would be listed in the help text and others
would not, when what is desired is that no positional parameters are
listed with the other command options. This change suppresses the help
listing for all positional parameters.
2019-06-18 18:16:31 +10:00
Jarryd Beck
9064fdf459 Add to changelog 2019-06-18 18:00:16 +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
Jarryd Beck
4f3fda4bf9 Add to changelog for #182 2019-06-18 08:17:26 +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
1eca210edc Remove unused variable 2019-06-14 18:28:04 +10:00
Jarryd Beck
e17c6b0827 Fix integer parsing again 2019-06-14 18:20:22 +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
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
cef280fad3 Remove some unreachable code.
Fixes #175. This was broken when throwing an exception on missing
positional parameters in #169.
2019-05-28 08:21:36 +10:00
Jack Clarke
e34676f73e fix sign conversion warnings (#174) 2019-05-13 08:33:15 +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
le-migou
48e265dc4b Remove u8 prefix in string literals. (#172)
String literals with the prefix `u8` now have the type `const char8_t[N]` in
C++20. As a consequence the library does not compile in c++2a mode with GCC
(you can't concatenate `std::basic_string<char>` and `const char8_t[]` as
`char` and `char8_t` are different types).
2019-04-15 18:26:43 +10:00
Jarryd Beck
3876c09072 Use reference instead of value
Fixes #166.
2019-02-19 18:14:36 +11:00
linus-sherrill
9990f73845 Remove empty string initializer. (#159)
The empty string caused the vector to have one element which caused
the test at line 2041 to always fail.
2019-01-14 08:46:41 +11:00
Jarryd Beck
3d405ef163 Improve boolean readme
Fixes #157. Fix the wording in the README about booleans.
2019-01-02 08:47:17 +11:00
Michael Tesch
0edf37b6cc accept single '-' as argument, such as in cat - (#153) 2018-12-20 07:58:37 +11:00
舒俊杰
5950d78558 fix min/max defined macros (#152)
Windows is broken and defines `min` and `max` as a macro, adding parentheses stops them from being expanded.
2018-12-20 07:57:22 +11:00
Jarryd Beck
287d1e39e0 Add to changelog for exception fix 2018-11-20 08:25:24 +11: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
c713b44d92 Use a shared pointer for the options map
Fixes #132. Since the map of options is shared between Options and
ParseResult, they should use a shared pointer instead of a reference so
that ParseResult can be returned without referencing destroyed memory.
2018-11-08 18:22:42 +11:00