Skip to content

Commit

Permalink
Merge branch '2_0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jarro2783 committed Nov 15, 2017
2 parents d7b9308 + 70b9230 commit 8893afe
Show file tree
Hide file tree
Showing 8 changed files with 621 additions and 295 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,29 @@
# Changelog

This is the changelog for `cxxopts`, a C++11 library for parsing command line
options. The project adheres to semantic versioning.

## 2.0

### Changed

* `Options::parse` returns a ParseResult rather than storing the parse
result internally.
* Options with default values now get counted as appearing once if they
were not specified by the user.

### Added

* A new `ParseResult` object that is the immutable result of parsing. It
responds to the same `count` and `operator[]` as `Options` of 1.x did.
* The function `ParseResult::arguments` returns a vector of the parsed
arguments to iterate through in the order they were provided.
* The symbol `cxxopts::version` for the version of the library.
* Booleans can be specified with various strings and explicitly set false.

## 1.x

The 1.x series was the first major version of the library, with release numbers
starting to follow semantic versioning, after 0.x being unstable. It never had
a changelog maintained for it. Releases mostly contained bug fixes, with the
occasional feature added.
19 changes: 14 additions & 5 deletions README.md
Expand Up @@ -39,12 +39,12 @@ Any type can be given as long as it can be parsed, with operator>>.

To parse the command line do:

options.parse(argc, argv);
auto result = options.parse(argc, argv);

To retrieve an option use `options.count("option")` to get the number of times
To retrieve an option use `result.count("option")` to get the number of times
it appeared, and

options["opt"].as<type>()
result["opt"].as<type>()

to get its value. If "opt" doesn't exist, or isn't of the right type, then an
exception will be thrown.
Expand Down Expand Up @@ -84,6 +84,17 @@ If an option had both, then not specifying it would give the value `"value"`,
writing it on the command line as `--option` would give the value `"implicit"`,
and writing `--option=another` would give it the value `"another"`.

Note that the default and implicit value is always stored as a string,
regardless of the type that you want to store it in. It will be parsed as
though it was given on the command line.

## Boolean values

Boolean options have a default implicit value of `"true"`, which can be
overridden. The effect is that writing `-o` by itself will set option `o` to
`true`. However, they can also be written with various strings using either
`=value` or the next argument.

# Linking

This is a header only library.
Expand All @@ -93,9 +104,7 @@ This is a header only library.
The only build requirement is a C++ compiler that supports C++11 regular
expressions. For example GCC >= 4.9 or clang with libc++.


# TODO list

* Allow unrecognised options.
* Various help strings.
* Unicode aware for help strings.

0 comments on commit 8893afe

Please sign in to comment.