Commit Graph

107 Commits

Author SHA1 Message Date
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
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
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
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
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
e40645e084 Don't show default when boolean false
Fixes #102. Don't show the default value when it is a boolean and the
value is false. Note that this is a bit of a hack and the
implementation should probably be reevaluated in the future.
2018-03-08 08:53:26 +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
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
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
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
Jarryd Beck
3c3d2003ca add help for positional parameters 2017-04-26 18:16:00 +10: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
Jarryd Beck
a04284fc2c fix Unicode build 2016-11-30 18:05:34 +11:00
Jarryd Beck
d92988c6a2 Allow for numbers in options
Closes #32. This adds numbers as allowed values in all parts
of short and long option specifiers.
2016-11-16 18:03:35 +11:00
Jarryd Beck
c45bcc3858 Hide positional parameters that are a container.
Closes #26. Don't show positional parameters that are a container,
because they are designed for chewing up any extra parameters.
2016-08-29 18:37:15 +10:00
Jarryd Beck
9e3f3115d2 Don't overwrite positional arguments.
Fixes #30. The positional arguments are not overwritten when they
have already been given on the command line.
2016-08-29 18:11:18 +10:00
Jarryd Beck
bef3e67cb8 Fix uninitialised m_next_positional
This fixes the runtime error in Travis Job 17.2.

The variable Options::m_next_positional was not initialised when no
positional parameters were set.
2016-08-26 20:13:49 +10:00
Jarryd Beck
c6554ddc49 ignore built files 2016-08-26 08:26:42 +10:00
Jarryd Beck
55bfe49aa0 options test 2016-08-26 08:22:04 +10:00
Jarryd Beck
abab8ce325 I27 vector<string> doesn't parse
Reorder the `parse_value` functions so that the vector-specific
function can see all of the other specific parsers.
2016-07-05 08:29:20 +10:00
Jarryd Beck
21489b233d fix long line 2016-07-04 19:17:54 +10:00
Pavel Medvedev
2e157e9881 Skip empty lines in option groups help
Also use single character \n for end of line instead of string literal.
2016-07-01 00:57:59 +03:00
Kevin Brightwell
774d455dc7 Update CMakeLists to be more configurable
* Add cxxopts.hpp as a source file to executable
* Add msvc options for compiling
* Add CXXOPTS_BUILD_EXAMPLES option to CMake build
  * This is helpful when using CMake's ExternalProject_add()
  * It is ON by default, but configurable from the command-line.
2016-06-15 20:32:32 -04:00
Jarryd Beck
7081d81890 add cstring for some compilers 2016-06-03 11:35:48 +10:00
Taylor Braun-Jones
7eb1bfbec1 Don't count default values 2016-05-23 15:49:52 -04:00
Nicholas Parker
ff3798f25c Remove log output
Looked like it was left over from something? Saw it when testing "--some-int-val string"
2016-04-30 09:24:04 -07:00
Jarryd Beck
81f1f440ed count arguments 2016-01-22 17:44:00 +11:00
Jarryd Beck
3ce8cbd1ae add support for -- 2016-01-22 17:43:20 +11:00
Jarryd Beck
b2e7efe7f4 positional arguments parse into multiple options 2015-09-25 16:49:06 +10:00
Kostya Bazhanov
9205d9093b Disable -Wnon-virtual-dtor warning for GCC and Clang. 2015-04-23 22:05:19 +03:00
Kostya Bazhanov
9c59bb25ff Fix Clang -Wsign-conversion and -Wshorten-64-to-32 warnings. 2015-04-18 21:50:12 +03:00
Kostya Bazhanov
2e9aab5cd0 Remove trailing spaces. 2015-04-18 21:43:37 +03:00
Baptiste Wicht
7611711651 Better support for spaces
This fixes support for options such as --file="folder with spaces/file".
2015-02-13 10:55:26 +01:00
Nagy Zsolt
44de7726f8 Fix remaining character check 2015-01-23 18:25:17 +01:00
Jarryd Beck
2144fbcc58 comment about Unicode 2014-11-08 15:30:32 +11:00
Jarryd Beck
f62ebb9688 formatting, inline 2014-10-31 08:30:50 +11:00
Baptiste Wicht
5492f17969 Add some getter
* Get list of groups
 * Get help details for groups
2014-10-30 18:14:08 +01:00
Jarryd Beck
f4c429390f Merge remote-tracking branch 'remotes/origin/master'
Conflicts:
	src/cxxopts.hpp
2014-10-30 08:56:29 +11:00
Baptiste Wicht
164095cc0c Macro to disable RTTI 2014-10-29 17:52:30 +01:00
Baptiste Wicht
4e4e91c37d Fix warnings 2014-10-29 17:35:42 +01:00
Baptiste Wicht
0639e086ea Finalize help 2014-10-29 17:04:53 +01:00
Baptiste Wicht
e09bb9052a Enhance example 2014-10-29 16:59:57 +01:00
Baptiste Wicht
9a2749f692 Merge branch 'master' into default_values
Conflicts:
	src/cxxopts.hpp
	src/example.cpp
2014-10-29 16:42:59 +01:00
Jarryd Beck
1a558d76bd custom argument help 2014-10-29 12:35:05 +11:00
Baptiste Wicht
9642317b08 Fix implicit and short 2014-10-28 21:36:33 +01:00
Baptiste Wicht
32be452302 Fix compilation 2014-10-28 21:27:29 +01:00
Baptiste Wicht
cc65ebb4fc Fix warning 2014-10-27 19:25:44 +01:00