Commit Graph

413 Commits

Author SHA1 Message Date
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
Hannah Rittich
2aed1ce41b Added parsing of general types. (#63)
Adds generic parsing of types using `operator>>`, in particular allows
parsing of floats and doubles.
2017-08-16 17:55:06 +10:00
Jarryd Beck
da9210d41e fix multiple definitions
Fixes #61. Commit 5e9f822598 introduced
duplicate definitions across separate translation units.
2017-08-08 08:12:31 +10:00
Jarryd Beck
5e9f822598 Improve integer parsing
Fixes #39. Closes #40. This is an overhaul of the way that integer
arguments are parsed. Instead of using std::istream, which allows,
for example, negative integers for unsigned types, we use our own
parser.

This allows us to do proper range checking depending on the type,
and to correctly check for negative values passed to unsigned types.

This also allows the handling of base 16 numbers.
2017-07-25 08:12:29 +10:00
Shivakar Vulli
f931fd4279 Allow spaces in option specification. (#58)
Fixes #57.

Allows spaces after the comma between the short and long option
specification.
2017-07-16 15:11:03 +10:00
Mario Werner
11faadeba7 Cmake overhaul (#53)
* remove biicode support

The company/startup died in 2015 and the open source project seems
to be dead as well.

* define compiler warning flags globally instead of locally for every binary

* add support for cmake's find_package() (refs #52)

This rewrite of the main CMakeLists.txt cleans up the way ICU flags
are attached to the library target and adds the cmake helper files
(cxxopts-config.cmake, cxxopts-config-version.cmake,
cxxopts-targets.cmake) which are needed for exporting the cxxopts
target. Cmake's find_package command uses these files when the
library is consumed by another project.

Additionally, two new tests have been added which build the example
application via add_subdirectory and find_package.

* removed target_sources from interface library

Adding target_sources to interface libraries and exporting them is
not supported in CMake 3.1 and 3.2. Furthermore, since it is a header,
it is not needed at all.

* use the *_LDFLAGS instead of *_LIBARIES when linking ICU

The LIBRARIES variable seems to contain only the name and not the
full path.
2017-06-23 18:38:42 +10:00
Dominic Cupo
a3a1363b6b Added inline to check_required (#51)
This alleviated an issue I had where during compilation, check_required was defined multiple times
2017-06-06 10:24:38 +10:00
Jarryd Beck
34aec8e87c Enable warnings and fix them
Fixes #50. This enables -Wall -Wextra -Wshadow and sets -Werror so that
the build fails if there are any warnings. All warnings that came up are
also fixed
2017-06-01 17:12:17 +10:00
Jarryd Beck
52f72a26e7 Version bump 2017-05-31 18:11:31 +10:00
Jarryd Beck
464a8eb65d Add required options helper
Fixes #44. Adds a helper function for checking required options.
2017-05-31 18:10:46 +10:00
Jarryd Beck
f3582c4864 missing file 2017-05-31 17:57:27 +10:00
Jarryd Beck
9d16b98edd Support only short option
Fixes #47. Adds support for options that only have a short option.
2017-05-31 17:40:14 +10:00
Jarryd Beck
77b1b43a7c remove redundant namespace block 2017-05-31 17:25:46 +10:00
Jarryd Beck
3fa0f6caa0 some cleanup
cleanup some code smells
2017-05-31 07:35:35 +10:00
Jarryd Beck
9db62cb338 Fix broken implicit_value when given empty
Fixes #46. When an option had an implicit value, and an empty string was
passed on the command line, the implicit value would be used instead.
2017-05-18 18:06:52 +10:00
Jarryd Beck
cca5472def failing test 2017-05-17 07:38:30 +10:00
Jarryd Beck
848880d931 Fix arguments after -- without declared positional
Fixes #36. This fixes handling arguments passed after `--` when no
positional arguments have been declared, or when the positional
arguments have all been used up. The bug was that the extra arguments
were lost. Now they are retained in the modified argv.
2017-05-06 14:16:00 +10:00
Torben Jonas
21591dc8e8 Conditionally output all help groups on empty groups vector (#42)
* Conditionally output all help groups on empty groups vector

* Fix formatting
2017-05-02 07:40:45 +10:00
Jarryd Beck
3c3d2003ca add help for positional parameters 2017-04-26 18:16:00 +10:00
Jarryd Beck
1be5f10daf clarify wording on short/long
Fixes #37.

A long option is required, a short option is not.
2017-01-30 07:29:12 +11:00
Mario Badr
e005d07656 Use cmake interface library
Fixes #33.

This PR uses cmake's interface library feature:

  An INTERFACE library target does not directly create build output,
  though it may have properties set on it and it may be installed,
  exported and imported.

This makes it easier to include the header only library in a cmake
project. After using add_subdirectory on the cxxopts directory, one
simply needs to include cxxopts in their target_link_libraries, which
will allow the user's target to inherit the properties of the cxxopts
header library (see changes to example and test).
2016-12-03 07:50:14 +11:00