Commit a1c18e058ad1907a4fcc6f13e0f6481fb132cc81

Authored by Philip Top
Committed by Henry Schreiner
1 parent 6be9f0c6

Do a little cleanup on the readme. (#259)

Showing 1 changed file with 51 additions and 58 deletions
README.md
... ... @@ -236,7 +236,7 @@ Option_group *app.add_option_group(name,description); // ๐Ÿšง
236 236 -app.add_mutable_set_ignore_case_underscore(... // ๐Ÿ†• String only
237 237 ```
238 238  
239   -An option name must start with a alphabetic character, underscore, a number ๐Ÿšง, '?'๐Ÿšง, or '@'๐Ÿšง. For long options, after the first character '.', and '-' are also valid characters. For the `add_flag*` functions '{' has special meaning. Names are given as a comma separated string, with the dash or dashes. An option or flag can have as many names as you want, and afterward, using `count`, you can use any of the names, with dashes as needed, to count the options. One of the names is allowed to be given without proceeding dash(es); if present the option is a positional option, and that name will be used on help line for its positional form. If you want the default value to print in the help description, pass in `true` for the final parameter for `add_option`.
  239 +An option name must start with a alphabetic character, underscore, a number ๐Ÿšง, '?'๐Ÿšง, or '@'๐Ÿšง. For long options, after the first character '.', and '-' are also valid characters. For the `add_flag*` functions '{' has special meaning. Names are given as a comma separated string, with the dash or dashes. An option or flag can have as many names as you want, and afterward, using `count`, you can use any of the names, with dashes as needed, to count the options. One of the names is allowed to be given without proceeding dash(es); if present the option is a positional option, and that name will be used on the help line for its positional form. If you want the default value to print in the help description, pass in `true` for the final parameter for `add_option`.
240 240  
241 241 The `add_option_function<type>(...` function will typically require the template parameter be given unless a `std::function` object with an exact match is passed. The type can be any type supported by the `add_option` function. The function should throw an error (`CLI::ConversionError` or `CLI::ValidationError` possibly) if the value is not valid.
242 242  
... ... @@ -249,7 +249,7 @@ app.add_flag(&quot;--flag,!--no-flag,result,&quot;help for flag&quot;); // ๐Ÿšง
249 249 specifies that if `--flag` is passed on the command line result will be true or contain a value of 1. If `--no-flag` is
250 250 passed `result` will contain false or -1 if `result` is a signed integer type, or 0 if it is an unsigned type. An
251 251 alternative form of the syntax is more explicit: `"--flag,--no-flag{false}"`; this is equivalent to the previous
252   -example. This also works for short form options `"-f,!-n"` or `"-f,-n{false}"` If `variable_to_bind_to` is anything but an integer value the
  252 +example. This also works for short form options `"-f,!-n"` or `"-f,-n{false}"`. If `variable_to_bind_to` is anything but an integer value the
253 253 default behavior is to take the last value given, while if `variable_to_bind_to` is an integer type the behavior will be to sum
254 254 all the given arguments and return the result. This can be modified if needed by changing the `multi_option_policy` on each flag (this is not inherited).
255 255 The default value can be any value. For example if you wished to define a numerical flag
... ... @@ -261,7 +261,7 @@ using any of those flags on the command line will result in the specified number
261 261  
262 262 On a `C++14` compiler, you can pass a callback function directly to `.add_flag`, while in C++11 mode you'll need to use `.add_flag_function` if you want a callback function. The function will be given the number of times the flag was passed. You can throw a relevant `CLI::ParseError` to signal a failure.
263 263  
264   -On a compiler that supports C++17's `__has_include`, you can also use `std::optional`, `std::experimental::optional`, and `boost::optional` directly in an `add_option` call. If you don't have `__has_include`, you can define `CLI11_BOOST_OPTIONAL 1` before including CLI11 to manually add support (or 0 to remove) for `boost::optional`. See [CLI11 Internals][] for information on how this was done and how you can add your own converters.
  264 +On a compiler that supports C++17's `__has_include`, you can also use `std::optional`, `std::experimental::optional`, and `boost::optional` directly in an `add_option` call. If you don't have `__has_include`, you can define `CLI11_BOOST_OPTIONAL 1` before including CLI11 to manually add support (or 0 to remove) for `boost::optional`. See [CLI11 Internals][] for information on how this was done and how you can add your own converters. Optional values are only supported for types that support the `>>` operator.
265 265  
266 266 #### Example
267 267  
... ... @@ -285,19 +285,19 @@ Before parsing, you can set the following options:
285 285 - `->group(name)`: The help group to put the option in. No effect for positional options. Defaults to `"Options"`. `""` will not show up in the help print (hidden).
286 286 - `->ignore_case()`: Ignore the case on the command line (also works on subcommands, does not affect arguments).
287 287 - `->ignore_underscore()`: ๐Ÿ†• Ignore any underscores in the options names (also works on subcommands, does not affect arguments). For example "option_one" will match with "optionone". This does not apply to short form options since they only have one character
288   -- `->disable_flag_override()`: ๐Ÿšง from the command line long form flag option can be assigned a value on the command line using the `=` notation `--flag=value`. If this behavior is not desired, the `disable_flag_override()` disables it and will generate an exception if it is done on the command line. The `=` does not work with short form flag options.
289   -- `->delimiter(char)`: ๐Ÿšง allows specification of a custom delimiter for separating single arguments into vector arguments, for example specifying `->delimiter(',')` on an option would result in `--opt=1,2,3` producing 3 elements of a vector and the equivalent of --opt 1 2 3 assuming opt is a vector value
  288 +- `->disable_flag_override()`: ๐Ÿšง from the command line long form flag options can be assigned a value on the command line using the `=` notation `--flag=value`. If this behavior is not desired, the `disable_flag_override()` disables it and will generate an exception if it is done on the command line. The `=` does not work with short form flag options.
  289 +- `->delimiter(char)`: ๐Ÿšง allows specification of a custom delimiter for separating single arguments into vector arguments, for example specifying `->delimiter(',')` on an option would result in `--opt=1,2,3` producing 3 elements of a vector and the equivalent of --opt 1 2 3 assuming opt is a vector value.
290 290 - `->description(str)`: ๐Ÿ†• Set/change the description.
291 291 - `->multi_option_policy(CLI::MultiOptionPolicy::Throw)`: Set the multi-option policy. Shortcuts available: `->take_last()`, `->take_first()`, and `->join()`. This will only affect options expecting 1 argument or bool flags (which do not inherit their default but always start with a specific policy).
292 292 - `->check(std::string(const std::string &), validator_name="",validator_description="")`: ๐Ÿšง define a check function. The function should return a non empty string with the error message if the check fails
293 293 - `->check(Validator)`:๐Ÿšง Use a Validator object to do the check see [Validators](#validators) for a description of available Validators and how to create new ones.
294 294 - `->transform(std::string(std::string &), validator_name="",validator_description=")`: Converts the input string into the output string, in-place in the parsed options.
295 295 - `->transform(Validator)`: uses a Validator object to do the transformation see [Validators](#validators) for a description of available Validators and how to create new ones.
296   -- `->each(void(const std::string &)>`: Run this function on each value received, as it is received. It should throw a `ValidationError` if an error is encountered
  296 +- `->each(void(const std::string &)>`: Run this function on each value received, as it is received. It should throw a `ValidationError` if an error is encountered.
297 297 - `->configurable(false)`: Disable this option from being in a configuration file.
298 298  
299 299  
300   -These options return the `Option` pointer, so you can chain them together, and even skip storing the pointer entirely. Each takes any function that has the signature `void(const std::string&)`; it should throw a `ValidationError` when validation fails. The help message will have the name of the parent option prepended. Since `each`, `check` and `transform` use the same underlying mechanism, you can chain as many as you want, and they will be executed in order. Operations added through `transform` are executed first in reverse order of addition, and `check` and `each` are run in order of addition. If you just want to see the unconverted values, use `.results()` to get the `std::vector<std::string>` of results.
  300 +These options return the `Option` pointer, so you can chain them together, and even skip storing the pointer entirely. The `each` function takes any function that has the signature `void(const std::string&)`; it should throw a `ValidationError` when validation fails. The help message will have the name of the parent option prepended. Since `each`, `check` and `transform` use the same underlying mechanism, you can chain as many as you want, and they will be executed in order. Operations added through `transform` are executed first in reverse order of addition, and `check` and `each` are run following the transform functions in order of addition. If you just want to see the unconverted values, use `.results()` to get the `std::vector<std::string>` of results.
301 301  
302 302 On the command line, options can be given as:
303 303  
... ... @@ -317,7 +317,7 @@ On the command line, options can be given as:
317 317 - `/long` (long flag)
318 318 - `/file filename` (space)
319 319 - `/file:filename` (colon)
320   -- `/long_flag:false (long flag with : to override the default value) ๐Ÿšง
  320 +- `/long_flag:false` (long flag with : to override the default value) ๐Ÿšง
321 321 = Windows style options do not allow combining short options or values not separated from the short option like with `-` options
322 322  
323 323 ๐Ÿšง Long flag options may be given with an `=<value>` to allow specifying a false value, or some other value to the flag. See [config files](#configuration-file) for details on the values supported. NOTE: only the `=` or `:` for windows-style options may be used for this, using a space will result in the argument being interpreted as a positional argument. This syntax can override the default values, and can be disabled by using `disable_flag_override()`.
... ... @@ -330,13 +330,13 @@ If `--` is present in the command line that does not end an unlimited option, th
330 330 everything after that is positional only.
331 331  
332 332 #### Validators
333   -Validators are structures to check or modify inputs, they can be used to verify that an input meets certain criteria or transform it into another value. They are added through an options `check` or `transform` functions. They differences between those two function are that checks do not modify the input whereas transforms can and are executed before any Validators added through `check`.
  333 +Validators are structures to check or modify inputs, they can be used to verify that an input meets certain criteria or transform it into another value. They are added through the `check` or `transform` functions. The differences between the two function are that checks do not modify the input whereas transforms can and are executed before any Validators added through `check`.
334 334  
335   -CLI11 has several Validators built in that perform some common checks
  335 +CLI11 has several Validators built-in that perform some common checks
336 336  
337 337 - `CLI::IsMember(...)`: ๐Ÿšง Require an option be a member of a given set. See [Transforming Validators](#transforming-validators) for more details.
338 338 - `CLI::Transformer(...)`: ๐Ÿšง Modify the input using a map. See [Transforming Validators](#transforming-validators) for more details.
339   -- `CLI::CheckedTransformer(...)`: ๐Ÿšง Modify the input using a map, and Require that the input is either in the set or already one of the outputs of the set. See [Transforming Validators](#transforming-validators) for more details.
  339 +- `CLI::CheckedTransformer(...)`: ๐Ÿšง Modify the input using a map, and require that the input is either in the set or already one of the outputs of the set. See [Transforming Validators](#transforming-validators) for more details.
340 340 - `CLI::ExistingFile`: Requires that the file exists if given.
341 341 - `CLI::ExistingDirectory`: Requires that the directory exists.
342 342 - `CLI::ExistingPath`: Requires that the path (file or directory) exists.
... ... @@ -349,17 +349,14 @@ CLI11 has several Validators built in that perform some common checks
349 349 These Validators can be used by simply passing the name into the `check` or `transform` methods on an option
350 350 ```cpp
351 351 ->check(CLI::ExistingFile);
352   -```
353   -```cpp
354 352 ->check(CLI::Range(0,10));
355 353 ```
356 354  
357   -Validators can be merged using `&` and `|` and inverted using `!`๐Ÿšง
358   -such as
  355 +Validators can be merged using `&` and `|` and inverted using `!`๐Ÿšง. For example
359 356 ```cpp
360 357 ->check(CLI::Range(0,10)|CLI::Range(20,30));
361 358 ```
362   -will produce a check if a value is between 0 and 10 or 20 and 30.
  359 +will produce a check to ensure a value is between 0 and 10 or 20 and 30.
363 360 ```cpp
364 361 ->check(!CLI::PositiveNumber);
365 362 ```
... ... @@ -369,17 +366,17 @@ will produce a check for a number less than 0;
369 366 There are a few built in Validators that let you transform values if used with the `transform` function. If they also do some checks then they can be used `check` but some may do nothing in that case.
370 367 * ๐Ÿšง `CLI::Bounded(min,max)` will bound values between min and max and values outside of that range are limited to min or max, it will fail if the value cannot be converted and produce a `ValidationError`
371 368 * ๐Ÿšง The `IsMember` Validator lets you specify a set of predefined options. You can pass any container or copyable pointer (including `std::shared_ptr`) to a container to this validator; the container just needs to be iterable and have a `::value_type`. The key type should be convertible from a string, You can use an initializer list directly if you like. If you need to modify the set later, the pointer form lets you do that; the type message and check will correctly refer to the current version of the set. The container passed in can be a set, vector, or a map like structure. If used in the `transform` method the output value will be the matching key as it could be modified by filters.
372   -After specifying a set of options, you can also specify "filter" functions of the form `T(T)`, where `T` is the type of the values. The most common choices probably will be `CLI::ignore_case` an `CLI::ignore_underscore`, and CLI::ignore_space. These all work on strings but it is possible to define functions that work on other types.
  369 +After specifying a set of options, you can also specify "filter" functions of the form `T(T)`, where `T` is the type of the values. The most common choices probably will be `CLI::ignore_case` an `CLI::ignore_underscore`, and `CLI::ignore_space`. These all work on strings but it is possible to define functions that work on other types.
373 370 Here are some examples
374 371 of `IsMember`:
375 372  
376 373 * `CLI::IsMember({"choice1", "choice2"})`: Select from exact match to choices.
377 374 * `CLI::IsMember({"choice1", "choice2"}, CLI::ignore_case, CLI::ignore_underscore)`: Match things like `Choice_1`, too.
378 375 * `CLI::IsMember(std::set<int>({2,3,4}))`: Most containers and types work; you just need `std::begin`, `std::end`, and `::value_type`.
379   - * `CLI::IsMember(std::map<std::string, TYPE>({{"one", 1}, {"two", 2}}))`: You can use maps; in `->transform()` these replace the matched value with the matched key. The value member of the map is not used in `IsMember`.
  376 + * `CLI::IsMember(std::map<std::string, TYPE>({{"one", 1}, {"two", 2}}))`: You can use maps; in `->transform()` these replace the matched value with the matched key. The value member of the map is not used in `IsMember`, so it can be any type.
380 377 * `auto p = std::make_shared<std::vector<std::string>>(std::initializer_list<std::string>("one", "two")); CLI::IsMember(p)`: You can modify `p` later.
381   -* ๐Ÿšง The `Transformer` and `CheckedTransformer` Validators transform one value into another. Any container or copyable pointer (including `std::shared_ptr`) to a container that generates pairs of values can be passed to these `Validator's`; the container just needs to be iterable and have a `::value_type` that consists of pairs. The key type should be convertible from a string, and the value type should be convertible to a string You can use an initializer list directly if you like. If you need to modify the map later, the pointer form lets you do that; the description message will correctly refer to the current version of the map. `Transformer` does not do any checking so values not in the map are ignored. `CheckedTransformer` takes an extra step of verifying that the value is either one of the map key values, or one of the expected output values, and if not will generate a ValidationError. A Transformer placed using `check` will not do anything.
382   -After specifying a map of options, you can also specify "filter" just like in CLI::IsMember.
  378 +* ๐Ÿšง The `Transformer` and `CheckedTransformer` Validators transform one value into another. Any container or copyable pointer (including `std::shared_ptr`) to a container that generates pairs of values can be passed to these `Validator's`; the container just needs to be iterable and have a `::value_type` that consists of pairs. The key type should be convertible from a string, and the value type should be convertible to a string You can use an initializer list directly if you like. If you need to modify the map later, the pointer form lets you do that; the description message will correctly refer to the current version of the map. `Transformer` does not do any checking so values not in the map are ignored. `CheckedTransformer` takes an extra step of verifying that the value is either one of the map key values, in which case it is transformed, or one of the expected output values, and if not will generate a `ValidationError`. A Transformer placed using `check` will not do anything.
  379 +After specifying a map of options, you can also specify "filter" just like in `CLI::IsMember`.
383 380 Here are some examples (`Transformer` and `CheckedTransformer` are interchangeable in the examples)
384 381 of `Transformer`:
385 382  
... ... @@ -389,11 +386,11 @@ of `Transformer`:
389 386 * `CLI::CheckedTransformer(std::map<std::string, int>({{"one", 1}, {"two", 2}}))`: You can use maps; in `->transform()` these replace the matched key with the value. `CheckedTransformer` also requires that the value either match one of the keys or match one of known outputs.
390 387 * `auto p = std::make_shared<CLI::TransformPairs<std::string>>(std::initializer_list<std::pair<std::string,std::string>>({"key1", "map1"},{"key2","map2"})); CLI::Transformer(p)`: You can modify `p` later. `TransformPairs<T>` is an alias for `std::vector<std::pair<<std::string,T>>`
391 388  
392   -NOTES: If the container used in `IsMember`, `Transformer`, or `CheckedTransformer` has a specialized search function like `std::unordered_map` or `std::map` then that function is used to do the searching. If it does not have a find function a linear search is performed. If there are filters present, the fast search is performed first, and if that fails a linear search with the filters on the key values is performed.
  389 +NOTES: If the container used in `IsMember`, `Transformer`, or `CheckedTransformer` has a `find` function like `std::unordered_map` or `std::map` then that function is used to do the searching. If it does not have a `find` function a linear search is performed. If there are filters present, the fast search is performed first, and if that fails a linear search with the filters on the key values is performed.
393 390  
394 391 ##### Validator operations๐Ÿšง
395 392 Validators are copyable and have a few operations that can be performed on them to alter settings. Most of the built in Validators have a default description that is displayed in the help. This can be altered via `.description(validator_description)`.
396   -the name of a Validator, which is useful for later reference from the `get_validator(name)` method of an `Option` can be set via `.name(validator_name)`
  393 +The name of a Validator, which is useful for later reference from the `get_validator(name)` method of an `Option` can be set via `.name(validator_name)`
397 394 The operation function of a Validator can be set via
398 395 `.operation(std::function<std::string(std::string &>)`. The `.active()` function can activate or deactivate a Validator from the operation.
399 396 All the functions return a Validator reference allowing them to be chained. For example
... ... @@ -411,7 +408,7 @@ opt-&gt;get_validator(&quot;range&quot;)-&gt;active();
411 408  
412 409 A validator object with a custom function can be created via
413 410 ```cpp
414   -CLI::Validator(std::function<std::string(std::string &>,validator_description,validator_name="");
  411 +CLI::Validator(std::function<std::string(std::string &)>,validator_description,validator_name="");
415 412 ```
416 413 or if the operation function is set later they can be created with
417 414 ```cpp
... ... @@ -425,16 +422,16 @@ Once loaded into an Option, a pointer to a named Validator can be retrieved via
425 422 ```cpp
426 423 opt->get_validator(name);
427 424 ```
428   -This will retrieve a Validator with the given name or throw a CLI::OptionNotFound error. If no name is given or name is empty the first unnamed Validator will be returned or the first Validator if there is only one.
  425 +This will retrieve a Validator with the given name or throw a `CLI::OptionNotFound` error. If no name is given or name is empty the first unnamed Validator will be returned or the first Validator if there is only one.
429 426  
430 427 Validators have a few functions to query the current values
431 428 * `get_description()`:๐Ÿšง Will return a description string
432 429 * `get_name()`:๐Ÿšง Will return the Validator name
433 430 * `get_active()`:๐Ÿšง Will return the current active state, true if the Validator is active.
434   - * `get_modifying()`: ๐Ÿšง Will return true if the Validator is allowed to modify the input, this can be controlled via the `non_modifying()`๐Ÿšง method, though it is recommended to let check and transform function manipulate it if needed.
  431 + * `get_modifying()`: ๐Ÿšง Will return true if the Validator is allowed to modify the input, this can be controlled via the `non_modifying()`๐Ÿšง method, though it is recommended to let `check` and `transform` option methods manipulate it if needed.
435 432  
436 433 #### Getting results
437   -In most cases the fastest and easiest way is to return the results through a callback or variable specified in one of the `add_*` functions. But there are situations where this is not possible or desired. For these cases the results may be obtained through one of the following functions. Please note that these functions will do any type conversions and processing during the call so should not used in performance critical code:
  434 +In most cases, the fastest and easiest way is to return the results through a callback or variable specified in one of the `add_*` functions. But there are situations where this is not possible or desired. For these cases the results may be obtained through one of the following functions. Please note that these functions will do any type conversions and processing during the call so should not used in performance critical code:
438 435  
439 436 - `results()`: Retrieves a vector of strings with all the results in the order they were given.
440 437 - `results(variable_to_bind_to)`: ๐Ÿšง Gets the results according to the MultiOptionPolicy and converts them just like the `add_option_function` with a variable.
... ... @@ -454,10 +451,10 @@ All `App`s have a `get_subcommands()` method, which returns a list of pointers t
454 451 For many cases, however, using an app's callback may be easier. Every app executes a callback function after it parses; just use a lambda function (with capture to get parsed values) to `.callback`. If you throw `CLI::Success` or `CLI::RuntimeError(return_value)`, you can
455 452 even exit the program through the callback. The main `App` has a callback slot, as well, but it is generally not as useful.
456 453 You are allowed to throw `CLI::Success` in the callbacks.
457   -Multiple subcommands are allowed, to allow [`Click`][click] like series of commands (order is preserved). The same subcommand can be triggered multiple times but all positional arguments will take precedence over the second and future calls of the subcommand. `->count()` on the subcommand will return the number of times the subcommand was called. The subcommand callback will only be triggered once.
  454 +Multiple subcommands are allowed, to allow [`Click`][click] like series of commands (order is preserved). The same subcommand can be triggered multiple times but all positional arguments will take precedence over the second and future calls of the subcommand. `->count()` on the subcommand will return the number of times the subcommand was called. The subcommand callback will only be triggered once unless the `.immediate_callback()` flag is set. In which case the callback executes on completion of the subcommand arguments but after the arguments for that subcommand have been parsed, and can be triggered multiple times.
458 455  
459 456 ๐Ÿšง Subcommands may also have an empty name either by calling `add_subcommand` with an empty string for the name or with no arguments.
460   -Nameless subcommands function a similarly to groups in the main `App`. See [Option groups](#option-groups) to see how this might work. If an option is not defined in the main App, all nameless subcommands are checked as well. This allows for the options to be defined in a composable group. The `add_subcommand` function has an overload for adding a `shared_ptr<App>` so the subcommand(s) could be defined in different components and merged into a main `App`, or possibly multiple `Apps`. Multiple nameless subcommands are allowed.
  457 +Nameless subcommands function a similarly to groups in the main `App`. See [Option groups](#option-groups) to see how this might work. If an option is not defined in the main App, all nameless subcommands are checked as well. This allows for the options to be defined in a composable group. The `add_subcommand` function has an overload for adding a `shared_ptr<App>` so the subcommand(s) could be defined in different components and merged into a main `App`, or possibly multiple `Apps`. Multiple nameless subcommands are allowed. Callbacks for nameless subcommands are only triggered if any options from the subcommand were parsed.
461 458  
462 459 #### Subcommand options
463 460  
... ... @@ -465,15 +462,15 @@ There are several options that are supported on the main app and subcommands and
465 462  
466 463 - `.ignore_case()`: Ignore the case of this subcommand. Inherited by added subcommands, so is usually used on the main `App`.
467 464 - `.ignore_underscore()`: ๐Ÿ†• Ignore any underscores in the subcommand name. Inherited by added subcommands, so is usually used on the main `App`.
468   -- `.allow_windows_style_options()`: ๐Ÿ†• Allow command line options to be parsed in the form of `/s /long /file:file_name.ext` This option does not change how options are specified in the `add_option` calls or the ability to process options in the form of `-s --long --file=file_name.ext`
  465 +- `.allow_windows_style_options()`: ๐Ÿ†• Allow command line options to be parsed in the form of `/s /long /file:file_name.ext` This option does not change how options are specified in the `add_option` calls or the ability to process options in the form of `-s --long --file=file_name.ext`.
469 466 - `.fallthrough()`: Allow extra unmatched options and positionals to "fall through" and be matched on a parent command. Subcommands always are allowed to fall through.
470 467 - `.disable()`: ๐Ÿšง Specify that the subcommand is disabled, if given with a bool value it will enable or disable the subcommand or option group.
471   -- `.disabled_by_default()`:๐Ÿšง Specify that at the start of parsing the subcommand should be disabled. This is useful for allowing some Subcommands to trigger others.
  468 +- `.disabled_by_default()`:๐Ÿšง Specify that at the start of parsing the subcommand/option_group should be disabled. This is useful for allowing some Subcommands to trigger others.
472 469 - `.enabled_by_default()`: ๐Ÿšง Specify that at the start of each parse the subcommand/option_group should be enabled. This is useful for allowing some Subcommands to disable others.
473   -- `.exludes(option_or_subcommand)`: ๐Ÿšง If given an option pointer or pointer to another subcommand, these subcommands cannot be given together. In the case of options, if the option is passed the subcommand cannot be used and will generate an error.
  470 +- `.excludes(option_or_subcommand)`: ๐Ÿšง If given an option pointer or pointer to another subcommand, these subcommands cannot be given together. In the case of options, if the option is passed the subcommand cannot be used and will generate an error.
474 471 - `.require_option()`: ๐Ÿšง Require 1 or more options or option groups be used.
475   -- `.require_option(N)`: ๐Ÿšง Require `N` options or option groups if `N>0`, or up to `N` if `N<0`. `N=0` resets to the default to 0 or more.
476   -- `.require_option(min, max)`: ๐Ÿšง Explicitly set min and max allowed options or option groups. Setting `max` to 0 is unlimited.
  472 +- `.require_option(N)`: ๐Ÿšง Require `N` options or option groups, if `N>0`, or up to `N` if `N<0`. `N=0` resets to the default to 0 or more.
  473 +- `.require_option(min, max)`: ๐Ÿšง Explicitly set min and max allowed options or option groups. Setting `max` to 0 implies unlimited options.
477 474 - `.require_subcommand()`: Require 1 or more subcommands.
478 475 - `.require_subcommand(N)`: Require `N` subcommands if `N>0`, or up to `N` if `N<0`. `N=0` resets to the default to 0 or more.
479 476 - `.require_subcommand(min, max)`: Explicitly set min and max allowed subcommands. Setting `max` to 0 is unlimited.
... ... @@ -483,7 +480,7 @@ There are several options that are supported on the main app and subcommands and
483 480 - `.got_subcommand(App_or_name)`: Check to see if a subcommand was received on the command line.
484 481 - `.get_subcommands(filter)`: The list of subcommands that match a particular filter function.
485 482 - `.add_option_group(name="", description="")`: ๐Ÿšง Add an [option group](#option-groups) to an App, an option group is specialized subcommand intended for containing groups of options or other groups for controlling how options interact.
486   -- `.get_parent()`: Get the parent App or nullptr if called on master App.
  483 +- `.get_parent()`: Get the parent App or `nullptr` if called on master App.
487 484 - `.get_option(name)`: Get an option pointer by option name will throw if the specified option is not available, nameless subcommands are also searched
488 485 - `.get_option_no_throw(name)`: ๐Ÿšง Get an option pointer by option name. This function will return a `nullptr` instead of throwing if the option is not available.
489 486 - `.get_options(filter)`: Get the list of all defined option pointers (useful for processing the app for custom output formats).
... ... @@ -492,9 +489,9 @@ There are several options that are supported on the main app and subcommands and
492 489 - `.description(str)`: ๐Ÿ†• Set/change the description.
493 490 - `.get_description()`: Access the description.
494 491 - `.parsed()`: True if this subcommand was given on the command line.
495   -- `.count()`: Returns the number of times the subcommand was called
496   -- `.count(option_name)`: Returns the number of times a particular option was called
497   -- `.count_all()`: ๐Ÿšง Returns the total number of arguments a particular subcommand processed, on the master App it returns the total number of processed commands
  492 +- `.count()`: Returns the number of times the subcommand was called.
  493 +- `.count(option_name)`: Returns the number of times a particular option was called.
  494 +- `.count_all()`: ๐Ÿšง Returns the total number of arguments a particular subcommand processed, on the master App it returns the total number of processed commands.
498 495 - `.name(name)`: Add or change the name.
499 496 - `.callback(void() function)`: Set the callback that runs at the end of parsing. The options have already run at this point. See [Subcommand callbacks](#callbacks) for some additional details.
500 497 - `.immediate_callback()`: ๐Ÿšง Specify that the callback for a subcommand should run immediately on completion of a subcommand vs at the completion of all parsing if this option is not used.
... ... @@ -507,12 +504,12 @@ There are several options that are supported on the main app and subcommands and
507 504 - `.set_help_all_flag(name, message)`: Set the help all flag name and message, returns a pointer to the created option. Expands subcommands.
508 505 - `.failure_message(func)`: Set the failure message function. Two provided: `CLI::FailureMessage::help` and `CLI::FailureMessage::simple` (the default).
509 506 - `.group(name)`: Set a group name, defaults to `"Subcommands"`. Setting `""` will be hide the subcommand.
510   -- `[option_name]`: ๐Ÿšง retrieve a const pointer to an option given by `option_name` for Example `app["--flag1"]` will get a pointer to the option for the "--flag1" value, `app["--flag1"]->as<bool>() will get the results of the command line for a flag
  507 +- `[option_name]`: ๐Ÿšง retrieve a const pointer to an option given by `option_name` for Example `app["--flag1"]` will get a pointer to the option for the "--flag1" value, `app["--flag1"]->as<bool>()` will get the results of the command line for a flag.
511 508  
512 509 > Note: if you have a fixed number of required positional options, that will match before subcommand names. `{}` is an empty filter function, and any positional argument will match before repeated subcommand names.
513 510  
514 511  
515   -#### Callbacks
  512 +#### Callbacks
516 513 A subcommand has two optional callbacks that are executed at different stages of processing. The `preparse_callback` ๐Ÿšง is executed once after the first argument of a subcommand or application is processed and gives an argument for the number of remaining arguments to process. For the main app the first argument is considered the program name, for subcommands the first argument is the subcommand name. For Option groups and nameless subcommands the first argument is after the first argument or subcommand is processed from that group.
517 514 The second callback is executed after parsing. The behavior depends on the status of the `immediate_callback` flag ๐Ÿšง. If true, this runs immediately after the parsing of the subcommand. Or if the flag is false, once after parsing of all arguments. If the `immediate_callback` is set then the callback can be executed multiple times if the subcommand list given multiple times. If the main app or subcommand has a config file, no data from the config file will be reflected in immediate_callback. `immediate_callback()` has no effect on the main app, though it can be inherited. For option_groups `immediate_callback` causes the callback to be run prior to other option groups and options in the main app, effectively giving the options in the group priority.
518 515  
... ... @@ -522,7 +519,7 @@ For example say an application was set up like
522 519 app.callback(ac);
523 520 sub1=app.add_subcommand("sub1")->callback(c1)->preparse_callback(pc1)->immediate_callback();
524 521 sub2=app.add_subcommand("sub2")->callback(c2)->preparse_callback(pc2);
525   -app.preparse_callback( pa1);
  522 +app.preparse_callback( pa);
526 523  
527 524 ... A bunch of other options
528 525  
... ... @@ -534,13 +531,13 @@ Then the command line is given as
534 531 program --opt1 opt1_val sub1 --sub1opt --sub1optb val sub2 --sub2opt sub1 --sub1opt2 sub2 --sub2opt2 val
535 532 ```
536 533  
537   -* pa will be called prior to parsing any values with an argument of 14.
  534 +* pa will be called prior to parsing any values with an argument of 13.
538 535 * pc1 will be called immediately after processing the sub1 command with a value of 10.
539   -* c1 will be called when the `sub2` command is encountered
  536 +* c1 will be called when the `sub2` command is encountered.
540 537 * pc2 will be called with value of 6 after the sub2 command is encountered.
541   -* c1 will be called again after the second sub2 command is encountered
542   -* c2 will be called once after processing all arguments
543   -* ac will be called after completing the parse and all lower level callbacks have been executed
  538 +* c1 will be called again after the second sub2 command is encountered.
  539 +* c2 will be called once after processing all arguments.
  540 +* ac will be called after completing the parse and all lower level callbacks have been executed.
544 541  
545 542 A subcommand is considered terminated when one of the following conditions are met.
546 543 1. There are no more arguments to process
... ... @@ -548,7 +545,7 @@ A subcommand is considered terminated when one of the following conditions are m
548 545 3. The positional_mark(`--`) is encountered and there are no available positional slots in the subcommand.
549 546 4. The subcommand_terminator mark(`++`) is encountered
550 547  
551   -If the `immediate_callback` flag is set then all contained options are processed and the callback is triggered. If a subcommand with an immediate_callback flag is called again, then the contained options are reset, and can be triggered again.
  548 +If the `immediate_callback` flag is set then all contained options are processed and the callback is triggered. If a subcommand with an `immediate_callback` flag is called again, then the contained options are reset, and can be triggered again.
552 549  
553 550  
554 551  
... ... @@ -560,28 +557,24 @@ The subcommand method
560 557 .add_option_group(name,description)
561 558 ```
562 559  
563   -Will create an option Group, and return a pointer to it. An option group allows creation of a collection of options, similar to the groups function on options, but with additional controls and requirements. They allow specific sets of options to be composed and controlled as a collective. For an example see [range test](./tests/ranges.cpp). Option groups are a specialization of an App so all [functions](#subcommand-options) that work with an App also work on option groups. Options can be created as part of an option group using the add functions just like a subcommand, or previously created options can be added through
  560 +Will create an option group, and return a pointer to it. An option group allows creation of a collection of options, similar to the groups function on options, but with additional controls and requirements. They allow specific sets of options to be composed and controlled as a collective. For an example see [range test](./tests/ranges.cpp). Option groups are a specialization of an App so all [functions](#subcommand-options) that work with an App or subcommand also work on option groups. Options can be created as part of an option group using the add functions just like a subcommand, or previously created options can be added through
564 561  
565 562 ```cpp
566 563 ogroup->add_option(option_pointer);
567   -```
568   -
569   -```cpp
570 564 ogroup->add_options(option_pointer);
571   -```
572   -
573   -```cpp
574 565 ogroup->add_options(option1,option2,option3,...);
575 566 ```
576 567  
577 568 The option pointers used in this function must be options defined in the parent application of the option group otherwise an error will be generated. Subcommands can also be added via
  569 +
578 570 ```cpp
579 571 ogroup->add_subcommand(subcom_pointer);
580 572 ```
  573 +
581 574 This results in the subcommand being moved from its parent into the option group.
582 575  
583 576 Options in an option group are searched for a command line match after any options in the main app, so any positionals in the main app would be matched first. So care must be taken to make sure of the order when using positional arguments and option groups.
584   -Option groups work well with `excludes` and `require_options` methods, as an Application will treat an option group as a single option for the purpose of counting and requirements. Option groups allow specifying requirements such as requiring 1 of 3 options in one group and 1 of 3 options in a different group. Option groups can contain other groups as well. Disabling an option group will turn off all options within the group.
  577 +Option groups work well with `excludes` and `require_options` methods, as an Application will treat an option group as a single option for the purpose of counting and requirements, and an option group will be considered used if any of the options or subcommands contained in it are used. Option groups allow specifying requirements such as requiring 1 of 3 options in one group and 1 of 3 options in a different group. Option groups can contain other groups as well. Disabling an option group will turn off all options within the group.
585 578  
586 579 The `CLI::TriggerOn`๐Ÿšง and `CLI::TriggerOff`๐Ÿšง methods are helper methods to allow the use of options/subcommands from one group to trigger another group on or off.
587 580  
... ... @@ -590,7 +583,7 @@ CLI::TriggerOn(group1_pointer, triggered_group);
590 583 CLI::TriggerOff(group2_pointer, disabled_group);
591 584 ```
592 585  
593   -These functions make use of the `preparse_callback`, `enabled_by_default()` and `disabled_by_default`. The triggered group may be a vector of group pointers. These methods should only used once per group and will override any previous use of the underlying functions. More complex arrangements can be accomplished using similar methodology with a different preparse_callback function that does more.
  586 +These functions make use of `preparse_callback`, `enabled_by_default()` and `disabled_by_default`. The triggered group may be a vector of group pointers. These methods should only be used once per group and will override any previous use of the underlying functions. More complex arrangements can be accomplished using similar methodology with a custom preparse_callback function that does more.
594 587  
595 588  
596 589 ### Configuration file
... ... @@ -659,12 +652,12 @@ Also, in a related note, the `App` you get a pointer to is stored in the parent
659 652  
660 653 ### How it works
661 654  
662   -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 strings, so it knows how many times an option was passed or how many arguments it received (flags add empty strings to keep the counts correct). The lambda returns `true` if it could validate the option strings, and
  655 +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 strings, so it knows how many times an option was passed or how many arguments it received. The lambda returns `true` if it could validate the option strings, and
663 656 `false` if it failed.
664 657  
665   -Other values can be added as long as they support `operator>>` (and defaults can be printed if they support `operator<<`). To add an enum, for example, provide a custom `operator>>` with an `istream` (inside the CLI namespace is fine if you don't want to interfere with an existing `operator>>`).
  658 +Other values can be added as long as they support `operator>>` (and defaults can be printed if they support `operator<<`). To add a new type, for example, provide a custom `operator>>` with an `istream` (inside the CLI namespace is fine if you don't want to interfere with an existing `operator>>`).
666 659  
667   -If you wanted to extend this to support a completely new type, use a lambda or add a specialization of the lexical_cast function template in the namespace `CLI::detail` with the type you need to convert to. Some examples of some new parsers for `complex<double>` that support all of the features of a standard `add_options` call are in [one of the tests](./tests/NewParseTest.cpp). A simpler example is shown below:
  660 +If you wanted to extend this to support a completely new type, use a lambda or add a specialization of the `lexical_cast` function template in the namespace `CLI::detail` with the type you need to convert to. Some examples of some new parsers for `complex<double>` that support all of the features of a standard `add_options` call are in [one of the tests](./tests/NewParseTest.cpp). A simpler example is shown below:
668 661  
669 662 #### Example
670 663  
... ...