Commit Graph

322 Commits

Author SHA1 Message Date
jarro2783
dd45a0801c
Rename BUILD to BUILD.bazel 2021-02-20 15:12:07 +11:00
Jarryd Beck
aaa5e790b6 Rename variable, add to example 2021-02-15 08:34:46 +11:00
Wolfgang Gahr
43ce03fdbd
Improve formatting of help descriptions (#215)
* Improve formatting of help descriptions (#213)

* new function: cxxopts::Option::set_width(size_t width)
  Set the size of a helpline.
* new function: cxxopts::Option::set_tab_expansion()
  Expand the tabs in descriptions.
  The tabsize 8 chars, base is start of description.
  The descriptions are not disturbed by adding additional options.
* Allow newlines \n and tabs \t in descriptions.

Other changes (last commit/new commit):
* 1453/1471: size_t for OPTION_LONGEST and OPTION_DESC_GAP.
  This prevents the static cast in 2086/2140.
* 2088/2142: in case of small width the value of
  "width - longest - OPTION_DEC_GAP" becomes negative.
  Because size_t is unsigned the result is a big number, and
  the width of the column of the descriptions is not shortened.
* new 2143: When the given width is too small, it is set to
  longest + OPTION_DESC_GAP + 10
* new 1570: A long description is broken into multiple lines, and
  the iterator lastSpace remembers the begin of the last word.
  But when the iterator current reaches the end of line, the whole
  string from iterator is printed, which in soome cases is too
  long. Thats why one blank is added to the description to trigger
  the handling of lastSpace.
  Accordingly in 1574/1627 the line is shortened by one char.

* repaired signed/unsigned issue

* changes for unicode
2021-02-12 08:17:55 +11:00
Jarryd Beck
f34d603863 Fix missing override 2021-02-08 09:44:26 +11:00
Jarryd Beck
d10a9b5678 Upgrade GCC versions 2021-02-08 08:41:20 +11:00
Jarryd Beck
e862445ef3 Fix null dereference warning error
Fixes #276. Remove the fix for null dereference warning for GCC after
10.1.0 because this was removed in later versions.
2021-01-23 14:08:56 +11:00
Rosen Penev
ed85f04a1b
clang-tidy stuff (#266)
Several clang-tidy improvements.
2021-01-19 17:05:09 +11:00
Benjamin Sergeant
834fb9999b
Ignore gcc-10 warning (#273)
Workaround for GCC 10 null dereference warning.
2021-01-19 17:00:45 +11:00
jpr89
dc9a7728c0
Fixing cmake developer warning (#274)
Here is the warning currently being produced:

CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.19/Modules/GNUInstallDirs.cmake:223 (message):
Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
target architecture is known. Please enable at least one language before
including GNUInstallDirs.
Call Stack (most recent call first):

I noted how I fixed the error. This is caused by GNUInstallDirs automatically executing code just by including it.

I also added -Werror=dev to the CI to ensure this never happens again.

Co-authored-by: Juan Ramos <juanr0911@gmail.com>
2021-01-19 16:55:23 +11:00
jpr89
c55726ee29
Cmake Revamp (#270)
* Cmake Revamp

I needed to do a variety of things to ensure cxxopts worked well in my own project.

I created a new cmake module to abstract a lot of the logic in the main CMakelists.txt, I think it really assists in the readability of the project. Consequently a lot of logic is now written in functions.

I made a lot of the project options off by default unless the project is being built standalone. As a frequent consumer of cmake libraries this is a huge issue. Since examples, tests, installation, etc. aren't things I expect/desired by default when using libraries.

Co-authored-by: Juan Ramos <juanr0911@gmail.com>
2021-01-17 12:11:02 +11:00
Dan Ibanez
2d8e17c4f8
Add CMake option to not add warning flags (#267)
Allow extra compiler warnings to be disabled.
2020-12-15 08:47:52 +11:00
fiesh
66b52e6cc9
Add -Wsuggest-override (#264)
We also add the suggested `override` keyword.
2020-10-21 10:24:41 +11: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
4b63c333a8 Improve README note 2020-10-01 20:09:16 +10:00
Jarryd Beck
748ac35277 small cleanup 2020-10-01 17:26:32 +10:00
Jarryd Beck
703eeef906 Update version for 3 2020-10-01 17:14:39 +10:00
Jarryd Beck
31b77f11af Prepare notes for v3 2020-10-01 17:14:39 +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
Daniel Gomez Antonio
fd5cdfd547
Fix compiler warning C4702 for MSVC-14 (#225)
* Fix compiler warning C4702  for MSVC-14
2020-09-15 10:07:53 +10:00
Vitaly Zaitsev
584e0c3dd3
Fixed installation on other than Ubuntu GNU/Linux distributions. (#226)
Fixes the installation paths by using cmake variables.
2020-08-19 09:16:11 +10:00
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