Commit 2c431f1613edd6355a53d4fe24790ea859a776f7

Authored by Henry Fredrick Schreiner
1 parent 9a956f1d

Adding fixes from derilict C++14 branch

README.md
@@ -123,11 +123,11 @@ An option name must start with a alphabetic character or underscore. For long op @@ -123,11 +123,11 @@ An option name must start with a alphabetic character or underscore. For long op
123 123
124 Adding a configuration option is special. If it is present, it will be read along with the normal command line arguments. The file will be read if it exists, and does not throw an error unless required is `true`. Configuration files are in `ini` format, and only support long options. Currently, flags and vector options are not supported. 124 Adding a configuration option is special. If it is present, it will be read along with the normal command line arguments. The file will be read if it exists, and does not throw an error unless required is `true`. Configuration files are in `ini` format, and only support long options. Currently, flags and vector options are not supported.
125 125
126 -> ### Example  
127 ->  
128 -> * `"one,-o,--one"`: Valid as long as not a flag, would create an option that can be specified positionally, or with `-o` or `--option`  
129 -> * `"this"` Can only be passed positionally  
130 -> * `"-a,-b,-c"` No limit to the number of non-positional option names 126 +### Example
  127 +
  128 +* `"one,-o,--one"`: Valid as long as not a flag, would create an option that can be specified positionally, or with `-o` or `--option`
  129 +* `"this"` Can only be passed positionally
  130 +* `"-a,-b,-c"` No limit to the number of non-positional option names
131 131
132 132
133 The add commands return a pointer to an internally stored `Option`. If you set the final argument to true, the default value is captured and printed on the command line with the help flag. This option can be used directly to check for the count (`->count()`) after parsing to avoid a string based lookup. Before parsing, you can set the following options: 133 The add commands return a pointer to an internally stored `Option`. If you set the final argument to true, the default value is captured and printed on the command line with the help flag. This option can be used directly to check for the count (`->count()`) after parsing to avoid a string based lookup. Before parsing, you can set the following options:
@@ -186,6 +186,15 @@ Also, in a related note, the `App` you get a pointer to is stored in the parent @@ -186,6 +186,15 @@ Also, in a related note, the `App` you get a pointer to is stored in the parent
186 Every `add_` option you have seen so far depends on one method that takes a lambda function. Each of these methods is just making a different lambda function with capture to populate the option. The function has full access to the vector of vector of strings, so it knows how many times an option was passed, and how many arguments each passing received (flags add empty strings to keep the counts correct). The lambda returns `true` if it could validate the option strings, and 186 Every `add_` option you have seen so far depends on one method that takes a lambda function. Each of these methods is just making a different lambda function with capture to populate the option. The function has full access to the vector of vector of strings, so it knows how many times an option was passed, and how many arguments each passing received (flags add empty strings to keep the counts correct). The lambda returns `true` if it could validate the option strings, and
187 `false` if it failed. 187 `false` if it failed.
188 188
  189 +### Example
  190 +
  191 +~~~python
  192 +app.add_option("--fancy-count", [](std::vector<std::vector<std::string>> val){
  193 + std::cout << "This option was given " << val.size() << " times." << std::endl
  194 + << "The first time, it received " << val.at(0).size() << " items" << std::endl;
  195 + });
  196 +~~~
  197 +
189 ## Contributing 198 ## Contributing
190 199
191 To contribute, open an [issue](https://github.com/henryiii/CLI11/issues) or [pull request](https://github.com/henryiii/CLI11/pulls) on GitHub, or ask a question on [gitter](https://gitter.im/CLI11gitter/Lobby). 200 To contribute, open an [issue](https://github.com/henryiii/CLI11/issues) or [pull request](https://github.com/henryiii/CLI11/pulls) on GitHub, or ask a question on [gitter](https://gitter.im/CLI11gitter/Lobby).
include/CLI/App.hpp
@@ -319,7 +319,7 @@ public: @@ -319,7 +319,7 @@ public:
319 } 319 }
320 320
321 321
322 - /// Add set of options_ 322 + /// Add set of options
323 template<typename T> 323 template<typename T>
324 Option* add_set( 324 Option* add_set(
325 std::string name, 325 std::string name,
@@ -357,7 +357,7 @@ public: @@ -357,7 +357,7 @@ public:
357 Option* add_set_ignore_case( 357 Option* add_set_ignore_case(
358 std::string name, 358 std::string name,
359 std::string &member, ///< The selected member of the set 359 std::string &member, ///< The selected member of the set
360 - std::set<std::string> options, ///< The set of posibilities 360 + std::set<std::string> options, ///< The set of posibilities
361 std::string description="", 361 std::string description="",
362 bool defaulted=false 362 bool defaulted=false
363 ) { 363 ) {