Commit 4f14dbde63bb9a7b9da47c7229a947269832a243

Authored by Henry Schreiner
Committed by Henry Schreiner
1 parent c1465e61

style: run pre-commit on linewidth

.appveyor.yml
... ... @@ -19,7 +19,9 @@ install:
19 19 build_script:
20 20 - mkdir build
21 21 - cd build
22   - - ps: cmake .. -DCLI11_WARNINGS_AS_ERRORS=ON -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015"
  22 + - ps:
  23 + cmake .. -DCLI11_WARNINGS_AS_ERRORS=ON -DCLI11_SINGLE_FILE_TESTS=ON
  24 + -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015"
23 25 - ps: cmake --build .
24 26 - cd ..
25 27 - conan create . CLIUtils/CLI11
... ...
.ci/azure-build.yml
1 1 steps:
2 2 - task: CMake@1
3 3 inputs:
4   - cmakeArgs: .. -DCLI11_WARNINGS_AS_ERRORS=ON -DCLI11_SINGLE_FILE=$(cli11.single) -DCMAKE_CXX_STANDARD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) $(cli11.options)
  4 + cmakeArgs:
  5 + .. -DCLI11_WARNINGS_AS_ERRORS=ON -DCLI11_SINGLE_FILE=$(cli11.single)
  6 + -DCMAKE_CXX_STANDARD=$(cli11.std)
  7 + -DCLI11_SINGLE_FILE_TESTS=$(cli11.single)
  8 + -DCMAKE_BUILD_TYPE=$(cli11.build_type) $(cli11.options)
5 9 displayName: "Configure"
6 10  
7 11 - script: cmake --build .
... ...
.ci/azure-cmake.yml
... ... @@ -11,5 +11,7 @@ steps:
11 11 destinationFolder: "cmake_program"
12 12 displayName: Extract CMake
13 13  
14   - - bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
  14 + - bash:
  15 + echo
  16 + "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
15 17 displayName: Add CMake to PATH
... ...
.clang-tidy
... ... @@ -4,15 +4,9 @@
4 4 FormatStyle: file
5 5  
6 6 Checks: >
7   - -*,
8   - google-*,
9   - -google-runtime-references,
10   - llvm-include-order,
11   - llvm-namespace-comment,
12   - misc-throw-by-value-catch-by-reference,
13   - modernize*,
14   - -modernize-use-trailing-return-type,
15   - readability-container-size-empty,
  7 + -*, google-*, -google-runtime-references, llvm-include-order,
  8 + llvm-namespace-comment, misc-throw-by-value-catch-by-reference, modernize*,
  9 + -modernize-use-trailing-return-type, readability-container-size-empty,
16 10  
17 11 WarningsAsErrors: "*"
18 12  
... ...
.github/CONTRIBUTING.md
1 1 # Contributing
2 2  
3   -Thanks for considering to write a Pull Request (PR) for CLI11! Here are a few guidelines to get you started:
  3 +Thanks for considering to write a Pull Request (PR) for CLI11! Here are a few
  4 +guidelines to get you started:
4 5  
5   -Make sure you are comfortable with the license; all contributions are licensed under the original license.
  6 +Make sure you are comfortable with the license; all contributions are licensed
  7 +under the original license.
6 8  
7 9 ## Adding functionality
8 10  
... ... @@ -13,25 +15,36 @@ Make sure any new functions you add are are:
13 15 - Explained in your PR (or previously explained in an Issue mentioned in the PR)
14 16 - Completely covered by tests
15 17  
16   -In general, make sure the addition is well thought out and does not increase the complexity of CLI11 needlessly.
  18 +In general, make sure the addition is well thought out and does not increase the
  19 +complexity of CLI11 needlessly.
17 20  
18 21 ## Things you should know
19 22  
20   -- Once you make the PR, tests will run to make sure your code works on all supported platforms
  23 +- Once you make the PR, tests will run to make sure your code works on all
  24 + supported platforms
21 25 - The test coverage is also measured, and that should remain 100%
22   -- Formatting should be done with pre-commit, otherwise the format check will not pass. However, it is trivial to apply this to your PR, so don't worry about this check. If you do want to run it, see below.
23   -- Everything must pass clang-tidy as well, run with `-DCLI11_CLANG_TIDY=ON` (if you set `-DCLI11_CLANG_TIDY_OPTIONS="-fix"`, make sure you use a single threaded build process, or just build one example target).
24   -- Your changes must also conform to most of the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) rules checked by [cpplint](https://github.com/cpplint/cpplint). For unused cpplint filters and justifications, see [CPPLINT.cfg](/CPPLINT.cfg).
  26 +- Formatting should be done with pre-commit, otherwise the format check will not
  27 + pass. However, it is trivial to apply this to your PR, so don't worry about
  28 + this check. If you do want to run it, see below.
  29 +- Everything must pass clang-tidy as well, run with `-DCLI11_CLANG_TIDY=ON` (if
  30 + you set `-DCLI11_CLANG_TIDY_OPTIONS="-fix"`, make sure you use a single
  31 + threaded build process, or just build one example target).
  32 +- Your changes must also conform to most of the
  33 + [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
  34 + rules checked by [cpplint](https://github.com/cpplint/cpplint). For unused
  35 + cpplint filters and justifications, see [CPPLINT.cfg](/CPPLINT.cfg).
25 36  
26 37 ## Pre-commit
27 38  
28   -Format is handled by pre-commit. You should install it (or use [pipx](https://pypa.github.io/pipx/)):
  39 +Format is handled by pre-commit. You should install it (or use
  40 +[pipx](https://pypa.github.io/pipx/)):
29 41  
30 42 ```bash
31 43 python3 -m pip install pre-commit
32 44 ```
33 45  
34   -Then, you can run it on the items you've added to your staging area, or all files:
  46 +Then, you can run it on the items you've added to your staging area, or all
  47 +files:
35 48  
36 49 ```bash
37 50 pre-commit run
... ... @@ -39,7 +52,8 @@ pre-commit run
39 52 pre-commit run --all-files
40 53 ```
41 54  
42   -And, if you want to always use it, you can install it as a git hook (hence the name, pre-commit):
  55 +And, if you want to always use it, you can install it as a git hook (hence the
  56 +name, pre-commit):
43 57  
44 58 ```bash
45 59 pre-commit install
... ... @@ -47,7 +61,8 @@ pre-commit install
47 61  
48 62 ## For developers releasing to Conan.io
49 63  
50   -This is now done by the CI system on tagged releases. Previously, the steps to make a Conan.io release were:
  64 +This is now done by the CI system on tagged releases. Previously, the steps to
  65 +make a Conan.io release were:
51 66  
52 67 ```bash
53 68 conan remove '*' # optional, I like to be clean
... ... @@ -59,7 +74,10 @@ Here I've assumed that the remote is `cli11`.
59 74  
60 75 ## For maintainers: remember to add contributions
61 76  
62   -In a commit to a PR, just add "`@all-contributors please add <username> for <contributions>`" or similar (see <https://allcontributors.org>). Use `code` for code, `bug` if an issue was submitted, `platform` for packaging stuff, and `doc` for documentation updates.
  77 +In a commit to a PR, just add
  78 +"`@all-contributors please add <username> for <contributions>`" or similar (see
  79 +<https://allcontributors.org>). Use `code` for code, `bug` if an issue was
  80 +submitted, `platform` for packaging stuff, and `doc` for documentation updates.
63 81  
64 82 To run locally, do:
65 83  
... ... @@ -70,7 +88,8 @@ yarn all-contributors add username code,bug
70 88  
71 89 ## For maintainers: Making a release
72 90  
73   -Remember to replace the emoji in the readme, being careful not to replace the ones in all-contributors if any overlap.
  91 +Remember to replace the emoji in the readme, being careful not to replace the
  92 +ones in all-contributors if any overlap.
74 93  
75 94 Steps:
76 95  
... ...
CHANGELOG.md
... ... @@ -2,28 +2,55 @@
2 2  
3 3 ## Version 2.2: Option and Configuration Flexibility
4 4  
5   -New features include support for output of an empty vector, a summing option policy that can be applied more broadly, and an option to validate optional arguments to discriminate from positional arguments. A new validator to check for files on a default path is included to allow one or more default paths for configuration files or other file arguments. A number of bug fixes and code cleanup for various build configurations. Clean up of some error outputs and extension of existing capability to new types or situations.
6   -
7   -There is a possible minor breaking change in behavior of certain types which wrapped an integer, such as `std::atomic<int>` or `std::optional<int>` when used in a flag. The default behavior is now as a single argument value vs. summing all the arguments. The default summing behavior is now restricted to pure integral types, int64_t, int, uint32_t, etc. Use the new `sum` multi option policy to revert to the older behavior. The summing behavior on wrapper types was not originally intended.
8   -
9   -- Add `MultiOptionPolicy::Sum` and refactor the `add_flag` to fix a bug when using `std::optional<bool>` as type. [#709][]
10   -- Add support for an empty vector result in TOML and as a default string. [#660][]
11   -- Add `.validate_optional_arguments()` to support discriminating positional arguments from vector option arguments. [#668][]
12   -- Add `CLI::FileOnDefaultPath` to check for files on a specified default path. [#698][]
13   -- Change default value display in help messages from `=XXXX` to `[XXXXX]` to make it clearer. [#666][]
14   -- Modify the Range Validator to support additional types and clean up the error output. [#690][]
15   -- Bugfix: The trigger on parse modifier did not work on positional argument.s [#713][]
16   -- Bugfix: The single header file generation was missing custom namespace generation. [#707][]
  5 +New features include support for output of an empty vector, a summing option
  6 +policy that can be applied more broadly, and an option to validate optional
  7 +arguments to discriminate from positional arguments. A new validator to check
  8 +for files on a default path is included to allow one or more default paths for
  9 +configuration files or other file arguments. A number of bug fixes and code
  10 +cleanup for various build configurations. Clean up of some error outputs and
  11 +extension of existing capability to new types or situations.
  12 +
  13 +There is a possible minor breaking change in behavior of certain types which
  14 +wrapped an integer, such as `std::atomic<int>` or `std::optional<int>` when used
  15 +in a flag. The default behavior is now as a single argument value vs. summing
  16 +all the arguments. The default summing behavior is now restricted to pure
  17 +integral types, int64_t, int, uint32_t, etc. Use the new `sum` multi option
  18 +policy to revert to the older behavior. The summing behavior on wrapper types
  19 +was not originally intended.
  20 +
  21 +- Add `MultiOptionPolicy::Sum` and refactor the `add_flag` to fix a bug when
  22 + using `std::optional<bool>` as type. [#709][]
  23 +- Add support for an empty vector result in TOML and as a default string.
  24 + [#660][]
  25 +- Add `.validate_optional_arguments()` to support discriminating positional
  26 + arguments from vector option arguments. [#668][]
  27 +- Add `CLI::FileOnDefaultPath` to check for files on a specified default path.
  28 + [#698][]
  29 +- Change default value display in help messages from `=XXXX` to `[XXXXX]` to
  30 + make it clearer. [#666][]
  31 +- Modify the Range Validator to support additional types and clean up the error
  32 + output. [#690][]
  33 +- Bugfix: The trigger on parse modifier did not work on positional argument.s
  34 + [#713][]
  35 +- Bugfix: The single header file generation was missing custom namespace
  36 + generation. [#707][]
17 37 - Bugfix: Clean up File Error handling in the argument processing. [#678][]
18   -- Bugfix: Fix a stack overflow error if nameless commands had fallthrough. [#665][]
19   -- Bugfix: A subcommand callback could be executed multiple times if it was a member of an option group. [#666][]
20   -- Bugfix: Fix an issue with vectors of multi argument types where partial argument sets did not result in an error. [#661][]
21   -- Bugfix: Fix an issue with type the template matching on C++20 and add some CI builds for C++20. [#663][]
  38 +- Bugfix: Fix a stack overflow error if nameless commands had fallthrough.
  39 + [#665][]
  40 +- Bugfix: A subcommand callback could be executed multiple times if it was a
  41 + member of an option group. [#666][]
  42 +- Bugfix: Fix an issue with vectors of multi argument types where partial
  43 + argument sets did not result in an error. [#661][]
  44 +- Bugfix: Fix an issue with type the template matching on C++20 and add some CI
  45 + builds for C++20. [#663][]
22 46 - Bugfix: Fix typo in C++20 detection on MSVC. [#706][]
23   -- Bugfix: An issue where the detection of RTTI being disabled on certain MSVC platforms did not disable the use of dynamic cast calls. [#666][]
  47 +- Bugfix: An issue where the detection of RTTI being disabled on certain MSVC
  48 + platforms did not disable the use of dynamic cast calls. [#666][]
24 49 - Bugfix: Resolve strict-overflow warning on some GCC compilers. [#666][]
25   -- Backend: Add additional tests concerning the use of aliases for option groups in config files. [#666][]
26   -- Build: Add support for testing in meson and cleanup symbolic link generation. [#701][], [#697][]
  50 +- Backend: Add additional tests concerning the use of aliases for option groups
  51 + in config files. [#666][]
  52 +- Build: Add support for testing in meson and cleanup symbolic link generation.
  53 + [#701][], [#697][]
27 54 - Build: Support building in WebAssembly. [#679][]
28 55  
29 56 [#660]: https://github.com/CLIUtils/CLI11/pull/660
... ... @@ -49,15 +76,21 @@ The name restrictions for options and subcommands are now much looser, allowing
49 76 a wider variety of characters than before, even spaces can be used (use quotes
50 77 to include a space in most shells). The default configuration parser was
51 78 improved, allowing your configuration to sit in a larger file. And option
52   -callbacks have a few new settings, allowing them to be run even if the option
53   -is not passed, or every time the option is parsed.
54   -
55   -- Option/subcommand name restrictions have been relaxed. Most characters are now allowed. [#627][]
56   -- The config parser can accept streams, specify a specific section, and inline comment characters are supported [#630][]
57   -- `force_callback` & `trigger_on_parse` added, allowing a callback to always run on parse even if not present or every time the option is parsed [#631][]
58   -- Bugfix(cmake): Only add `CONFIGURE_DEPENDS` if CLI11 is the main project [#633][]
59   -- Bugfix(cmake): Ensure the cmake/pkg-config files install to a arch independent path [#635][]
60   -- Bugfix: The single header file generation was missing the include guard. [#620][]
  79 +callbacks have a few new settings, allowing them to be run even if the option is
  80 +not passed, or every time the option is parsed.
  81 +
  82 +- Option/subcommand name restrictions have been relaxed. Most characters are now
  83 + allowed. [#627][]
  84 +- The config parser can accept streams, specify a specific section, and inline
  85 + comment characters are supported [#630][]
  86 +- `force_callback` & `trigger_on_parse` added, allowing a callback to always run
  87 + on parse even if not present or every time the option is parsed [#631][]
  88 +- Bugfix(cmake): Only add `CONFIGURE_DEPENDS` if CLI11 is the main project
  89 + [#633][]
  90 +- Bugfix(cmake): Ensure the cmake/pkg-config files install to a arch independent
  91 + path [#635][]
  92 +- Bugfix: The single header file generation was missing the include guard.
  93 + [#620][]
61 94  
62 95 [#620]: https://github.com/CLIUtils/CLI11/pull/620
63 96 [#627]: https://github.com/CLIUtils/CLI11/pull/627
... ... @@ -70,7 +103,8 @@ is not passed, or every time the option is parsed.
70 103  
71 104 - A collision with `min`/`max` macros on Windows has been fixed. [#642][]
72 105 - Tests pass with Boost again [#646][]
73   -- Running the pre-commit hooks in development no longer requires docker for clang-format [#647][]
  106 +- Running the pre-commit hooks in development no longer requires docker for
  107 + clang-format [#647][]
74 108  
75 109 [#642]: https://github.com/CLIUtils/CLI11/pull/642
76 110 [#646]: https://github.com/CLIUtils/CLI11/pull/646
... ... @@ -92,11 +126,11 @@ is not passed, or every time the option is parsed.
92 126  
93 127 This version focuses on cleaning up deprecated functionality, and some minor
94 128 default changes. The config processing is TOML compliant now. Atomics and
95   -complex numbers are directly supported, along with other container
96   -improvements. A new version flag option has finally been added. Subcommands are
97   -significantly improved with new features and bugfixes for corner cases. This
98   -release contains a lot of backend cleanup, including a complete overhaul of the
99   -testing system and single file generation system.
  129 +complex numbers are directly supported, along with other container improvements.
  130 +A new version flag option has finally been added. Subcommands are significantly
  131 +improved with new features and bugfixes for corner cases. This release contains
  132 +a lot of backend cleanup, including a complete overhaul of the testing system
  133 +and single file generation system.
100 134  
101 135 - Built-in config format is TOML compliant now [#435][]
102 136 - Support multiline TOML [#528][]
... ... @@ -109,13 +143,15 @@ testing system and single file generation system.
109 143 - Support `->silent()` on subcommands. [#529][]
110 144 - Add alias section to help for subcommands [#545][]
111 145 - Allow quotes to specify a program name [#605][]
112   -- Backend: redesigned MakeSingleFiles to have a higher level of manual control, to support future features. [#546][]
  146 +- Backend: redesigned MakeSingleFiles to have a higher level of manual control,
  147 + to support future features. [#546][]
113 148 - Backend: moved testing from GTest to Catch2 [#574][]
114 149 - Bugfix: avoid duplicated and missed calls to the final callback [#584][]
115 150 - Bugfix: support embedded newlines in more places [#592][]
116 151 - Bugfix: avoid listing helpall as a required flag [#530][]
117 152 - Bugfix: avoid a clash with WINDOWS define [#563][]
118   -- Bugfix: the help flag didn't get processed when a config file was required [#606][]
  153 +- Bugfix: the help flag didn't get processed when a config file was required
  154 + [#606][]
119 155 - Bugfix: fix description of non-configurable subcommands in config [#604][]
120 156 - Build: support pkg-config [#523][]
121 157  
... ... @@ -123,9 +159,10 @@ testing system and single file generation system.
123 159 >
124 160 > - Removed deprecated set commands, use validators instead. [#565][]
125 161 > - The final "defaulted" bool has been removed, use `->capture_default_str()`
126   -> instead. Use `app.option_defaults()->always_capture_default()` to set this for
127   -> all future options. [#597][]
128   -> - Use `add_option` on a complex number instead of `add_complex`, which has been removed.
  162 +> instead. Use `app.option_defaults()->always_capture_default()` to set this
  163 +> for all future options. [#597][]
  164 +> - Use `add_option` on a complex number instead of `add_complex`, which has
  165 +> been removed.
129 166  
130 167 [#423]: https://github.com/CLIUtils/CLI11/pull/423
131 168 [#435]: https://github.com/CLIUtils/CLI11/pull/435
... ... @@ -153,23 +190,30 @@ testing system and single file generation system.
153 190  
154 191 ## Version 1.9: Config files and cleanup
155 192  
156   -Config file handling was revamped to fix common issues, and now supports reading [TOML](https://github.com/toml-lang/toml).
  193 +Config file handling was revamped to fix common issues, and now supports reading
  194 +[TOML](https://github.com/toml-lang/toml).
157 195  
158 196 Adding options is significantly more powerful with support for things like
159 197 `std::tuple` and `std::array`, including with transforms. Several new
160   -configuration options were added to facilitate a wider variety of apps. GCC
161   -4.7 is no longer supported.
  198 +configuration options were added to facilitate a wider variety of apps. GCC 4.7
  199 +is no longer supported.
162 200  
163   -- Config files refactored, supports TOML (may become default output in 2.0) [#362][]
164   -- Added two template parameter form of `add_option`, allowing `std::optional` to be supported without a special import [#285][]
  201 +- Config files refactored, supports TOML (may become default output in 2.0)
  202 + [#362][]
  203 +- Added two template parameter form of `add_option`, allowing `std::optional` to
  204 + be supported without a special import [#285][]
165 205 - `string_view` now supported in reasonable places [#300][], [#285][]
166   -- `immediate_callback`, `final_callback`, and `parse_complete_callback` added to support controlling the App callback order [#292][], [#313][]
167   -- Multiple positional arguments maintain order if `positionals_at_end` is set. [#306][]
168   -- Pair/tuple/array now supported, and validators indexed to specific components in the objects [#307][], [#310][]
  206 +- `immediate_callback`, `final_callback`, and `parse_complete_callback` added to
  207 + support controlling the App callback order [#292][], [#313][]
  208 +- Multiple positional arguments maintain order if `positionals_at_end` is set.
  209 + [#306][]
  210 +- Pair/tuple/array now supported, and validators indexed to specific components
  211 + in the objects [#307][], [#310][]
169 212 - Footer callbacks supported [#309][]
170 213 - Subcommands now support needs (including nameless subcommands) [#317][]
171 214 - More flexible type size, more useful `add_complex` [#325][], [#370][]
172   -- Added new validators `CLI::NonNegativeNumber` and `CLI::PositiveNumber` [#342][]
  215 +- Added new validators `CLI::NonNegativeNumber` and `CLI::PositiveNumber`
  216 + [#342][]
173 217 - Transform now supports arrays [#349][]
174 218 - Option groups can be hidden [#356][]
175 219 - Add `CLI::deprecate_option` and `CLI::retire_option` functions [#358][]
... ... @@ -178,23 +222,29 @@ configuration options were added to facilitate a wider variety of apps. GCC
178 222 - Backend: File checking updates [#341][]
179 223 - Backend: Using pre-commit to format, checked in GitHub Actions [#336][]
180 224 - Backend: Clang-tidy checked again, CMake option now `CL11_CLANG_TIDY` [#390][]
181   -- Backend: Warning cleanup, more checks from klocwork [#350][], Effective C++ [#354][], clang-tidy [#360][], CUDA NVCC [#365][], cross compile [#373][], sign conversion [#382][], and cpplint [#400][]
182   -- Docs: CLI11 Tutorial now hosted in the same repository [#304][], [#318][], [#374][]
  225 +- Backend: Warning cleanup, more checks from klocwork [#350][], Effective C++
  226 + [#354][], clang-tidy [#360][], CUDA NVCC [#365][], cross compile [#373][],
  227 + sign conversion [#382][], and cpplint [#400][]
  228 +- Docs: CLI11 Tutorial now hosted in the same repository [#304][], [#318][],
  229 + [#374][]
183 230 - Bugfix: Fixed undefined behavior in `checked_multiply` [#290][]
184 231 - Bugfix: `->check()` was adding the name to the wrong validator [#320][]
185 232 - Bugfix: Resetting config option works properly [#301][]
186 233 - Bugfix: Hidden flags were showing up in error printout [#333][]
187 234 - Bugfix: Enum conversion no longer broken if stream operator added [#348][]
188 235 - Build: The meson build system supported [#299][]
189   -- Build: GCC 4.7 is no longer supported, due mostly to GoogleTest. GCC 4.8+ is now required. [#160][]
  236 +- Build: GCC 4.7 is no longer supported, due mostly to GoogleTest. GCC 4.8+ is
  237 + now required. [#160][]
190 238 - Build: Restructured significant portions of CMake build system [#394][]
191 239  
192 240 > ### Converting from CLI11 1.8
193 241 >
194 242 > - Some deprecated methods dropped
195   -> - `add_set*` should be replaced with `->check`/`->transform` and `CLI::IsMember` since 1.8
  243 +> - `add_set*` should be replaced with `->check`/`->transform` and
  244 +> `CLI::IsMember` since 1.8
196 245 > - `get_defaultval` was replaced by `get_default_str` in 1.8
197   -> - The true/false 4th argument to `add_option` is expected to be removed in 2.0, use `->capture_default_str()` since 1.8
  246 +> - The true/false 4th argument to `add_option` is expected to be removed in
  247 +> 2.0, use `->capture_default_str()` since 1.8
198 248  
199 249 [#160]: https://github.com/CLIUtils/CLI11/pull/160
200 250 [#285]: https://github.com/CLIUtils/CLI11/pull/285
... ... @@ -258,41 +308,73 @@ This is a patch version that backports fixes from the development of 2.0.
258 308  
259 309 ## Version 1.8: Transformers, default strings, and flags
260 310  
261   -Set handling has been completely replaced by a new backend that works as a Validator or Transformer. This provides a single interface instead of the 16 different functions in App. It also allows ordered collections to be used, custom functions for filtering, and better help and error messages. You can also use a collection of pairs (like `std::map`) to transform the match into an output. Also new are inverted flags, which can cancel or reduce the count of flags, and can also support general flag types. A new `add_option_fn` lets you more easily program CLI11 options with the types you choose. Vector options now support a custom separator. Apps can now be composed with unnamed subcommand support. The final bool "defaults" flag when creating options has been replaced by `->capture_default_str()` (ending an old limitation in construction made this possible); the old method is still available but may be removed in future versions.
262   -
263   -- Replaced default help capture: `.add_option("name", value, "", True)` becomes `.add_option("name", value)->capture_default_str()` [#242][]
  311 +Set handling has been completely replaced by a new backend that works as a
  312 +Validator or Transformer. This provides a single interface instead of the 16
  313 +different functions in App. It also allows ordered collections to be used,
  314 +custom functions for filtering, and better help and error messages. You can also
  315 +use a collection of pairs (like `std::map`) to transform the match into an
  316 +output. Also new are inverted flags, which can cancel or reduce the count of
  317 +flags, and can also support general flag types. A new `add_option_fn` lets you
  318 +more easily program CLI11 options with the types you choose. Vector options now
  319 +support a custom separator. Apps can now be composed with unnamed subcommand
  320 +support. The final bool "defaults" flag when creating options has been replaced
  321 +by `->capture_default_str()` (ending an old limitation in construction made this
  322 +possible); the old method is still available but may be removed in future
  323 +versions.
  324 +
  325 +- Replaced default help capture: `.add_option("name", value, "", True)` becomes
  326 + `.add_option("name", value)->capture_default_str()` [#242][]
264 327 - Added `.always_capture_default()` [#242][]
265 328 - New `CLI::IsMember` validator replaces set validation [#222][]
266   -- `IsMember` also supports container of pairs, transform allows modification of result [#228][]
267   -- Added new Transformers, `CLI::AsNumberWithUnit` and `CLI::AsSizeValue` [#253][]
268   -- Much more powerful flags with different values [#211][], general types [#235][]
  329 +- `IsMember` also supports container of pairs, transform allows modification of
  330 + result [#228][]
  331 +- Added new Transformers, `CLI::AsNumberWithUnit` and `CLI::AsSizeValue`
  332 + [#253][]
  333 +- Much more powerful flags with different values [#211][], general types
  334 + [#235][]
269 335 - `add_option` now supports bool due to unified bool handling [#211][]
270 336 - Support for composable unnamed subcommands [#216][]
271 337 - Reparsing is better supported with `.remaining_for_passthrough()` [#265][]
272 338 - Custom vector separator using `->delimiter(char)` [#209][], [#221][], [#240][]
273   -- Validators added for IP4 addresses and positive numbers [#210][] and numbers [#262][]
274   -- Minimum required Boost for optional Optionals has been corrected to 1.61 [#226][]
275   -- Positionals can stop options from being parsed with `app.positionals_at_end()` [#223][]
  339 +- Validators added for IP4 addresses and positive numbers [#210][] and numbers
  340 + [#262][]
  341 +- Minimum required Boost for optional Optionals has been corrected to 1.61
  342 + [#226][]
  343 +- Positionals can stop options from being parsed with `app.positionals_at_end()`
  344 + [#223][]
276 345 - Added `validate_positionals` [#262][]
277   -- Positional parsing is much more powerful [#251][], duplicates supported [#247][]
278   -- Validators can be negated with `!` [#230][], and now handle tname functions [#228][]
  346 +- Positional parsing is much more powerful [#251][], duplicates supported
  347 + [#247][]
  348 +- Validators can be negated with `!` [#230][], and now handle tname functions
  349 + [#228][]
279 350 - Better enum support and streaming helper [#233][] and [#228][]
280 351 - Cleanup for shadow warnings [#232][]
281 352 - Better alignment on multiline descriptions [#269][]
282 353 - Better support for aarch64 [#266][]
283   -- Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise, `CLI11_TESTING` must be used [#277][]
284   -- Drop auto-detection of experimental optional and boost::optional; must be enabled explicitly (too fragile) [#277][] [#279][]
  354 +- Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise,
  355 + `CLI11_TESTING` must be used [#277][]
  356 +- Drop auto-detection of experimental optional and boost::optional; must be
  357 + enabled explicitly (too fragile) [#277][] [#279][]
285 358  
286 359 > ### Converting from CLI11 1.7
287 360 >
288   -> - `.add_option(..., true)` should be replaced by `.add_option(...)->capture_default_str()` or `app.option_defaults()->always_capture_default()` can be used
289   -> - `app.add_set("--name", value, {"choice1", "choice2"})` should become `app.add_option("--name", value)->check(CLI::IsMember({"choice1", "choice2"}))`
290   -> - The `_ignore_case` version of this can be replaced by adding `CLI::ignore_case` to the argument list in `IsMember`
291   -> - The `_ignore_underscore` version of this can be replaced by adding `CLI::ignore_underscore` to the argument list in `IsMember`
292   -> - The `_ignore_case_underscore` version of this can be replaced by adding both functions listed above to the argument list in `IsMember`
293   -> - If you want an exact match to the original choice after one of the modifier functions matches, use `->transform` instead of `->check`
294   -> - The `_mutable` versions of this can be replaced by passing a pointer or shared pointer into `IsMember`
295   -> - An error with sets now produces a `ValidationError` instead of a `ConversionError`
  361 +> - `.add_option(..., true)` should be replaced by
  362 +> `.add_option(...)->capture_default_str()` or
  363 +> `app.option_defaults()->always_capture_default()` can be used
  364 +> - `app.add_set("--name", value, {"choice1", "choice2"})` should become
  365 +> `app.add_option("--name", value)->check(CLI::IsMember({"choice1", "choice2"}))`
  366 +> - The `_ignore_case` version of this can be replaced by adding
  367 +> `CLI::ignore_case` to the argument list in `IsMember`
  368 +> - The `_ignore_underscore` version of this can be replaced by adding
  369 +> `CLI::ignore_underscore` to the argument list in `IsMember`
  370 +> - The `_ignore_case_underscore` version of this can be replaced by adding both
  371 +> functions listed above to the argument list in `IsMember`
  372 +> - If you want an exact match to the original choice after one of the modifier
  373 +> functions matches, use `->transform` instead of `->check`
  374 +> - The `_mutable` versions of this can be replaced by passing a pointer or
  375 +> shared pointer into `IsMember`
  376 +> - An error with sets now produces a `ValidationError` instead of a
  377 +> `ConversionError`
296 378  
297 379 [#209]: https://github.com/CLIUtils/CLI11/pull/209
298 380 [#210]: https://github.com/CLIUtils/CLI11/pull/210
... ... @@ -321,29 +403,50 @@ Set handling has been completely replaced by a new backend that works as a Valid
321 403  
322 404 ## Version 1.7: Parse breakup
323 405  
324   -The parsing procedure now maps much more sensibly to complex, nested subcommand structures. Each phase of the parsing happens on all subcommands before moving on with the next phase of the parse. This allows several features, like required environment variables, to work properly even through subcommand boundaries.
325   -Passing the same subcommand multiple times is better supported. Several new features were added as well, including Windows style option support, parsing strings directly, and ignoring underscores in names. Adding a set that you plan to change later must now be done with `add_mutable_set`.
326   -
327   -- Support Windows style options with `->allow_windows_style_options`. [#187][] On by default on Windows. [#190][]
328   -- Added `parse(string)` to split up and parse a command-line style string directly. [#186][]
329   -- Added `ignore_underscore` and related functions, to ignore underscores when matching names. [#185][]
  406 +The parsing procedure now maps much more sensibly to complex, nested subcommand
  407 +structures. Each phase of the parsing happens on all subcommands before moving
  408 +on with the next phase of the parse. This allows several features, like required
  409 +environment variables, to work properly even through subcommand boundaries.
  410 +Passing the same subcommand multiple times is better supported. Several new
  411 +features were added as well, including Windows style option support, parsing
  412 +strings directly, and ignoring underscores in names. Adding a set that you plan
  413 +to change later must now be done with `add_mutable_set`.
  414 +
  415 +- Support Windows style options with `->allow_windows_style_options`. [#187][]
  416 + On by default on Windows. [#190][]
  417 +- Added `parse(string)` to split up and parse a command-line style string
  418 + directly. [#186][]
  419 +- Added `ignore_underscore` and related functions, to ignore underscores when
  420 + matching names. [#185][]
330 421 - The default INI Config will now add quotes to strings with spaces [#195][]
331   -- The default message now will mention the help-all flag also if present [#197][]
  422 +- The default message now will mention the help-all flag also if present
  423 + [#197][]
332 424 - Added `->description` to set Option descriptions [#199][]
333   -- Mutating sets (introduced in Version 1.6) now have a clear add method, `add_mutable_set*`, since the set reference should not expire [#200][]
334   -- Subcommands now track how many times they were parsed in a parsing process. `count()` with no arguments will return the number of times a subcommand was encountered. [#178][]
335   -- Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#178][]
336   -- Calling parse multiple times is now officially supported without `clear` (automatic). [#178][]
337   -- Dropped the mostly undocumented `short_circuit` property, as help flag parsing is a bit more complex, and the default callback behavior of options now works properly. [#179][]
  425 +- Mutating sets (introduced in Version 1.6) now have a clear add method,
  426 + `add_mutable_set*`, since the set reference should not expire [#200][]
  427 +- Subcommands now track how many times they were parsed in a parsing process.
  428 + `count()` with no arguments will return the number of times a subcommand was
  429 + encountered. [#178][]
  430 +- Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and
  431 + `requirements`; all subcommands complete a phase before moving on. [#178][]
  432 +- Calling parse multiple times is now officially supported without `clear`
  433 + (automatic). [#178][]
  434 +- Dropped the mostly undocumented `short_circuit` property, as help flag parsing
  435 + is a bit more complex, and the default callback behavior of options now works
  436 + properly. [#179][]
338 437 - Use the standard `BUILD_TESTING` over `CLI11_TESTING` if defined [#183][]
339 438 - Cleanup warnings [#191][]
340   -- Remove deprecated names: `set_footer`, `set_name`, `set_callback`, and `set_type_name`. Use without the `set_` instead. [#192][]
  439 +- Remove deprecated names: `set_footer`, `set_name`, `set_callback`, and
  440 + `set_type_name`. Use without the `set_` instead. [#192][]
341 441  
342 442 > ### Converting from CLI11 1.6
343 443 >
344   -> - `->short_circuit()` is no longer needed, just remove it if you were using it - raising an exception will happen in the proper place now without it.
345   -> - `->add_set*` becomes `->add_mutable_set*` if you were using the editable set feature
346   -> - `footer`, `name`, `callback`, and `type_name` must be used instead of the `set_*` versions (deprecated previously).
  444 +> - `->short_circuit()` is no longer needed, just remove it if you were using
  445 +> it - raising an exception will happen in the proper place now without it.
  446 +> - `->add_set*` becomes `->add_mutable_set*` if you were using the editable set
  447 +> feature
  448 +> - `footer`, `name`, `callback`, and `type_name` must be used instead of the
  449 +> `set_*` versions (deprecated previously).
347 450  
348 451 [#178]: https://github.com/CLIUtils/CLI11/pull/178
349 452 [#183]: https://github.com/CLIUtils/CLI11/pull/183
... ... @@ -360,7 +463,8 @@ Passing the same subcommand multiple times is better supported. Several new feat
360 463  
361 464 ### Version 1.7.1: Quick patch
362 465  
363   -This version provides a quick patch for a (correct) warning from GCC 8 for the windows options code.
  466 +This version provides a quick patch for a (correct) warning from GCC 8 for the
  467 +windows options code.
364 468  
365 469 - Fix for Windows style option parsing [#201][]
366 470 - Improve `add_subcommand` when throwing an exception [#204][]
... ... @@ -372,7 +476,9 @@ This version provides a quick patch for a (correct) warning from GCC 8 for the w
372 476  
373 477 ## Version 1.6: Formatting help
374 478  
375   -Added a new formatting system [#109][]. You can now set the formatter on Apps. This has also simplified the internals of Apps and Options a bit by separating most formatting code.
  479 +Added a new formatting system [#109][]. You can now set the formatter on Apps.
  480 +This has also simplified the internals of Apps and Options a bit by separating
  481 +most formatting code.
376 482  
377 483 - Added `CLI::Formatter` and `formatter` slot for apps, inherited.
378 484 - `FormatterBase` is the minimum required.
... ... @@ -387,7 +493,8 @@ Changes to the help system (most normal users will not notice this):
387 493 - Removed `help_*` functions.
388 494 - Protected function `_has_help_positional` removed.
389 495 - `format_help` can now be chained.
390   -- Added getters for the missing parts of options (help no longer uses any private parts).
  496 +- Added getters for the missing parts of options (help no longer uses any
  497 + private parts).
391 498 - Help flags now use new `short_circuit` property to simplify parsing. [#121][]
392 499  
393 500 New for Config file reading and writing [#121][]:
... ... @@ -400,7 +507,8 @@ New for Config file reading and writing [#121][]:
400 507 - Added `ConfigItem`.
401 508 - Added an example of a custom config format using [nlohmann/json][]. [#138][]
402 509  
403   -Validators are now much more powerful [#118][], all built in validators upgraded to the new form:
  510 +Validators are now much more powerful [#118][], all built in validators upgraded
  511 +to the new form:
404 512  
405 513 - A subclass of `CLI::Validator` is now also accepted.
406 514 - They now can set the type name to things like `PATH` and `INT in [1-4]`.
... ... @@ -410,24 +518,32 @@ Validators are now much more powerful [#118][], all built in validators upgraded
410 518 Other changes:
411 519  
412 520 - Fixing `parse(args)`'s `args` setting and ordering after parse. [#141][]
413   -- Replaced `set_custom_option` with `type_name` and `type_size` instead of `set_custom_option`. Methods return `this`. [#136][]
414   -- Dropped `set_` on Option's `type_name`, `default_str`, and `default_val`. [#136][]
415   -- Removed `set_` from App's `failure_message`, `footer`, `callback`, and `name`. [#136][]
  521 +- Replaced `set_custom_option` with `type_name` and `type_size` instead of
  522 + `set_custom_option`. Methods return `this`. [#136][]
  523 +- Dropped `set_` on Option's `type_name`, `default_str`, and `default_val`.
  524 + [#136][]
  525 +- Removed `set_` from App's `failure_message`, `footer`, `callback`, and `name`.
  526 + [#136][]
416 527 - Fixed support `N<-1` for `type_size`. [#140][]
417 528 - Added `->each()` to make adding custom callbacks easier. [#126][]
418   -- Allow empty options `add_option("-n",{})` to be edited later with `each` [#142][]
419   -- Added filter argument to `get_subcommands`, `get_options`; use empty filter `{}` to avoid filtering.
  529 +- Allow empty options `add_option("-n",{})` to be edited later with `each`
  530 + [#142][]
  531 +- Added filter argument to `get_subcommands`, `get_options`; use empty filter
  532 + `{}` to avoid filtering.
420 533 - Added `get_groups()` to get groups.
421   -- Better support for manual options with `get_option`, `set_results`, and `empty`. [#119][]
  534 +- Better support for manual options with `get_option`, `set_results`, and
  535 + `empty`. [#119][]
422 536 - `lname` and `sname` have getters, added `const get_parent`. [#120][]
423   -- Using `add_set` will now capture L-values for sets, allowing further modification. [#113][]
  537 +- Using `add_set` will now capture L-values for sets, allowing further
  538 + modification. [#113][]
424 539 - Dropped duplicate way to run `get_type_name` (`get_typeval`).
425 540 - Removed `requires` in favor of `needs` (deprecated in last version). [#112][]
426 541 - Const added to argv. [#126][]
427 542  
428 543 Backend and testing changes:
429 544  
430   -- Internally, `type_name` is now a lambda function; for sets, this reads the set live. [#116][]
  545 +- Internally, `type_name` is now a lambda function; for sets, this reads the set
  546 + live. [#116][]
431 547 - Cleaner tests without `app.reset()` (and `reset` is now `clear`). [#141][]
432 548 - Better CMake policy handling. [#110][]
433 549 - Includes are properly sorted. [#120][]
... ... @@ -453,12 +569,14 @@ Backend and testing changes:
453 569  
454 570 ### Version 1.6.1: Platform fixes
455 571  
456   -This version provides a few fixes for special cases, such as mixing with `Windows.h` and better defaults
457   -for systems like Hunter. The one new feature is the ability to produce "branded" single file output for
458   -providing custom namespaces or custom macro names.
  572 +This version provides a few fixes for special cases, such as mixing with
  573 +`Windows.h` and better defaults for systems like Hunter. The one new feature is
  574 +the ability to produce "branded" single file output for providing custom
  575 +namespaces or custom macro names.
459 576  
460 577 - Added fix and test for including Windows.h [#145][]
461   -- No longer build single file by default if main project, supports systems stuck on Python 2.6 [#149][], [#151][]
  578 +- No longer build single file by default if main project, supports systems stuck
  579 + on Python 2.6 [#149][], [#151][]
462 580 - Branding support for single file output [#150][]
463 581  
464 582 [#145]: https://github.com/CLIUtils/CLI11/pull/145
... ... @@ -468,18 +586,22 @@ providing custom namespaces or custom macro names.
468 586  
469 587 ### Version 1.6.2: Help-all
470 588  
471   -This version fixes some formatting bugs with help-all. It also adds fixes for several warnings, including an experimental optional error on Clang 7. Several smaller fixes.
  589 +This version fixes some formatting bugs with help-all. It also adds fixes for
  590 +several warnings, including an experimental optional error on Clang 7. Several
  591 +smaller fixes.
472 592  
473 593 - Fixed help-all formatting [#163][]
474 594 - Printing help-all on nested command now fixed (App)
475 595 - Missing space after help-all restored (Default formatter)
476 596 - More detail printed on help all (Default formatter)
477   - - Help-all subcommands get indented with inner blank lines removed (Default formatter)
  597 + - Help-all subcommands get indented with inner blank lines removed (Default
  598 + formatter)
478 599 - `detail::find_and_replace` added to utilities
479 600 - Fixed CMake install as subproject with `CLI11_INSTALL` flag. [#156][]
480 601 - Fixed warning about local variable hiding class member with MSVC [#157][]
481 602 - Fixed compile error with default settings on Clang 7 and libc++ [#158][]
482   -- Fixed special case of `--help` on subcommands (general fix planned for 1.7) [#168][]
  603 +- Fixed special case of `--help` on subcommands (general fix planned for 1.7)
  604 + [#168][]
483 605 - Removing an option with links [#179][]
484 606  
485 607 [#156]: https://github.com/CLIUtils/CLI11/issues/156
... ... @@ -491,15 +613,24 @@ This version fixes some formatting bugs with help-all. It also adds fixes for se
491 613  
492 614 ## Version 1.5: Optionals
493 615  
494   -This version introduced support for optionals, along with clarification and examples of custom conversion overloads. Enums now have been dropped from the automatic conversion system, allowing explicit protection for out-of-range ints (or a completely custom conversion). This version has some internal cleanup and improved support for the newest compilers. Several bugs were fixed, as well.
  616 +This version introduced support for optionals, along with clarification and
  617 +examples of custom conversion overloads. Enums now have been dropped from the
  618 +automatic conversion system, allowing explicit protection for out-of-range ints
  619 +(or a completely custom conversion). This version has some internal cleanup and
  620 +improved support for the newest compilers. Several bugs were fixed, as well.
495 621  
496 622 Note: This is the final release with `requires`, please switch to `needs`.
497 623  
498   -- Fix unlimited short options eating two values before checking for positionals when no space present [#90][]
499   -- Symmetric exclude text when excluding options, exclude can be called multiple times [#64][]
500   -- Support for `std::optional`, `std::experimental::optional`, and `boost::optional` added if `__has_include` is supported [#95][]
501   -- All macros/CMake variables now start with `CLI11_` instead of just `CLI_` [#95][]
502   -- The internal stream was not being cleared before use in some cases. Fixed. [#95][]
  624 +- Fix unlimited short options eating two values before checking for positionals
  625 + when no space present [#90][]
  626 +- Symmetric exclude text when excluding options, exclude can be called multiple
  627 + times [#64][]
  628 +- Support for `std::optional`, `std::experimental::optional`, and
  629 + `boost::optional` added if `__has_include` is supported [#95][]
  630 +- All macros/CMake variables now start with `CLI11_` instead of just `CLI_`
  631 + [#95][]
  632 +- The internal stream was not being cleared before use in some cases. Fixed.
  633 + [#95][]
503 634 - Using an enum now requires explicit conversion overload [#97][]
504 635 - The separator `--` now is removed when it ends unlimited arguments [#100][]
505 636  
... ... @@ -510,8 +641,10 @@ Other, non-user facing changes:
510 641 - C++17 is now tested on supported platforms [#95][]
511 642 - Informational printout now added to CTest [#95][]
512 643 - Better single file generation [#95][]
513   -- Added support for GTest on MSVC 2017 (but not in C++17 mode, will need next version of GTest)
514   -- Types now have a specific size, separate from the expected number - cleaner and more powerful internally [#92][]
  644 +- Added support for GTest on MSVC 2017 (but not in C++17 mode, will need next
  645 + version of GTest)
  646 +- Types now have a specific size, separate from the expected number - cleaner
  647 + and more powerful internally [#92][]
515 648 - Examples now run as part of testing [#99][]
516 649  
517 650 [#64]: https://github.com/CLIUtils/CLI11/issues/64
... ... @@ -524,11 +657,15 @@ Other, non-user facing changes:
524 657  
525 658 ### Version 1.5.1: Access
526 659  
527   -This patch release adds better access to the App programmatically, to assist with writing custom converters to other formats. It also improves the help output, and uses a new feature in CLI11 1.5 to fix an old "quirk" in the way unlimited options and positionals interact.
  660 +This patch release adds better access to the App programmatically, to assist
  661 +with writing custom converters to other formats. It also improves the help
  662 +output, and uses a new feature in CLI11 1.5 to fix an old "quirk" in the way
  663 +unlimited options and positionals interact.
528 664  
529 665 - Make mixing unlimited positionals and options more intuitive [#102][]
530 666 - Add missing getters `get_options` and `get_description` to App [#105][]
531   -- The app name now can be set, and will override the auto name if present [#105][]
  667 +- The app name now can be set, and will override the auto name if present
  668 + [#105][]
532 669 - Add `(REQUIRED)` for required options [#104][]
533 670 - Print simple name for Needs/Excludes [#104][]
534 671 - Use Needs instead of Requires in help print [#104][]
... ... @@ -541,21 +678,30 @@ This patch release adds better access to the App programmatically, to assist wit
541 678  
542 679 ### Version 1.5.2: LICENSE in single header mode
543 680  
544   -This is a quick patch release that makes LICENSE part of the single header file, making it easier to include. Minor cleanup from codacy. No significant code changes from 1.5.1.
  681 +This is a quick patch release that makes LICENSE part of the single header file,
  682 +making it easier to include. Minor cleanup from codacy. No significant code
  683 +changes from 1.5.1.
545 684  
546 685 ### Version 1.5.3: Compiler compatibility
547 686  
548   -This version fixes older AppleClang compilers by removing the optimization for casting. The minimum version of Boost Optional supported has been clarified to be 1.58. CUDA 7.0 NVCC is now supported.
  687 +This version fixes older AppleClang compilers by removing the optimization for
  688 +casting. The minimum version of Boost Optional supported has been clarified to
  689 +be 1.58. CUDA 7.0 NVCC is now supported.
549 690  
550 691 ### Version 1.5.4: Optionals
551 692  
552   -This version fixes the optional search in the single file version; some macros were not yet defined when it did the search. You can define the `CLI11_*_OPTIONAL` macros to 0 if needed to eliminate the search.
  693 +This version fixes the optional search in the single file version; some macros
  694 +were not yet defined when it did the search. You can define the
  695 +`CLI11_*_OPTIONAL` macros to 0 if needed to eliminate the search.
553 696  
554 697 ## Version 1.4: More feedback
555 698  
556   -This version adds lots of smaller fixes and additions after the refactor in version 1.3. More ways to download and use CLI11 in CMake have been added. INI files have improved support.
  699 +This version adds lots of smaller fixes and additions after the refactor in
  700 +version 1.3. More ways to download and use CLI11 in CMake have been added. INI
  701 +files have improved support.
557 702  
558   -- Lexical cast is now more strict than before [#68][] and fails on overflow [#84][]
  703 +- Lexical cast is now more strict than before [#68][] and fails on overflow
  704 + [#84][]
559 705 - Added `get_parent()` to access the parent from a subcommand
560 706 - Added `ExistingPath` validator [#73][]
561 707 - `app.allow_ini_extras()` added to allow extras in INI files [#70][]
... ... @@ -564,7 +710,8 @@ This version adds lots of smaller fixes and additions after the refactor in vers
564 710 - Double printing of error message fixed [#77][]
565 711 - Renamed `requires` to `needs` to avoid C++20 keyword [#75][], [#82][]
566 712 - MakeSingleHeader now works if outside of git [#78][]
567   -- Adding install support for CMake [#79][], improved support for `find_package` [#83][], [#84][]
  713 +- Adding install support for CMake [#79][], improved support for `find_package`
  714 + [#83][], [#84][]
568 715 - Added support for Conan.io [#83][]
569 716  
570 717 [#70]: https://github.com/CLIUtils/CLI11/issues/70
... ... @@ -581,73 +728,128 @@ This version adds lots of smaller fixes and additions after the refactor in vers
581 728  
582 729 ## Version 1.3: Refactor
583 730  
584   -This version focused on refactoring several key systems to ensure correct behavior in the interaction of different settings. Most caveats about
585   -features only working on the main App have been addressed, and extra arguments have been reworked. Inheritance
586   -of defaults makes configuring CLI11 much easier without having to subclass. Policies add new ways to handle multiple arguments to match your
587   -favorite CLI programs. Error messages and help messages are better and more flexible. Several bugs and odd behaviors in the parser have been fixed.
588   -
589   -- Added a version macro, `CLI11_VERSION`, along with `*_MAJOR`, `*_MINOR`, and `*_PATCH`, for programmatic access to the version.
590   -- Reworked the way defaults are set and inherited; explicit control given to user with `->option_defaults()` [#48](https://github.com/CLIUtils/CLI11/pull/48)
591   -- Hidden options now are based on an empty group name, instead of special "hidden" keyword [#48](https://github.com/CLIUtils/CLI11/pull/48)
592   -- `parse` no longer returns (so `CLI11_PARSE` is always usable) [#37](https://github.com/CLIUtils/CLI11/pull/37)
593   -- Added `remaining()` and `remaining_size()` [#37](https://github.com/CLIUtils/CLI11/pull/37)
594   -- `allow_extras` and `prefix_command` are now valid on subcommands [#37](https://github.com/CLIUtils/CLI11/pull/37)
595   -- Added `take_last` to only take last value passed [#40](https://github.com/CLIUtils/CLI11/pull/40)
596   -- Added `multi_option_policy` and shortcuts to provide more control than just a take last policy [#59](https://github.com/CLIUtils/CLI11/pull/59)
597   -- More detailed error messages in a few cases [#41](https://github.com/CLIUtils/CLI11/pull/41)
  731 +This version focused on refactoring several key systems to ensure correct
  732 +behavior in the interaction of different settings. Most caveats about features
  733 +only working on the main App have been addressed, and extra arguments have been
  734 +reworked. Inheritance of defaults makes configuring CLI11 much easier without
  735 +having to subclass. Policies add new ways to handle multiple arguments to match
  736 +your favorite CLI programs. Error messages and help messages are better and more
  737 +flexible. Several bugs and odd behaviors in the parser have been fixed.
  738 +
  739 +- Added a version macro, `CLI11_VERSION`, along with `*_MAJOR`, `*_MINOR`, and
  740 + `*_PATCH`, for programmatic access to the version.
  741 +- Reworked the way defaults are set and inherited; explicit control given to
  742 + user with `->option_defaults()`
  743 + [#48](https://github.com/CLIUtils/CLI11/pull/48)
  744 +- Hidden options now are based on an empty group name, instead of special
  745 + "hidden" keyword [#48](https://github.com/CLIUtils/CLI11/pull/48)
  746 +- `parse` no longer returns (so `CLI11_PARSE` is always usable)
  747 + [#37](https://github.com/CLIUtils/CLI11/pull/37)
  748 +- Added `remaining()` and `remaining_size()`
  749 + [#37](https://github.com/CLIUtils/CLI11/pull/37)
  750 +- `allow_extras` and `prefix_command` are now valid on subcommands
  751 + [#37](https://github.com/CLIUtils/CLI11/pull/37)
  752 +- Added `take_last` to only take last value passed
  753 + [#40](https://github.com/CLIUtils/CLI11/pull/40)
  754 +- Added `multi_option_policy` and shortcuts to provide more control than just a
  755 + take last policy [#59](https://github.com/CLIUtils/CLI11/pull/59)
  756 +- More detailed error messages in a few cases
  757 + [#41](https://github.com/CLIUtils/CLI11/pull/41)
598 758 - Footers can be added to help [#42](https://github.com/CLIUtils/CLI11/pull/42)
599   -- Help flags are easier to customize [#43](https://github.com/CLIUtils/CLI11/pull/43)
  759 +- Help flags are easier to customize
  760 + [#43](https://github.com/CLIUtils/CLI11/pull/43)
600 761 - Subcommand now support groups [#46](https://github.com/CLIUtils/CLI11/pull/46)
601   -- `CLI::RuntimeError` added, for easy exit with error codes [#45](https://github.com/CLIUtils/CLI11/pull/45)
602   -- The clang-format script is now no longer "hidden" [#48](https://github.com/CLIUtils/CLI11/pull/48)
603   -- The order is now preserved for subcommands (list and callbacks) [#49](https://github.com/CLIUtils/CLI11/pull/49)
604   -- Tests now run individually, utilizing CMake 3.10 additions if possible [#50](https://github.com/CLIUtils/CLI11/pull/50)
605   -- Failure messages are now customizable, with a shorter default [#52](https://github.com/CLIUtils/CLI11/pull/52)
606   -- Some improvements to error codes [#53](https://github.com/CLIUtils/CLI11/pull/53)
607   -- `require_subcommand` now offers a two-argument form and negative values on the one-argument form are more useful [#51](https://github.com/CLIUtils/CLI11/pull/51)
608   -- Subcommands no longer match after the max required number is obtained [#51](https://github.com/CLIUtils/CLI11/pull/51)
609   -- Unlimited options no longer prioritize over remaining/unlimited positionals [#51](https://github.com/CLIUtils/CLI11/pull/51)
610   -- Added `->transform` which modifies the string parsed [#54](https://github.com/CLIUtils/CLI11/pull/54)
611   -- Changed of API in validators to `void(std::string &)` (const for users), throwing providing nicer errors [#54](https://github.com/CLIUtils/CLI11/pull/54)
612   -- Added `CLI::ArgumentMismatch` [#56](https://github.com/CLIUtils/CLI11/pull/56) and fixed missing failure if one arg expected [#55](https://github.com/CLIUtils/CLI11/issues/55)
613   -- Support for minimum unlimited expected arguments [#56](https://github.com/CLIUtils/CLI11/pull/56)
614   -- Single internal arg parse function [#56](https://github.com/CLIUtils/CLI11/pull/56)
615   -- Allow options to be disabled from INI file, rename `add_config` to `set_config` [#60](https://github.com/CLIUtils/CLI11/pull/60)
  762 +- `CLI::RuntimeError` added, for easy exit with error codes
  763 + [#45](https://github.com/CLIUtils/CLI11/pull/45)
  764 +- The clang-format script is now no longer "hidden"
  765 + [#48](https://github.com/CLIUtils/CLI11/pull/48)
  766 +- The order is now preserved for subcommands (list and callbacks)
  767 + [#49](https://github.com/CLIUtils/CLI11/pull/49)
  768 +- Tests now run individually, utilizing CMake 3.10 additions if possible
  769 + [#50](https://github.com/CLIUtils/CLI11/pull/50)
  770 +- Failure messages are now customizable, with a shorter default
  771 + [#52](https://github.com/CLIUtils/CLI11/pull/52)
  772 +- Some improvements to error codes
  773 + [#53](https://github.com/CLIUtils/CLI11/pull/53)
  774 +- `require_subcommand` now offers a two-argument form and negative values on the
  775 + one-argument form are more useful
  776 + [#51](https://github.com/CLIUtils/CLI11/pull/51)
  777 +- Subcommands no longer match after the max required number is obtained
  778 + [#51](https://github.com/CLIUtils/CLI11/pull/51)
  779 +- Unlimited options no longer prioritize over remaining/unlimited positionals
  780 + [#51](https://github.com/CLIUtils/CLI11/pull/51)
  781 +- Added `->transform` which modifies the string parsed
  782 + [#54](https://github.com/CLIUtils/CLI11/pull/54)
  783 +- Changed of API in validators to `void(std::string &)` (const for users),
  784 + throwing providing nicer errors
  785 + [#54](https://github.com/CLIUtils/CLI11/pull/54)
  786 +- Added `CLI::ArgumentMismatch` [#56](https://github.com/CLIUtils/CLI11/pull/56)
  787 + and fixed missing failure if one arg expected
  788 + [#55](https://github.com/CLIUtils/CLI11/issues/55)
  789 +- Support for minimum unlimited expected arguments
  790 + [#56](https://github.com/CLIUtils/CLI11/pull/56)
  791 +- Single internal arg parse function
  792 + [#56](https://github.com/CLIUtils/CLI11/pull/56)
  793 +- Allow options to be disabled from INI file, rename `add_config` to
  794 + `set_config` [#60](https://github.com/CLIUtils/CLI11/pull/60)
616 795  
617 796 > ### Converting from CLI11 1.2
618 797 >
619 798 > - `app.parse` no longer returns a vector. Instead, use `app.remaining(true)`.
620 799 > - `"hidden"` is no longer a special group name, instead use `""`
621   -> - Validators API has changed to return an error string; use `.empty()` to get the old bool back
622   -> - Use `.set_help_flag` instead of accessing the help pointer directly (discouraged, but not removed yet)
  800 +> - Validators API has changed to return an error string; use `.empty()` to get
  801 +> the old bool back
  802 +> - Use `.set_help_flag` instead of accessing the help pointer directly
  803 +> (discouraged, but not removed yet)
623 804 > - `add_config` has been renamed to `set_config`
624 805 > - Errors thrown in some cases are slightly more specific
625 806  
626 807 ## Version 1.2: Stability
627 808  
628   -This release focuses on making CLI11 behave properly in corner cases, and with config files on the command line. This includes fixes for a variety of reported issues. A few features were added to make life easier, as well; such as a new flag callback and a macro for the parse command.
629   -
630   -- Added functional form of flag [#33](https://github.com/CLIUtils/CLI11/pull/33), automatic on C++14
631   -- Fixed Config file search if passed on command line [#30](https://github.com/CLIUtils/CLI11/issues/30)
632   -- Added `CLI11_PARSE(app, argc, argv)` macro for simple parse commands (does not support returning arg)
633   -- The name string can now contain spaces around commas [#29](https://github.com/CLIUtils/CLI11/pull/29)
634   -- `set_default_str` now only sets string, and `set_default_val` will evaluate the default string given [#26](https://github.com/CLIUtils/CLI11/issues/26)
635   -- Required positionals now take priority over subcommands [#23](https://github.com/CLIUtils/CLI11/issues/23)
  809 +This release focuses on making CLI11 behave properly in corner cases, and with
  810 +config files on the command line. This includes fixes for a variety of reported
  811 +issues. A few features were added to make life easier, as well; such as a new
  812 +flag callback and a macro for the parse command.
  813 +
  814 +- Added functional form of flag
  815 + [#33](https://github.com/CLIUtils/CLI11/pull/33), automatic on C++14
  816 +- Fixed Config file search if passed on command line
  817 + [#30](https://github.com/CLIUtils/CLI11/issues/30)
  818 +- Added `CLI11_PARSE(app, argc, argv)` macro for simple parse commands (does not
  819 + support returning arg)
  820 +- The name string can now contain spaces around commas
  821 + [#29](https://github.com/CLIUtils/CLI11/pull/29)
  822 +- `set_default_str` now only sets string, and `set_default_val` will evaluate
  823 + the default string given [#26](https://github.com/CLIUtils/CLI11/issues/26)
  824 +- Required positionals now take priority over subcommands
  825 + [#23](https://github.com/CLIUtils/CLI11/issues/23)
636 826 - Extra requirements enforced by Travis
637 827  
638 828 ## Version 1.1: Feedback
639 829  
640   -This release incorporates feedback from the release announcement. The examples are slowly being expanded, some corner cases improved, and some new functionality for tricky parsing situations.
641   -
642   -- Added simple support for enumerations, allow non-printable objects [#12](https://github.com/CLIUtils/CLI11/issues/12)
643   -- Added `app.parse_order()` with original parse order ([#13](https://github.com/CLIUtils/CLI11/issues/13), [#16](https://github.com/CLIUtils/CLI11/pull/16))
644   -- Added `prefix_command()`, which is like `allow_extras` but instantly stops and returns. ([#8](https://github.com/CLIUtils/CLI11/issues/8), [#17](https://github.com/CLIUtils/CLI11/pull/17))
645   -- Removed Windows warning ([#10](https://github.com/CLIUtils/CLI11/issues/10), [#20](https://github.com/CLIUtils/CLI11/pull/20))
646   -- Some improvements to CMake, detect Python and no dependencies on Python 2 (like Python 3) ([#18](https://github.com/CLIUtils/CLI11/issues/18), [#21](https://github.com/CLIUtils/CLI11/pull/21))
  830 +This release incorporates feedback from the release announcement. The examples
  831 +are slowly being expanded, some corner cases improved, and some new
  832 +functionality for tricky parsing situations.
  833 +
  834 +- Added simple support for enumerations, allow non-printable objects
  835 + [#12](https://github.com/CLIUtils/CLI11/issues/12)
  836 +- Added `app.parse_order()` with original parse order
  837 + ([#13](https://github.com/CLIUtils/CLI11/issues/13),
  838 + [#16](https://github.com/CLIUtils/CLI11/pull/16))
  839 +- Added `prefix_command()`, which is like `allow_extras` but instantly stops and
  840 + returns. ([#8](https://github.com/CLIUtils/CLI11/issues/8),
  841 + [#17](https://github.com/CLIUtils/CLI11/pull/17))
  842 +- Removed Windows warning ([#10](https://github.com/CLIUtils/CLI11/issues/10),
  843 + [#20](https://github.com/CLIUtils/CLI11/pull/20))
  844 +- Some improvements to CMake, detect Python and no dependencies on Python 2
  845 + (like Python 3) ([#18](https://github.com/CLIUtils/CLI11/issues/18),
  846 + [#21](https://github.com/CLIUtils/CLI11/pull/21))
647 847  
648 848 ## Version 1.0: Official release
649 849  
650   -This is the first stable release for CLI11. Future releases will try to remain backward compatible and will follow semantic versioning if possible. There were a few small changes since version 0.9:
  850 +This is the first stable release for CLI11. Future releases will try to remain
  851 +backward compatible and will follow semantic versioning if possible. There were
  852 +a few small changes since version 0.9:
651 853  
652 854 - Cleanup using `clang-tidy` and `clang-format`
653 855 - Small improvements to Timers, easier to subclass Error
... ... @@ -655,13 +857,16 @@ This is the first stable release for CLI11. Future releases will try to remain b
655 857  
656 858 ## Version 0.9: Polish
657 859  
658   -This release focused on cleaning up the most exotic compiler warnings, fixing a few oddities of the config parser, and added a more natural method to check subcommands.
  860 +This release focused on cleaning up the most exotic compiler warnings, fixing a
  861 +few oddities of the config parser, and added a more natural method to check
  862 +subcommands.
659 863  
660 864 - Better CMake named target (CLI11)
661 865 - More warnings added, fixed
662 866 - Ini output now includes `=false` when `default_also` is true
663 867 - Ini no longer lists the help pointer
664   -- Added test for inclusion in multiple files and linking, fixed issues (rarely needed for CLI, but nice for tools)
  868 +- Added test for inclusion in multiple files and linking, fixed issues (rarely
  869 + needed for CLI, but nice for tools)
665 870 - Support for complex numbers
666 871 - Subcommands now test true/false directly or with `->parsed()`, cleaner parse
667 872  
... ... @@ -674,20 +879,25 @@ This release moved the repository to the CLIUtils main organization.
674 879  
675 880 ## Version 0.7: Code coverage 100%
676 881  
677   -Lots of small bugs fixed when adding code coverage, better in edge cases. Much more powerful ini support.
  882 +Lots of small bugs fixed when adding code coverage, better in edge cases. Much
  883 +more powerful ini support.
678 884  
679 885 - Allow comments in ini files (lines starting with `;`)
680 886 - Ini files support flags, vectors, subcommands
681 887 - Added CodeCov code coverage reports
682 888 - Lots of small bugfixes related to adding tests to increase coverage to 100%
683 889 - Error handling now uses scoped enum in errors
684   -- Reparsing rules changed a little to accommodate Ini files. Callbacks are now called when parsing INI, and reset any time results are added.
685   -- Adding extra utilities in full version only, `Timer` (not needed for parsing, but useful for general CLI applications).
  890 +- Reparsing rules changed a little to accommodate Ini files. Callbacks are now
  891 + called when parsing INI, and reset any time results are added.
  892 +- Adding extra utilities in full version only, `Timer` (not needed for parsing,
  893 + but useful for general CLI applications).
686 894 - Better support for custom `add_options` like functions.
687 895  
688 896 ## Version 0.6: Cleanup
689 897  
690   -Lots of cleanup and docs additions made it into this release. Parsing is simpler and more robust; fall through option added and works as expected; much more consistent variable names internally.
  898 +Lots of cleanup and docs additions made it into this release. Parsing is simpler
  899 +and more robust; fall through option added and works as expected; much more
  900 +consistent variable names internally.
691 901  
692 902 - Simplified parsing to use `vector<string>` only
693 903 - Fixed fallthrough, made it optional as well (default: off): `.fallthrough()`.
... ... @@ -698,11 +908,20 @@ Lots of cleanup and docs additions made it into this release. Parsing is simpler
698 908 ## Version 0.5: Windows support
699 909  
700 910 - Allow `Hidden` options.
701   -- Throw `OptionAlreadyAdded` errors for matching subcommands or options, with ignore-case included, tests
702   -- `->ignore_case()` added to subcommands, options, and `add_set_ignore_case`. Subcommands inherit setting from parent App on creation.
703   -- Subcommands now can be "chained", that is, left over arguments can now include subcommands that then get parsed. Subcommands are now a list (`get_subcommands`). Added `got_subcommand(App_or_name)` to check for subcommands.
704   -- Added `.allow_extras()` to disable error on failure. Parse returns a vector of leftover options. Renamed error to `ExtrasError`, and now triggers on extra options too.
705   -- Added `require_subcommand` to `App`, to simplify forcing subcommands. Do **not** do `add_subcommand()->require_subcommand`, since that is the subcommand, not the main `App`.
  911 +- Throw `OptionAlreadyAdded` errors for matching subcommands or options, with
  912 + ignore-case included, tests
  913 +- `->ignore_case()` added to subcommands, options, and `add_set_ignore_case`.
  914 + Subcommands inherit setting from parent App on creation.
  915 +- Subcommands now can be "chained", that is, left over arguments can now include
  916 + subcommands that then get parsed. Subcommands are now a list
  917 + (`get_subcommands`). Added `got_subcommand(App_or_name)` to check for
  918 + subcommands.
  919 +- Added `.allow_extras()` to disable error on failure. Parse returns a vector of
  920 + leftover options. Renamed error to `ExtrasError`, and now triggers on extra
  921 + options too.
  922 +- Added `require_subcommand` to `App`, to simplify forcing subcommands. Do
  923 + **not** do `add_subcommand()->require_subcommand`, since that is the
  924 + subcommand, not the main `App`.
706 925 - Added printout of ini file text given parsed options, skips flags.
707 926 - Support for quotes and spaces in ini files
708 927 - Fixes to allow support for Windows (added Appveyor) (Uses `-`, not `/` syntax)
... ... @@ -717,14 +936,16 @@ Lots of cleanup and docs additions made it into this release. Parsing is simpler
717 936  
718 937 ## Version 0.3: Plumbum compatibility
719 938  
720   -- Added `->requires`, `->excludes`, and `->envname` from [Plumbum](http://plumbum.readthedocs.io/en/latest/)
  939 +- Added `->requires`, `->excludes`, and `->envname` from
  940 + [Plumbum](http://plumbum.readthedocs.io/en/latest/)
721 941 - Supports `->mandatory` from Plumbum
722 942 - More tests for help strings, improvements in formatting
723 943 - Support type and set syntax in positionals help strings
724 944 - Added help groups, with `->group("name")` syntax
725 945 - Added initial support for ini file reading with `add_config` option.
726 946 - Supports GCC 4.7 again
727   -- Clang 3.5 now required for tests due to googlemock usage, 3.4 should still work otherwise
  947 +- Clang 3.5 now required for tests due to googlemock usage, 3.4 should still
  948 + work otherwise
728 949 - Changes `setup` for an explicit help bool in constructor/`add_subcommand`
729 950  
730 951 ## Version 0.2: Leaner and meaner
... ... @@ -739,4 +960,5 @@ Lots of cleanup and docs additions made it into this release. Parsing is simpler
739 960  
740 961 ## Version 0.1: First release
741 962  
742   -First release before major cleanup. Still has make syntax and combiners; very clever syntax but not the best or most commonly expected way to work.
  963 +First release before major cleanup. Still has make syntax and combiners; very
  964 +clever syntax but not the best or most commonly expected way to work.
... ...
README.md
... ... @@ -7,8 +7,7 @@
7 7 [![Build Status AppVeyor][appveyor-badge]][appveyor]
8 8 [![Code Coverage][codecov-badge]][codecov]
9 9 [![Codacy Badge][codacy-badge]][codacy-link]
10   -[![License: BSD][license-badge]](./LICENSE)
11   -[![DOI][doi-badge]][doi-link]
  10 +[![License: BSD][license-badge]](./LICENSE) [![DOI][doi-badge]][doi-link]
12 11  
13 12 [![Gitter chat][gitter-badge]][gitter]
14 13 [![Latest GHA release][releases-badge]][github releases]
... ... @@ -17,11 +16,11 @@
17 16 [![Conda Version][conda-badge]][conda-link]
18 17 [![Try CLI11 2.1 online][wandbox-badge]][wandbox-link]
19 18  
20   -[What's new](./CHANGELOG.md) โ€ข
21   -[Documentation][gitbook] โ€ข
22   -[API Reference][api-docs]
  19 +[What's new](./CHANGELOG.md) โ€ข [Documentation][gitbook] โ€ข [API
  20 +Reference][api-docs]
23 21  
24   -CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
  22 +CLI11 is a command line parser for C++11 and beyond that provides a rich feature
  23 +set with a simple and intuitive interface.
25 24  
26 25 ## Table of Contents
27 26  
... ... @@ -58,35 +57,58 @@ CLI11 is a command line parser for C++11 and beyond that provides a rich feature
58 57 - [Contribute](#contribute)
59 58 - [License](#license)
60 59  
61   -Features that were added in the last released minor version are marked with "๐Ÿ†•". Features only available in main are marked with "๐Ÿšง".
  60 +Features that were added in the last released minor version are marked with
  61 +"๐Ÿ†•". Features only available in main are marked with "๐Ÿšง".
62 62  
63 63 ## Background
64 64  
65 65 ### Introduction
66 66  
67   -CLI11 provides all the features you expect in a powerful command line parser, with a beautiful, minimal syntax and no dependencies beyond C++11. It is header only, and comes in a single file form for easy inclusion in projects. It is easy to use for small projects, but powerful enough for complex command line projects, and can be customized for frameworks.
68   -It is tested on [Azure][] and [GitHub Actions][actions-link], and was originally used by the [GooFit GPU fitting framework][goofit]. It was inspired by [`plumbum.cli`][plumbum] for Python. CLI11 has a user friendly introduction in this README, a more in-depth tutorial [GitBook][], as well as [API documentation][api-docs] generated by Travis.
69   -See the [changelog](./CHANGELOG.md) or [GitHub Releases][] for details for current and past releases. Also see the [Version 1.0 post][], [Version 1.3 post][], [Version 1.6 post][], or [Version 2.0 post][] for more information.
70   -
71   -You can be notified when new releases are made by subscribing to <https://github.com/CLIUtils/CLI11/releases.atom> on an RSS reader, like Feedly, or use the releases mode of the GitHub watching tool.
  67 +CLI11 provides all the features you expect in a powerful command line parser,
  68 +with a beautiful, minimal syntax and no dependencies beyond C++11. It is header
  69 +only, and comes in a single file form for easy inclusion in projects. It is easy
  70 +to use for small projects, but powerful enough for complex command line
  71 +projects, and can be customized for frameworks. It is tested on [Azure][] and
  72 +[GitHub Actions][actions-link], and was originally used by the [GooFit GPU
  73 +fitting framework][goofit]. It was inspired by [`plumbum.cli`][plumbum] for
  74 +Python. CLI11 has a user friendly introduction in this README, a more in-depth
  75 +tutorial [GitBook][], as well as [API documentation][api-docs] generated by
  76 +Travis. See the [changelog](./CHANGELOG.md) or [GitHub Releases][] for details
  77 +for current and past releases. Also see the [Version 1.0 post][], [Version 1.3
  78 +post][], [Version 1.6 post][], or [Version 2.0 post][] for more information.
  79 +
  80 +You can be notified when new releases are made by subscribing to
  81 +<https://github.com/CLIUtils/CLI11/releases.atom> on an RSS reader, like Feedly,
  82 +or use the releases mode of the GitHub watching tool.
72 83  
73 84 ### Why write another CLI parser?
74 85  
75 86 An acceptable CLI parser library should be all of the following:
76 87  
77   -- Easy to include (i.e., header only, one file if possible, **no external requirements**).
78   -- Short, simple syntax: This is one of the main reasons to use a CLI parser, it should make variables from the command line nearly as easy to define as any other variables. If most of your program is hidden in CLI parsing, this is a problem for readability.
79   -- C++11 or better: Should work with GCC 4.8+ (default on CentOS/RHEL 7), Clang 3.4+, AppleClang 7+, NVCC 7.0+, or MSVC 2015+.
  88 +- Easy to include (i.e., header only, one file if possible, **no external
  89 + requirements**).
  90 +- Short, simple syntax: This is one of the main reasons to use a CLI parser, it
  91 + should make variables from the command line nearly as easy to define as any
  92 + other variables. If most of your program is hidden in CLI parsing, this is a
  93 + problem for readability.
  94 +- C++11 or better: Should work with GCC 4.8+ (default on CentOS/RHEL 7), Clang
  95 + 3.4+, AppleClang 7+, NVCC 7.0+, or MSVC 2015+.
80 96 - Work on Linux, macOS, and Windows.
81   -- Well tested on all common platforms and compilers. "Well" is defined as having good coverage measured by [CodeCov][].
  97 +- Well tested on all common platforms and compilers. "Well" is defined as having
  98 + good coverage measured by [CodeCov][].
82 99 - Clear help printing.
83 100 - Nice error messages.
84   -- Standard shell idioms supported naturally, like grouping flags, a positional separator, etc.
85   -- Easy to execute, with help, parse errors, etc. providing correct exit and details.
  101 +- Standard shell idioms supported naturally, like grouping flags, a positional
  102 + separator, etc.
  103 +- Easy to execute, with help, parse errors, etc. providing correct exit and
  104 + details.
86 105 - Easy to extend as part of a framework that provides "applications" to users.
87   -- Usable subcommand syntax, with support for multiple subcommands, nested subcommands, option groups, and optional fallthrough (explained later).
88   -- Ability to add a configuration file (`TOML`, `INI`, or custom format), and produce it as well.
89   -- Produce real values that can be used directly in code, not something you have pay compute time to look up, for HPC applications.
  106 +- Usable subcommand syntax, with support for multiple subcommands, nested
  107 + subcommands, option groups, and optional fallthrough (explained later).
  108 +- Ability to add a configuration file (`TOML`, `INI`, or custom format), and
  109 + produce it as well.
  110 +- Produce real values that can be used directly in code, not something you have
  111 + pay compute time to look up, for HPC applications.
90 112 - Work with common types, simple custom types, and extensible to exotic types.
91 113 - Permissively licensed.
92 114  
... ... @@ -117,31 +139,57 @@ After I wrote this, I also found the following libraries:
117 139 | [argparse][] | C++17 single file argument parser. Design seems similar to CLI11 in some ways. The author has several other interesting projects. |
118 140 | [lyra][] | a simple header only parser with composable options. Might work well for simple standardized parsing |
119 141  
120   -See [Awesome C++][] for a less-biased list of parsers. You can also find other single file libraries at [Single file libs][].
  142 +See [Awesome C++][] for a less-biased list of parsers. You can also find other
  143 +single file libraries at [Single file libs][].
121 144  
122 145 </p></details>
123 146 <br/>
124 147  
125   -None of these libraries fulfill all the above requirements, or really even come close. As you probably have already guessed, CLI11 does.
126   -So, this library was designed to provide a great syntax, good compiler compatibility, and minimal installation fuss.
  148 +None of these libraries fulfill all the above requirements, or really even come
  149 +close. As you probably have already guessed, CLI11 does. So, this library was
  150 +designed to provide a great syntax, good compiler compatibility, and minimal
  151 +installation fuss.
127 152  
128 153 ### Features not supported by this library
129 154  
130   -There are some other possible "features" that are intentionally not supported by this library:
131   -
132   -- Non-standard variations on syntax, like `-long` options. This is non-standard and should be avoided, so that is enforced by this library.
133   -- Completion of partial options, such as Python's `argparse` supplies for incomplete arguments. It's better not to guess. Most third party command line parsers for python actually reimplement command line parsing rather than using argparse because of this perceived design flaw (recent versions do have an option to disable it).
134   -- Autocomplete: This might eventually be added to both Plumbum and CLI11, but it is not supported yet.
135   -- Wide strings / unicode: Since this uses the standard library only, it might be hard to properly implement, but I would be open to suggestions in how to do this.
  155 +There are some other possible "features" that are intentionally not supported by
  156 +this library:
  157 +
  158 +- Non-standard variations on syntax, like `-long` options. This is non-standard
  159 + and should be avoided, so that is enforced by this library.
  160 +- Completion of partial options, such as Python's `argparse` supplies for
  161 + incomplete arguments. It's better not to guess. Most third party command line
  162 + parsers for python actually reimplement command line parsing rather than using
  163 + argparse because of this perceived design flaw (recent versions do have an
  164 + option to disable it).
  165 +- Autocomplete: This might eventually be added to both Plumbum and CLI11, but it
  166 + is not supported yet.
  167 +- Wide strings / unicode: Since this uses the standard library only, it might be
  168 + hard to properly implement, but I would be open to suggestions in how to do
  169 + this.
136 170  
137 171 ## Install
138 172  
139 173 To use, there are several methods:
140 174  
141   -- All-in-one local header: Copy `CLI11.hpp` from the [most recent release][github releases] into your include directory, and you are set. This is combined from the source files for every release. This includes the entire command parser library, but does not include separate utilities (like `Timer`, `AutoTimer`). The utilities are completely self contained and can be copied separately.
142   -- All-in-one global header: Like above, but copying the file to a shared folder location like `/opt/CLI11`. Then, the C++ include path has to be extended to point at this folder. With CMake, use `include_directories(/opt/CLI11)`
143   -- Local headers and target: Use `CLI/*.hpp` files. You could check out the repository as a git submodule, for example. With CMake, you can use `add_subdirectory` and the `CLI11::CLI11` interface target when linking. If not using a submodule, you must ensure that the copied files are located inside the same tree directory than your current project, to prevent an error with CMake and `add_subdirectory`.
144   -- Global headers: Use `CLI/*.hpp` files stored in a shared folder. You could check out the git repository to a system-wide folder, for example `/opt/`. With CMake, you could add to the include path via:
  175 +- All-in-one local header: Copy `CLI11.hpp` from the [most recent
  176 + release][github releases] into your include directory, and you are set. This
  177 + is combined from the source files for every release. This includes the entire
  178 + command parser library, but does not include separate utilities (like `Timer`,
  179 + `AutoTimer`). The utilities are completely self contained and can be copied
  180 + separately.
  181 +- All-in-one global header: Like above, but copying the file to a shared folder
  182 + location like `/opt/CLI11`. Then, the C++ include path has to be extended to
  183 + point at this folder. With CMake, use `include_directories(/opt/CLI11)`
  184 +- Local headers and target: Use `CLI/*.hpp` files. You could check out the
  185 + repository as a git submodule, for example. With CMake, you can use
  186 + `add_subdirectory` and the `CLI11::CLI11` interface target when linking. If
  187 + not using a submodule, you must ensure that the copied files are located
  188 + inside the same tree directory than your current project, to prevent an error
  189 + with CMake and `add_subdirectory`.
  190 +- Global headers: Use `CLI/*.hpp` files stored in a shared folder. You could
  191 + check out the git repository to a system-wide folder, for example `/opt/`.
  192 + With CMake, you could add to the include path via:
145 193  
146 194 ```bash
147 195 if(NOT DEFINED CLI11_DIR)
... ... @@ -150,7 +198,8 @@ endif()
150 198 include_directories(${CLI11_DIR}/include)
151 199 ```
152 200  
153   -And then in the source code (adding several headers might be needed to prevent linker errors):
  201 +And then in the source code (adding several headers might be needed to prevent
  202 +linker errors):
154 203  
155 204 ```cpp
156 205 #include "CLI/App.hpp"
... ... @@ -158,10 +207,19 @@ And then in the source code (adding several headers might be needed to prevent l
158 207 #include "CLI/Config.hpp"
159 208 ```
160 209  
161   -- Global headers and target: configuring and installing the project is required for linking CLI11 to your project in the same way as you would do with any other external library. With CMake, this step allows using `find_package(CLI11 CONFIG REQUIRED)` and then using the `CLI11::CLI11` target when linking. If `CMAKE_INSTALL_PREFIX` was changed during install to a specific folder like `/opt/CLI11`, then you have to pass `-DCLI11_DIR=/opt/CLI11` when building your current project. You can also use [Conan.io][conan-link] or [Hunter][].
162   - (These are just conveniences to allow you to use your favorite method of managing packages; it's just header only so including the correct path and
163   - using C++11 is all you really need.)
164   -- Via FetchContent in CMake 3.14+ (or 3.11+ with more work): you can add this with fetch-content, then use the `CLI11::CLI11` target as above, and CMake will download the project in the configure stage:
  210 +- Global headers and target: configuring and installing the project is required
  211 + for linking CLI11 to your project in the same way as you would do with any
  212 + other external library. With CMake, this step allows using
  213 + `find_package(CLI11 CONFIG REQUIRED)` and then using the `CLI11::CLI11` target
  214 + when linking. If `CMAKE_INSTALL_PREFIX` was changed during install to a
  215 + specific folder like `/opt/CLI11`, then you have to pass
  216 + `-DCLI11_DIR=/opt/CLI11` when building your current project. You can also use
  217 + [Conan.io][conan-link] or [Hunter][]. (These are just conveniences to allow
  218 + you to use your favorite method of managing packages; it's just header only so
  219 + including the correct path and using C++11 is all you really need.)
  220 +- Via FetchContent in CMake 3.14+ (or 3.11+ with more work): you can add this
  221 + with fetch-content, then use the `CLI11::CLI11` target as above, and CMake
  222 + will download the project in the configure stage:
165 223  
166 224 ```cmake
167 225 include(FetchContent)
... ... @@ -174,7 +232,11 @@ FetchContent_Declare(
174 232 FetchContent_MakeAvailable(cli11)
175 233 ```
176 234  
177   -It is highly recommended that you use the git hash for `GIT_TAG` instead of a tag or branch, as that will both be more secure, as well as faster to reconfigure - CMake will not have to reach out to the internet to see if the tag moved. You can also download just the single header file from the releases using `file(DOWNLOAD`.
  235 +It is highly recommended that you use the git hash for `GIT_TAG` instead of a
  236 +tag or branch, as that will both be more secure, as well as faster to
  237 +reconfigure - CMake will not have to reach out to the internet to see if the tag
  238 +moved. You can also download just the single header file from the releases using
  239 +`file(DOWNLOAD`.
178 240  
179 241 To build the tests, checkout the repository and use CMake:
180 242  
... ... @@ -186,15 +248,24 @@ CTEST_OUTPUT_ON_FAILURE=1 cmake --build build -t test
186 248  
187 249 <details><summary>Note: Special instructions for GCC 8</summary><p>
188 250  
189   -If you are using GCC 8 and using it in C++17 mode with CLI11. CLI11 makes use of the `<filesystem>` header if available, but specifically for this compiler, the `filesystem` library is separate from the standard library and needs to be linked separately. So it is available but CLI11 doesn't use it by default.
  251 +If you are using GCC 8 and using it in C++17 mode with CLI11. CLI11 makes use of
  252 +the `<filesystem>` header if available, but specifically for this compiler, the
  253 +`filesystem` library is separate from the standard library and needs to be
  254 +linked separately. So it is available but CLI11 doesn't use it by default.
190 255  
191   -Specifically `libstdc++fs` needs to be added to the linking list and `CLI11_HAS_FILESYSTEM=1` has to be defined. Then the filesystem variant of the Validators could be used on GCC 8. GCC 9+ does not have this issue so the `<filesystem>` is used by default.
  256 +Specifically `libstdc++fs` needs to be added to the linking list and
  257 +`CLI11_HAS_FILESYSTEM=1` has to be defined. Then the filesystem variant of the
  258 +Validators could be used on GCC 8. GCC 9+ does not have this issue so the
  259 +`<filesystem>` is used by default.
192 260  
193 261 There may also be other cases where a specific library needs to be linked.
194 262  
195   -Defining `CLI11_HAS_FILESYSTEM=0` which will remove the usage and hence any linking issue.
  263 +Defining `CLI11_HAS_FILESYSTEM=0` which will remove the usage and hence any
  264 +linking issue.
196 265  
197   -In some cases certain clang compilations may require linking against `libc++fs`. These situations have not been encountered so the specific situations requiring them are unknown yet.
  266 +In some cases certain clang compilations may require linking against `libc++fs`.
  267 +These situations have not been encountered so the specific situations requiring
  268 +them are unknown yet.
198 269  
199 270 </p></details>
200 271 </br>
... ... @@ -203,7 +274,8 @@ In some cases certain clang compilations may require linking against `libc++fs`.
203 274  
204 275 ### Adding options
205 276  
206   -To set up, add options, and run, your main function will look something like this:
  277 +To set up, add options, and run, your main function will look something like
  278 +this:
207 279  
208 280 ```cpp
209 281 int main(int argc, char** argv) {
... ... @@ -227,16 +299,26 @@ try {
227 299 }
228 300 ```
229 301  
230   -The try/catch block ensures that `-h,--help` or a parse error will exit with the correct return code (selected from `CLI::ExitCodes`). (The return here should be inside `main`). You should not assume that the option values have been set inside the catch block; for example, help flags intentionally short-circuit all other processing for speed and to ensure required options and the like do not interfere.
  302 +The try/catch block ensures that `-h,--help` or a parse error will exit with the
  303 +correct return code (selected from `CLI::ExitCodes`). (The return here should be
  304 +inside `main`). You should not assume that the option values have been set
  305 +inside the catch block; for example, help flags intentionally short-circuit all
  306 +other processing for speed and to ensure required options and the like do not
  307 +interfere.
231 308  
232 309 </p></details>
233 310 </br>
234 311  
235   -The initialization is just one line, adding options is just two each. The parse macro is just one line (or 5 for the contents of the macro). After the app runs, the filename will be set to the correct value if it was passed, otherwise it will be set to the default. You can check to see if this was passed on the command line with `app.count("--file")`.
  312 +The initialization is just one line, adding options is just two each. The parse
  313 +macro is just one line (or 5 for the contents of the macro). After the app runs,
  314 +the filename will be set to the correct value if it was passed, otherwise it
  315 +will be set to the default. You can check to see if this was passed on the
  316 +command line with `app.count("--file")`.
236 317  
237 318 #### Option types
238 319  
239   -While all options internally are the same type, there are several ways to add an option depending on what you need. The supported values are:
  320 +While all options internally are the same type, there are several ways to add an
  321 +option depending on what you need. The supported values are:
240 322  
241 323 ```cpp
242 324 // Add options
... ... @@ -277,18 +359,32 @@ App* subcom = app.add_subcommand(name, description);
277 359 Option_group *app.add_option_group(name,description);
278 360 ```
279 361  
280   -An option name may start with any character except ('-', ' ', '\n', and '!'). For long options, after the first character all characters are allowed except ('=',':','{',' ', '\n'). For the `add_flag*` functions '{' and '!' have special meaning which is why they are not allowed. 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.
281   -
282   -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.
283   -
284   -The two parameter template overload can be used in cases where you want to restrict the input such as
  362 +An option name may start with any character except ('-', ' ', '\n', and '!').
  363 +For long options, after the first character all characters are allowed except
  364 +('=',':','{',' ', '\n'). For the `add_flag*` functions '{' and '!' have special
  365 +meaning which is why they are not allowed. Names are given as a comma separated
  366 +string, with the dash or dashes. An option or flag can have as many names as you
  367 +want, and afterward, using `count`, you can use any of the names, with dashes as
  368 +needed, to count the options. One of the names is allowed to be given without
  369 +proceeding dash(es); if present the option is a positional option, and that name
  370 +will be used on the help line for its positional form.
  371 +
  372 +The `add_option_function<type>(...` function will typically require the template
  373 +parameter be given unless a `std::function` object with an exact match is
  374 +passed. The type can be any type supported by the `add_option` function. The
  375 +function should throw an error (`CLI::ConversionError` or `CLI::ValidationError`
  376 +possibly) if the value is not valid.
  377 +
  378 +The two parameter template overload can be used in cases where you want to
  379 +restrict the input such as
285 380  
286 381 ```cpp
287 382 double val
288 383 app.add_option<double,unsigned int>("-v",val);
289 384 ```
290 385  
291   -which would first verify the input is convertible to an `unsigned int` before assigning it. Or using some variant type
  386 +which would first verify the input is convertible to an `unsigned int` before
  387 +assigning it. Or using some variant type
292 388  
293 389 ```cpp
294 390 using vtype=std::variant<int, double, std::string>;
... ... @@ -298,9 +394,19 @@ app.add_option&lt;vtype,int&gt;(&quot;--vi&quot;,v1);
298 394 app.add_option<vtype,double>("--vf",v1);
299 395 ```
300 396  
301   -otherwise the output would default to a string. The `add_option` can be used with any integral or floating point types, enumerations, or strings. Or any type that takes an int, double, or std\::string in an assignment operator or constructor. If an object can take multiple varieties of those, std::string takes precedence, then double then int. To better control which one is used or to use another type for the underlying conversions use the two parameter template to directly specify the conversion type.
  397 +otherwise the output would default to a string. The `add_option` can be used
  398 +with any integral or floating point types, enumerations, or strings. Or any type
  399 +that takes an int, double, or std\::string in an assignment operator or
  400 +constructor. If an object can take multiple varieties of those, std::string
  401 +takes precedence, then double then int. To better control which one is used or
  402 +to use another type for the underlying conversions use the two parameter
  403 +template to directly specify the conversion type.
302 404  
303   -Types such as (std or boost) `optional<int>`, `optional<double>`, and `optional<string>` and any other wrapper types are supported directly. For purposes of CLI11 wrapper types are those which `value_type` definition. See [CLI11 Advanced Topics/Custom Converters][] for information on how you can add your own converters for additional types.
  405 +Types such as (std or boost) `optional<int>`, `optional<double>`, and
  406 +`optional<string>` and any other wrapper types are supported directly. For
  407 +purposes of CLI11 wrapper types are those which `value_type` definition. See
  408 +[CLI11 Advanced Topics/Custom Converters][] for information on how you can add
  409 +your own converters for additional types.
304 410  
305 411 Vector types can also be used in the two parameter template overload
306 412  
... ... @@ -309,79 +415,175 @@ std::vector&lt;double&gt; v1;
309 415 app.add_option<std::vector<double>,int>("--vs",v1);
310 416 ```
311 417  
312   -would load a vector of doubles but ensure all values can be represented as integers.
  418 +would load a vector of doubles but ensure all values can be represented as
  419 +integers.
313 420  
314   -Automatic direct capture of the default string is disabled when using the two parameter template. Use `set_default_str(...)` or `->default_function(std::string())` to set the default string or capture function directly for these cases.
  421 +Automatic direct capture of the default string is disabled when using the two
  422 +parameter template. Use `set_default_str(...)` or
  423 +`->default_function(std::string())` to set the default string or capture
  424 +function directly for these cases.
315 425  
316   -Flag options specified through the `add_flag*` functions allow a syntax for the option names to default particular options to a false value or any other value if some flags are passed. For example:
  426 +Flag options specified through the `add_flag*` functions allow a syntax for the
  427 +option names to default particular options to a false value or any other value
  428 +if some flags are passed. For example:
317 429  
318 430 ```cpp
319 431 app.add_flag("--flag,!--no-flag",result,"help for flag");
320 432 ```
321 433  
322   -specifies that if `--flag` is passed on the command line result will be true or contain a value of 1. If `--no-flag` is
323   -passed `result` will contain false or -1 if `result` is a signed integer type, or 0 if it is an unsigned type. An
324   -alternative form of the syntax is more explicit: `"--flag,--no-flag{false}"`; this is equivalent to the previous
325   -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
326   -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
327   -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).
328   -The default value can be any value. For example if you wished to define a numerical flag:
  434 +specifies that if `--flag` is passed on the command line result will be true or
  435 +contain a value of 1. If `--no-flag` is passed `result` will contain false or -1
  436 +if `result` is a signed integer type, or 0 if it is an unsigned type. An
  437 +alternative form of the syntax is more explicit: `"--flag,--no-flag{false}"`;
  438 +this is equivalent to the previous example. This also works for short form
  439 +options `"-f,!-n"` or `"-f,-n{false}"`. If `variable_to_bind_to` is anything but
  440 +an integer value the default behavior is to take the last value given, while if
  441 +`variable_to_bind_to` is an integer type the behavior will be to sum all the
  442 +given arguments and return the result. This can be modified if needed by
  443 +changing the `multi_option_policy` on each flag (this is not inherited). The
  444 +default value can be any value. For example if you wished to define a numerical
  445 +flag:
329 446  
330 447 ```cpp
331 448 app.add_flag("-1{1},-2{2},-3{3}",result,"numerical flag")
332 449 ```
333 450  
334   -Using any of those flags on the command line will result in the specified number in the output. Similar things can be done for string values, and enumerations, as long as the default value can be converted to the given type.
  451 +Using any of those flags on the command line will result in the specified number
  452 +in the output. Similar things can be done for string values, and enumerations,
  453 +as long as the default value can be converted to the given type.
335 454  
336   -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.
  455 +On a `C++14` compiler, you can pass a callback function directly to `.add_flag`,
  456 +while in C++11 mode you'll need to use `.add_flag_function` if you want a
  457 +callback function. The function will be given the number of times the flag was
  458 +passed. You can throw a relevant `CLI::ParseError` to signal a failure.
337 459  
338 460 #### Example
339 461  
340   -- `"one,-o,--one"`: Valid as long as not a flag, would create an option that can be specified positionally, or with `-o` or `--one`
  462 +- `"one,-o,--one"`: Valid as long as not a flag, would create an option that can
  463 + be specified positionally, or with `-o` or `--one`
341 464 - `"this"` Can only be passed positionally
342 465 - `"-a,-b,-c"` No limit to the number of non-positional option names
343 466  
344   -The add commands return a pointer to an internally stored `Option`.
345   -This option can be used directly to check for the count (`->count()`) after parsing to avoid a string based lookup.
  467 +The add commands return a pointer to an internally stored `Option`. This option
  468 +can be used directly to check for the count (`->count()`) after parsing to avoid
  469 +a string based lookup.
346 470  
347 471 #### Option options
348 472  
349 473 Before parsing, you can set the following options:
350 474  
351   -- `->required()`: The program will quit if this option is not present. This is `mandatory` in Plumbum, but required options seems to be a more standard term. For compatibility, `->mandatory()` also works.
352   -- `->expected(N)`: Take `N` values instead of as many as possible, only for vector args. If negative, require at least `-N`; end with `--` or another recognized option or subcommand.
353   -- `->expected(MIN,MAX)`: Set a range of expected values to accompany an option. `expected(0,1)` is the equivalent of making a flag.
354   -- `->type_name(typename)`: Set the name of an Option's type (`type_name_fn` allows a function instead)
355   -- `->type_size(N)`: Set the intrinsic size of an option value. The parser will require multiples of this number if negative. Most of the time this is detected automatically though can be modified for specific use cases.
  475 +- `->required()`: The program will quit if this option is not present. This is
  476 + `mandatory` in Plumbum, but required options seems to be a more standard term.
  477 + For compatibility, `->mandatory()` also works.
  478 +- `->expected(N)`: Take `N` values instead of as many as possible, only for
  479 + vector args. If negative, require at least `-N`; end with `--` or another
  480 + recognized option or subcommand.
  481 +- `->expected(MIN,MAX)`: Set a range of expected values to accompany an option.
  482 + `expected(0,1)` is the equivalent of making a flag.
  483 +- `->type_name(typename)`: Set the name of an Option's type (`type_name_fn`
  484 + allows a function instead)
  485 +- `->type_size(N)`: Set the intrinsic size of an option value. The parser will
  486 + require multiples of this number if negative. Most of the time this is
  487 + detected automatically though can be modified for specific use cases.
356 488 - `->type_size(MIN,MAX)`: Set the intrinsic size of an option to a range.
357   -- `->needs(opt)`: This option requires another option to also be present, opt is an `Option` pointer. Options can be removed from the `needs` with `remove_needs(opt)`. The option can also be specified with a string containing the name of the option
358   -- `->excludes(opt)`: This option cannot be given with `opt` present, opt is an `Option` pointer. Can also be given as a string containing the name of the option. Options can be removed from the excludes list with `->remove_excludes(opt)`
359   -- `->envname(name)`: Gets the value from the environment if present and not passed on the command line.
360   -- `->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).
361   -- `->ignore_case()`: Ignore the case on the command line (also works on subcommands, does not affect arguments).
362   -- `->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
363   -- `->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.
364   -- `->allow_extra_args(true/false)`: If set to true the option will take an unlimited number of arguments like a vector, if false it will limit the number of arguments to the size of the type used in the option. Default value depends on the nature of the type use, containers default to true, others default to false.
365   -- `->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.
  489 +- `->needs(opt)`: This option requires another option to also be present, opt is
  490 + an `Option` pointer. Options can be removed from the `needs` with
  491 + `remove_needs(opt)`. The option can also be specified with a string containing
  492 + the name of the option
  493 +- `->excludes(opt)`: This option cannot be given with `opt` present, opt is an
  494 + `Option` pointer. Can also be given as a string containing the name of the
  495 + option. Options can be removed from the excludes list with
  496 + `->remove_excludes(opt)`
  497 +- `->envname(name)`: Gets the value from the environment if present and not
  498 + passed on the command line.
  499 +- `->group(name)`: The help group to put the option in. No effect for positional
  500 + options. Defaults to `"Options"`. `""` will not show up in the help print
  501 + (hidden).
  502 +- `->ignore_case()`: Ignore the case on the command line (also works on
  503 + subcommands, does not affect arguments).
  504 +- `->ignore_underscore()`: Ignore any underscores in the options names (also
  505 + works on subcommands, does not affect arguments). For example "option_one"
  506 + will match with "optionone". This does not apply to short form options since
  507 + they only have one character
  508 +- `->disable_flag_override()`: From the command line long form flag options can
  509 + be assigned a value on the command line using the `=` notation `--flag=value`.
  510 + If this behavior is not desired, the `disable_flag_override()` disables it and
  511 + will generate an exception if it is done on the command line. The `=` does not
  512 + work with short form flag options.
  513 +- `->allow_extra_args(true/false)`: If set to true the option will take an
  514 + unlimited number of arguments like a vector, if false it will limit the number
  515 + of arguments to the size of the type used in the option. Default value depends
  516 + on the nature of the type use, containers default to true, others default to
  517 + false.
  518 +- `->delimiter(char)`: Allows specification of a custom delimiter for separating
  519 + single arguments into vector arguments, for example specifying
  520 + `->delimiter(',')` on an option would result in `--opt=1,2,3` producing 3
  521 + elements of a vector and the equivalent of --opt 1 2 3 assuming opt is a
  522 + vector value.
366 523 - `->description(str)`: Set/change the description.
367   -- `->multi_option_policy(CLI::MultiOptionPolicy::Throw)`: Set the multi-option policy. Shortcuts available: `->take_last()`, `->take_first()`,`->take_all()`, 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). `->join(delim)` can also be used to join with a specific delimiter. This equivalent to calling `->delimiter(delim)` and `->join()`. Valid values are `CLI::MultiOptionPolicy::Throw`, `CLI::MultiOptionPolicy::Throw`, `CLI::MultiOptionPolicy::TakeLast`, `CLI::MultiOptionPolicy::TakeFirst`, `CLI::MultiOptionPolicy::Join`, `CLI::MultiOptionPolicy::TakeAll`, and `CLI::MultiOptionPolicy::Sum` ๐Ÿšง.
368   -- `->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
369   -- `->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.
370   -- `->transform(std::string(std::string &), validator_name="",validator_description=")`: Converts the input string into the output string, in-place in the parsed options.
371   -- `->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.
372   -- `->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.
373   -- `->configurable(false)`: Disable this option from being in a configuration file.
374   -- `->capture_default_str()`: Store the current value attached and display it in the help string.
375   -- `->default_function(std::string())`: Advanced: Change the function that `capture_default_str()` uses.
376   -- `->always_capture_default()`: Always run `capture_default_str()` when creating new options. Only useful on an App's `option_defaults`.
377   -- `->default_str(string)`: Set the default string directly (NO VALIDATION OR CALLBACKS). This string will also be used as a default value if no arguments are passed and the value is requested.
378   -- `->default_val(value)`: Generate the default string from a value and validate that the value is also valid. For options that assign directly to a value type the value in that type is also updated. Value must be convertible to a string(one of known types or have a stream operator). The callback may be triggered if the `run_callback_for_default` is set.
379   -- `->run_callback_for_default()`: This will force the option callback to be executed or the variable set when the `default_val` is set.
380   -- `->option_text(string)`: Sets the text between the option name and description.
381   -- `->force_callback()`: Causes the option callback or value set to be triggered even if the option was not present in parsing.
382   -- `->trigger_on_parse()`: If set, causes the callback and all associated validation checks for the option to be executed when the option value is parsed vs. at the end of all parsing. This could cause the callback to be executed multiple times. Also works with positional options ๐Ÿ†•.
383   -
384   -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.
  524 +- `->multi_option_policy(CLI::MultiOptionPolicy::Throw)`: Set the multi-option
  525 + policy. Shortcuts available: `->take_last()`, `->take_first()`,`->take_all()`,
  526 + and `->join()`. This will only affect options expecting 1 argument or bool
  527 + flags (which do not inherit their default but always start with a specific
  528 + policy). `->join(delim)` can also be used to join with a specific delimiter.
  529 + This equivalent to calling `->delimiter(delim)` and `->join()`. Valid values
  530 + are `CLI::MultiOptionPolicy::Throw`, `CLI::MultiOptionPolicy::Throw`,
  531 + `CLI::MultiOptionPolicy::TakeLast`, `CLI::MultiOptionPolicy::TakeFirst`,
  532 + `CLI::MultiOptionPolicy::Join`, `CLI::MultiOptionPolicy::TakeAll`, and
  533 + `CLI::MultiOptionPolicy::Sum` ๐Ÿšง.
  534 +- `->check(std::string(const std::string &), validator_name="",validator_description="")`:
  535 + Define a check function. The function should return a non empty string with
  536 + the error message if the check fails
  537 +- `->check(Validator)`: Use a Validator object to do the check see
  538 + [Validators](#validators) for a description of available Validators and how to
  539 + create new ones.
  540 +- `->transform(std::string(std::string &), validator_name="",validator_description=")`:
  541 + Converts the input string into the output string, in-place in the parsed
  542 + options.
  543 +- `->transform(Validator)`: Uses a Validator object to do the transformation see
  544 + [Validators](#validators) for a description of available Validators and how to
  545 + create new ones.
  546 +- `->each(void(const std::string &)>`: Run this function on each value received,
  547 + as it is received. It should throw a `ValidationError` if an error is
  548 + encountered.
  549 +- `->configurable(false)`: Disable this option from being in a configuration
  550 + file.
  551 +- `->capture_default_str()`: Store the current value attached and display it in
  552 + the help string.
  553 +- `->default_function(std::string())`: Advanced: Change the function that
  554 + `capture_default_str()` uses.
  555 +- `->always_capture_default()`: Always run `capture_default_str()` when creating
  556 + new options. Only useful on an App's `option_defaults`.
  557 +- `->default_str(string)`: Set the default string directly (NO VALIDATION OR
  558 + CALLBACKS). This string will also be used as a default value if no arguments
  559 + are passed and the value is requested.
  560 +- `->default_val(value)`: Generate the default string from a value and validate
  561 + that the value is also valid. For options that assign directly to a value type
  562 + the value in that type is also updated. Value must be convertible to a
  563 + string(one of known types or have a stream operator). The callback may be
  564 + triggered if the `run_callback_for_default` is set.
  565 +- `->run_callback_for_default()`: This will force the option callback to be
  566 + executed or the variable set when the `default_val` is set.
  567 +- `->option_text(string)`: Sets the text between the option name and
  568 + description.
  569 +- `->force_callback()`: Causes the option callback or value set to be triggered
  570 + even if the option was not present in parsing.
  571 +- `->trigger_on_parse()`: If set, causes the callback and all associated
  572 + validation checks for the option to be executed when the option value is
  573 + parsed vs. at the end of all parsing. This could cause the callback to be
  574 + executed multiple times. Also works with positional options ๐Ÿ†•.
  575 +
  576 +These options return the `Option` pointer, so you can chain them together, and
  577 +even skip storing the pointer entirely. The `each` function takes any function
  578 +that has the signature `void(const std::string&)`; it should throw a
  579 +`ValidationError` when validation fails. The help message will have the name of
  580 +the parent option prepended. Since `each`, `check` and `transform` use the same
  581 +underlying mechanism, you can chain as many as you want, and they will be
  582 +executed in order. Operations added through `transform` are executed first in
  583 +reverse order of addition, and `check` and `each` are run following the
  584 +transform functions in order of addition. If you just want to see the
  585 +unconverted values, use `.results()` to get the `std::vector<std::string>` of
  586 +results.
385 587  
386 588 On the command line, options can be given as:
387 589  
... ... @@ -395,7 +597,8 @@ On the command line, options can be given as:
395 597 - `--file filename` (space)
396 598 - `--file=filename` (equals)
397 599  
398   -If `allow_windows_style_options()` is specified in the application or subcommand options can also be given as:
  600 +If `allow_windows_style_options()` is specified in the application or subcommand
  601 +options can also be given as:
399 602  
400 603 - `/a` (flag)
401 604 - `/f filename` (option)
... ... @@ -403,43 +606,78 @@ If `allow_windows_style_options()` is specified in the application or subcommand
403 606 - `/file filename` (space)
404 607 - `/file:filename` (colon)
405 608 - `/long_flag:false` (long flag with : to override the default value)
406   - - Windows style options do not allow combining short options or values not separated from the short option like with `-` options
407   -
408   -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()`.
409   -
410   -Extra positional arguments will cause the program to exit, so at least one positional option with a vector is recommended if you want to allow extraneous arguments.
411   -If you set `.allow_extras()` on the main `App`, you will not get an error. You can access the missing options using `remaining` (if you have subcommands, `app.remaining(true)` will get all remaining options, subcommands included).
412   -If the remaining arguments are to processed by another `App` then the function `remaining_for_passthrough()` can be used to get the remaining arguments in reverse order such that `app.parse(vector)` works directly and could even be used inside a subcommand callback.
413   -
414   -You can access a vector of pointers to the parsed options in the original order using `parse_order()`.
415   -If `--` is present in the command line that does not end an unlimited option, then
416   -everything after that is positional only.
  609 + - Windows style options do not allow combining short options or values not
  610 + separated from the short option like with `-` options
  611 +
  612 +Long flag options may be given with an `=<value>` to allow specifying a false
  613 +value, or some other value to the flag. See [config files](#configuration-file)
  614 +for details on the values supported. NOTE: only the `=` or `:` for windows-style
  615 +options may be used for this, using a space will result in the argument being
  616 +interpreted as a positional argument. This syntax can override the default
  617 +values, and can be disabled by using `disable_flag_override()`.
  618 +
  619 +Extra positional arguments will cause the program to exit, so at least one
  620 +positional option with a vector is recommended if you want to allow extraneous
  621 +arguments. If you set `.allow_extras()` on the main `App`, you will not get an
  622 +error. You can access the missing options using `remaining` (if you have
  623 +subcommands, `app.remaining(true)` will get all remaining options, subcommands
  624 +included). If the remaining arguments are to processed by another `App` then the
  625 +function `remaining_for_passthrough()` can be used to get the remaining
  626 +arguments in reverse order such that `app.parse(vector)` works directly and
  627 +could even be used inside a subcommand callback.
  628 +
  629 +You can access a vector of pointers to the parsed options in the original order
  630 +using `parse_order()`. If `--` is present in the command line that does not end
  631 +an unlimited option, then everything after that is positional only.
417 632  
418 633 #### Validators
419 634  
420   -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`.
  635 +Validators are structures to check or modify inputs, they can be used to verify
  636 +that an input meets certain criteria or transform it into another value. They
  637 +are added through the `check` or `transform` functions. The differences between
  638 +the two function are that checks do not modify the input whereas transforms can
  639 +and are executed before any Validators added through `check`.
421 640  
422 641 CLI11 has several Validators built-in that perform some common checks
423 642  
424   -- `CLI::IsMember(...)`: Require an option be a member of a given set. See [Transforming Validators](#transforming-validators) for more details.
425   -- `CLI::Transformer(...)`: Modify the input using a map. See [Transforming Validators](#transforming-validators) for more details.
426   -- `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.
427   -- `CLI::AsNumberWithUnit(...)`: Modify the `<NUMBER> <UNIT>` pair by matching the unit and multiplying the number by the corresponding factor. It can be used as a base for transformers, that accept things like size values (`1 KB`) or durations (`0.33 ms`).
428   -- `CLI::AsSizeValue(...)`: Convert inputs like `100b`, `42 KB`, `101 Mb`, `11 Mib` to absolute values. `KB` can be configured to be interpreted as 10^3 or 2^10.
  643 +- `CLI::IsMember(...)`: Require an option be a member of a given set. See
  644 + [Transforming Validators](#transforming-validators) for more details.
  645 +- `CLI::Transformer(...)`: Modify the input using a map. See
  646 + [Transforming Validators](#transforming-validators) for more details.
  647 +- `CLI::CheckedTransformer(...)`: Modify the input using a map, and require that
  648 + the input is either in the set or already one of the outputs of the set. See
  649 + [Transforming Validators](#transforming-validators) for more details.
  650 +- `CLI::AsNumberWithUnit(...)`: Modify the `<NUMBER> <UNIT>` pair by matching
  651 + the unit and multiplying the number by the corresponding factor. It can be
  652 + used as a base for transformers, that accept things like size values (`1 KB`)
  653 + or durations (`0.33 ms`).
  654 +- `CLI::AsSizeValue(...)`: Convert inputs like `100b`, `42 KB`, `101 Mb`,
  655 + `11 Mib` to absolute values. `KB` can be configured to be interpreted as 10^3
  656 + or 2^10.
429 657 - `CLI::ExistingFile`: Requires that the file exists if given.
430 658 - `CLI::ExistingDirectory`: Requires that the directory exists.
431 659 - `CLI::ExistingPath`: Requires that the path (file or directory) exists.
432 660 - `CLI::NonexistentPath`: Requires that the path does not exist.
433   -- `CLI::FileOnDefaultPath`: ๐Ÿ†• Best used as a transform, Will check that a file exists either directly or in a default path and update the path appropriately. See [Transforming Validators](#transforming-validators) for more details
434   -- `CLI::Range(min,max)`: Requires that the option be between min and max (make sure to use floating point if needed). Min defaults to 0.
435   -- `CLI::Bounded(min,max)`: Modify the input such that it is always between min and max (make sure to use floating point if needed). Min defaults to 0. Will produce an error if conversion is not possible.
  661 +- `CLI::FileOnDefaultPath`: ๐Ÿ†• Best used as a transform, Will check that a file
  662 + exists either directly or in a default path and update the path appropriately.
  663 + See [Transforming Validators](#transforming-validators) for more details
  664 +- `CLI::Range(min,max)`: Requires that the option be between min and max (make
  665 + sure to use floating point if needed). Min defaults to 0.
  666 +- `CLI::Bounded(min,max)`: Modify the input such that it is always between min
  667 + and max (make sure to use floating point if needed). Min defaults to 0. Will
  668 + produce an error if conversion is not possible.
436 669 - `CLI::PositiveNumber`: Requires the number be greater than 0
437 670 - `CLI::NonNegativeNumber`: Requires the number be greater or equal to 0
438 671 - `CLI::Number`: Requires the input be a number.
439   -- `CLI::ValidIPV4`: Requires that the option be a valid IPv4 string e.g. `'255.255.255.255'`, `'10.1.1.7'`.
440   -- `CLI::TypeValidator<TYPE>`:Requires that the option be convertible to the specified type e.g. `CLI::TypeValidator<unsigned int>()` would require that the input be convertible to an `unsigned int` regardless of the end conversion.
  672 +- `CLI::ValidIPV4`: Requires that the option be a valid IPv4 string e.g.
  673 + `'255.255.255.255'`, `'10.1.1.7'`.
  674 +- `CLI::TypeValidator<TYPE>`:Requires that the option be convertible to the
  675 + specified type e.g. `CLI::TypeValidator<unsigned int>()` would require that
  676 + the input be convertible to an `unsigned int` regardless of the end
  677 + conversion.
441 678  
442   -These Validators can be used by simply passing the name into the `check` or `transform` methods on an option
  679 +These Validators can be used by simply passing the name into the `check` or
  680 +`transform` methods on an option
443 681  
444 682 ```cpp
445 683 ->check(CLI::ExistingFile);
... ... @@ -462,53 +700,116 @@ will produce a check for a number less than or equal to 0.
462 700  
463 701 ##### Transforming Validators
464 702  
465   -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.
466   -
467   -- `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`
468   -- 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.
469   -
470   -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. Here are some examples of `IsMember`:
  703 +There are a few built in Validators that let you transform values if used with
  704 +the `transform` function. If they also do some checks then they can be used
  705 +`check` but some may do nothing in that case.
  706 +
  707 +- `CLI::Bounded(min,max)` will bound values between min and max and values
  708 + outside of that range are limited to min or max, it will fail if the value
  709 + cannot be converted and produce a `ValidationError`
  710 +- The `IsMember` Validator lets you specify a set of predefined options. You can
  711 + pass any container or copyable pointer (including `std::shared_ptr`) to a
  712 + container to this Validator; the container just needs to be iterable and have
  713 + a `::value_type`. The key type should be convertible from a string, You can
  714 + use an initializer list directly if you like. If you need to modify the set
  715 + later, the pointer form lets you do that; the type message and check will
  716 + correctly refer to the current version of the set. The container passed in can
  717 + be a set, vector, or a map like structure. If used in the `transform` method
  718 + the output value will be the matching key as it could be modified by filters.
  719 +
  720 +After specifying a set of options, you can also specify "filter" functions of
  721 +the form `T(T)`, where `T` is the type of the values. The most common choices
  722 +probably will be `CLI::ignore_case` an `CLI::ignore_underscore`, and
  723 +`CLI::ignore_space`. These all work on strings but it is possible to define
  724 +functions that work on other types. Here are some examples of `IsMember`:
471 725  
472 726 - `CLI::IsMember({"choice1", "choice2"})`: Select from exact match to choices.
473   -- `CLI::IsMember({"choice1", "choice2"}, CLI::ignore_case, CLI::ignore_underscore)`: Match things like `Choice_1`, too.
474   -- `CLI::IsMember(std::set<int>({2,3,4}))`: Most containers and types work; you just need `std::begin`, `std::end`, and `::value_type`.
475   -- `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.
476   -- `auto p = std::make_shared<std::vector<std::string>>(std::initializer_list<std::string>("one", "two")); CLI::IsMember(p)`: You can modify `p` later.
477   -- 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.
478   -
479   -After specifying a map of options, you can also specify "filter" just like in `CLI::IsMember`.
480   -Here are some examples (`Transformer` and `CheckedTransformer` are interchangeable in the examples)
481   -of `Transformer`:
482   -
483   -- `CLI::Transformer({{"key1", "map1"},{"key2","map2"}})`: Select from key values and produce map values.
484   -- `CLI::Transformer(std::map<std::string,int>({"two",2},{"three",3},{"four",4}}))`: most maplike containers work, the `::value_type` needs to produce a pair of some kind.
485   -- `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.
486   -- `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>>`
487   -
488   -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.
489   -
490   -- `CLI::FileOnDefaultPath(default_path)`: ๐Ÿ†• can be used to check for files in a default path. If used as a transform it will first check that a file exists, if it does nothing further is done, if it does not it tries to add a default Path to the file and search there again. If the file does not exist an error is returned normally but this can be disabled using CLI::FileOnDefaultPath(default_path, false). This allows multiple paths to be chained using multiple transform calls.
  727 +- `CLI::IsMember({"choice1", "choice2"}, CLI::ignore_case, CLI::ignore_underscore)`:
  728 + Match things like `Choice_1`, too.
  729 +- `CLI::IsMember(std::set<int>({2,3,4}))`: Most containers and types work; you
  730 + just need `std::begin`, `std::end`, and `::value_type`.
  731 +- `CLI::IsMember(std::map<std::string, TYPE>({{"one", 1}, {"two", 2}}))`: You
  732 + can use maps; in `->transform()` these replace the matched value with the
  733 + matched key. The value member of the map is not used in `IsMember`, so it can
  734 + be any type.
  735 +- `auto p = std::make_shared<std::vector<std::string>>(std::initializer_list<std::string>("one", "two")); CLI::IsMember(p)`:
  736 + You can modify `p` later.
  737 +- The `Transformer` and `CheckedTransformer` Validators transform one value into
  738 + another. Any container or copyable pointer (including `std::shared_ptr`) to a
  739 + container that generates pairs of values can be passed to these `Validator's`;
  740 + the container just needs to be iterable and have a `::value_type` that
  741 + consists of pairs. The key type should be convertible from a string, and the
  742 + value type should be convertible to a string You can use an initializer list
  743 + directly if you like. If you need to modify the map later, the pointer form
  744 + lets you do that; the description message will correctly refer to the current
  745 + version of the map. `Transformer` does not do any checking so values not in
  746 + the map are ignored. `CheckedTransformer` takes an extra step of verifying
  747 + that the value is either one of the map key values, in which case it is
  748 + transformed, or one of the expected output values, and if not will generate a
  749 + `ValidationError`. A Transformer placed using `check` will not do anything.
  750 +
  751 +After specifying a map of options, you can also specify "filter" just like in
  752 +`CLI::IsMember`. Here are some examples (`Transformer` and `CheckedTransformer`
  753 +are interchangeable in the examples) of `Transformer`:
  754 +
  755 +- `CLI::Transformer({{"key1", "map1"},{"key2","map2"}})`: Select from key values
  756 + and produce map values.
  757 +- `CLI::Transformer(std::map<std::string,int>({"two",2},{"three",3},{"four",4}}))`:
  758 + most maplike containers work, the `::value_type` needs to produce a pair of
  759 + some kind.
  760 +- `CLI::CheckedTransformer(std::map<std::string, int>({{"one", 1}, {"two", 2}}))`:
  761 + You can use maps; in `->transform()` these replace the matched key with the
  762 + value. `CheckedTransformer` also requires that the value either match one of
  763 + the keys or match one of known outputs.
  764 +- `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)`:
  765 + You can modify `p` later. `TransformPairs<T>` is an alias for
  766 + `std::vector<std::pair<<std::string,T>>`
  767 +
  768 +NOTES: If the container used in `IsMember`, `Transformer`, or
  769 +`CheckedTransformer` has a `find` function like `std::unordered_map` or
  770 +`std::map` then that function is used to do the searching. If it does not have a
  771 +`find` function a linear search is performed. If there are filters present, the
  772 +fast search is performed first, and if that fails a linear search with the
  773 +filters on the key values is performed.
  774 +
  775 +- `CLI::FileOnDefaultPath(default_path)`: ๐Ÿ†• can be used to check for files in a
  776 + default path. If used as a transform it will first check that a file exists,
  777 + if it does nothing further is done, if it does not it tries to add a default
  778 + Path to the file and search there again. If the file does not exist an error
  779 + is returned normally but this can be disabled using
  780 + `CLI::FileOnDefaultPath(default_path, false)`. This allows multiple paths to
  781 + be chained using multiple transform calls.
491 782  
492 783 ##### Validator operations
493 784  
494   -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)`.
495   -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)`
496   -The operation function of a Validator can be set via
497   -`.operation(std::function<std::string(std::string &>)`. The `.active()` function can activate or deactivate a Validator from the operation. A validator can be set to apply only to a specific element of the output. For example in a pair option `std::pair<int, std::string>` the first element may need to be a positive integer while the second may need to be a valid file. The `.application_index(int)` function can specify this. It is zero based and negative indices apply to all values.
  785 +Validators are copyable and have a few operations that can be performed on them
  786 +to alter settings. Most of the built in Validators have a default description
  787 +that is displayed in the help. This can be altered via
  788 +`.description(validator_description)`. The name of a Validator, which is useful
  789 +for later reference from the `get_validator(name)` method of an `Option` can be
  790 +set via `.name(validator_name)` The operation function of a Validator can be set
  791 +via `.operation(std::function<std::string(std::string &>)`. The `.active()`
  792 +function can activate or deactivate a Validator from the operation. A validator
  793 +can be set to apply only to a specific element of the output. For example in a
  794 +pair option `std::pair<int, std::string>` the first element may need to be a
  795 +positive integer while the second may need to be a valid file. The
  796 +`.application_index(int)` function can specify this. It is zero based and
  797 +negative indices apply to all values.
498 798  
499 799 ```cpp
500 800 opt->check(CLI::Validator(CLI::PositiveNumber).application_index(0));
501 801 opt->check(CLI::Validator(CLI::ExistingFile).application_index(1));
502 802 ```
503 803  
504   -All the validator operation functions return a Validator reference allowing them to be chained. For example
  804 +All the validator operation functions return a Validator reference allowing them
  805 +to be chained. For example
505 806  
506 807 ```cpp
507 808 opt->check(CLI::Range(10,20).description("range is limited to sensible values").active(false).name("range"));
508 809 ```
509 810  
510   -will specify a check on an option with a name "range", but deactivate it for the time being.
511   -The check can later be activated through
  811 +will specify a check on an option with a name "range", but deactivate it for the
  812 +time being. The check can later be activated through
512 813  
513 814 ```cpp
514 815 opt->get_validator("range")->active();
... ... @@ -528,7 +829,8 @@ or if the operation function is set later they can be created with
528 829 CLI::Validator(validator_description);
529 830 ```
530 831  
531   -It is also possible to create a subclass of `CLI::Validator`, in which case it can also set a custom description function, and operation function.
  832 +It is also possible to create a subclass of `CLI::Validator`, in which case it
  833 +can also set a custom description function, and operation function.
532 834  
533 835 ##### Querying Validators
534 836  
... ... @@ -538,7 +840,9 @@ Once loaded into an Option, a pointer to a named Validator can be retrieved via
538 840 opt->get_validator(name);
539 841 ```
540 842  
541   -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.
  843 +This will retrieve a Validator with the given name or throw a
  844 +`CLI::OptionNotFound` error. If no name is given or name is empty the first
  845 +unnamed Validator will be returned or the first Validator if there is only one.
542 846  
543 847 or
544 848  
... ... @@ -546,108 +850,265 @@ or
546 850 opt->get_validator(index);
547 851 ```
548 852  
549   -Which will return a validator in the index it is applied which isn't necessarily the order in which was defined. The pointer can be `nullptr` if an invalid index is given.
550   -Validators have a few functions to query the current values:
  853 +Which will return a validator in the index it is applied which isn't necessarily
  854 +the order in which was defined. The pointer can be `nullptr` if an invalid index
  855 +is given. Validators have a few functions to query the current values:
551 856  
552 857 - `get_description()`: Will return a description string
553 858 - `get_name()`: Will return the Validator name
554   -- `get_active()`: Will return the current active state, true if the Validator is active.
  859 +- `get_active()`: Will return the current active state, true if the Validator is
  860 + active.
555 861 - `get_application_index()`: Will return the current application index.
556   -- `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.
  862 +- `get_modifying()`: Will return true if the Validator is allowed to modify the
  863 + input, this can be controlled via the `non_modifying()` method, though it is
  864 + recommended to let `check` and `transform` option methods manipulate it if
  865 + needed.
557 866  
558 867 #### Getting results
559 868  
560   -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:
561   -
562   -- `->results()`: Retrieves a vector of strings with all the results in the order they were given.
563   -- `->results(variable_to_bind_to)`: Gets the results according to the MultiOptionPolicy and converts them just like the `add_option_function` with a variable.
564   -- `Value=opt->as<type>()`: Returns the result or default value directly as the specified type if possible, can be vector to return all results, and a non-vector to get the result according to the MultiOptionPolicy in place.
  869 +In most cases, the fastest and easiest way is to return the results through a
  870 +callback or variable specified in one of the `add_*` functions. But there are
  871 +situations where this is not possible or desired. For these cases the results
  872 +may be obtained through one of the following functions. Please note that these
  873 +functions will do any type conversions and processing during the call so should
  874 +not used in performance critical code:
  875 +
  876 +- `->results()`: Retrieves a vector of strings with all the results in the order
  877 + they were given.
  878 +- `->results(variable_to_bind_to)`: Gets the results according to the
  879 + MultiOptionPolicy and converts them just like the `add_option_function` with a
  880 + variable.
  881 +- `Value=opt->as<type>()`: Returns the result or default value directly as the
  882 + specified type if possible, can be vector to return all results, and a
  883 + non-vector to get the result according to the MultiOptionPolicy in place.
565 884  
566 885 ### Subcommands
567 886  
568   -Subcommands are supported, and can be nested infinitely. To add a subcommand, call the `add_subcommand` method with a name and an optional description. This gives a pointer to an `App` that behaves just like the main app, and can take options or further subcommands. Add `->ignore_case()` to a subcommand to allow any variation of caps to also be accepted. `->ignore_underscore()` is similar, but for underscores. Children inherit the current setting from the parent. You cannot add multiple matching subcommand names at the same level (including `ignore_case` and `ignore_underscore`).
569   -
570   -If you want to require that at least one subcommand is given, use `.require_subcommand()` on the parent app. You can optionally give an exact number of subcommands to require, as well. If you give two arguments, that sets the min and max number allowed.
571   -0 for the max number allowed will allow an unlimited number of subcommands. As a handy shortcut, a single negative value N will set "up to N" values. Limiting the maximum number allows you to keep arguments that match a previous
572   -subcommand name from matching.
573   -
574   -If an `App` (main or subcommand) has been parsed on the command line, `->parsed` will be true (or convert directly to bool).
575   -All `App`s have a `get_subcommands()` method, which returns a list of pointers to the subcommands passed on the command line. A `got_subcommand(App_or_name)` method is also provided that will check to see if an `App` pointer or a string name was collected on the command line.
576   -
577   -For many cases, however, using an app's callback capabilities may be easier. Every app has a set of callbacks that can be executed at various stages of parsing; a `C++` lambda function (with capture to get parsed values) can be used as input to the callback definition function. If you throw `CLI::Success` or `CLI::RuntimeError(return_value)`, you can
578   -even exit the program through the callback.
579   -
580   -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 or the callback is specified through the `parse_complete_callback()` function. The `final_callback()` is triggered only once. 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.
581   -
582   -Subcommands may also have an empty name either by calling `add_subcommand` with an empty string for the name or with no arguments.
583   -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. Subcommand names given through the `add_subcommand` method have the same restrictions as option names.
  887 +Subcommands are supported, and can be nested infinitely. To add a subcommand,
  888 +call the `add_subcommand` method with a name and an optional description. This
  889 +gives a pointer to an `App` that behaves just like the main app, and can take
  890 +options or further subcommands. Add `->ignore_case()` to a subcommand to allow
  891 +any variation of caps to also be accepted. `->ignore_underscore()` is similar,
  892 +but for underscores. Children inherit the current setting from the parent. You
  893 +cannot add multiple matching subcommand names at the same level (including
  894 +`ignore_case` and `ignore_underscore`).
  895 +
  896 +If you want to require that at least one subcommand is given, use
  897 +`.require_subcommand()` on the parent app. You can optionally give an exact
  898 +number of subcommands to require, as well. If you give two arguments, that sets
  899 +the min and max number allowed. 0 for the max number allowed will allow an
  900 +unlimited number of subcommands. As a handy shortcut, a single negative value N
  901 +will set "up to N" values. Limiting the maximum number allows you to keep
  902 +arguments that match a previous subcommand name from matching.
  903 +
  904 +If an `App` (main or subcommand) has been parsed on the command line, `->parsed`
  905 +will be true (or convert directly to bool). All `App`s have a
  906 +`get_subcommands()` method, which returns a list of pointers to the subcommands
  907 +passed on the command line. A `got_subcommand(App_or_name)` method is also
  908 +provided that will check to see if an `App` pointer or a string name was
  909 +collected on the command line.
  910 +
  911 +For many cases, however, using an app's callback capabilities may be easier.
  912 +Every app has a set of callbacks that can be executed at various stages of
  913 +parsing; a `C++` lambda function (with capture to get parsed values) can be used
  914 +as input to the callback definition function. If you throw `CLI::Success` or
  915 +`CLI::RuntimeError(return_value)`, you can even exit the program through the
  916 +callback.
  917 +
  918 +Multiple subcommands are allowed, to allow [`Click`][click] like series of
  919 +commands (order is preserved). The same subcommand can be triggered multiple
  920 +times but all positional arguments will take precedence over the second and
  921 +future calls of the subcommand. `->count()` on the subcommand will return the
  922 +number of times the subcommand was called. The subcommand callback will only be
  923 +triggered once unless the `.immediate_callback()` flag is set or the callback is
  924 +specified through the `parse_complete_callback()` function. The
  925 +`final_callback()` is triggered only once. In which case the callback executes
  926 +on completion of the subcommand arguments but after the arguments for that
  927 +subcommand have been parsed, and can be triggered multiple times.
  928 +
  929 +Subcommands may also have an empty name either by calling `add_subcommand` with
  930 +an empty string for the name or with no arguments. Nameless subcommands function
  931 +a similarly to groups in the main `App`. See [Option groups](#option-groups) to
  932 +see how this might work. If an option is not defined in the main App, all
  933 +nameless subcommands are checked as well. This allows for the options to be
  934 +defined in a composable group. The `add_subcommand` function has an overload for
  935 +adding a `shared_ptr<App>` so the subcommand(s) could be defined in different
  936 +components and merged into a main `App`, or possibly multiple `Apps`. Multiple
  937 +nameless subcommands are allowed. Callbacks for nameless subcommands are only
  938 +triggered if any options from the subcommand were parsed. Subcommand names given
  939 +through the `add_subcommand` method have the same restrictions as option names.
584 940  
585 941 #### Subcommand options
586 942  
587   -There are several options that are supported on the main app and subcommands and option_groups. These are:
588   -
589   -- `.ignore_case()`: Ignore the case of this subcommand. Inherited by added subcommands, so is usually used on the main `App`.
590   -- `.ignore_underscore()`: Ignore any underscores in the subcommand name. Inherited by added subcommands, so is usually used on the main `App`.
591   -- `.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`.
592   -- `.fallthrough()`: Allow extra unmatched options and positionals to "fall through" and be matched on a parent option. Subcommands always are allowed to "fall through" as in they will first attempt to match on the current subcommand and if they fail will progressively check parents for matching subcommands.
593   -- `.configurable()`: Allow the subcommand to be triggered from a configuration file. By default subcommand options in a configuration file do not trigger a subcommand but will just update default values.
594   -- `.disable()`: Specify that the subcommand is disabled, if given with a bool value it will enable or disable the subcommand or option group.
595   -- `.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.
596   -- `.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.
597   -- `.silent()`: Specify that the subcommand is silent meaning that if used it won't show up in the subcommand list. This allows the use of subcommands as modifiers
598   -- `.validate_positionals()`: Specify that positionals should pass validation before matching. Validation is specified through `transform`, `check`, and `each` for an option. If an argument fails validation it is not an error and matching proceeds to the next available positional or extra arguments.
599   -- `.validate_optional_arguments()`:๐Ÿ†• Specify that optional arguments should pass validation before being assigned to an option. Validation is specified through `transform`, `check`, and `each` for an option. If an argument fails validation it is not an error and matching proceeds to the next available positional subcommand or extra arguments.
600   -- `.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.
601   -- `.needs(option_or_subcommand)`: If given an option pointer or pointer to another subcommand, the subcommands will require the given option to have been given before this subcommand is validated which occurs prior to execution of any callback or after parsing is completed.
  943 +There are several options that are supported on the main app and subcommands and
  944 +option_groups. These are:
  945 +
  946 +- `.ignore_case()`: Ignore the case of this subcommand. Inherited by added
  947 + subcommands, so is usually used on the main `App`.
  948 +- `.ignore_underscore()`: Ignore any underscores in the subcommand name.
  949 + Inherited by added subcommands, so is usually used on the main `App`.
  950 +- `.allow_windows_style_options()`: Allow command line options to be parsed in
  951 + the form of `/s /long /file:file_name.ext` This option does not change how
  952 + options are specified in the `add_option` calls or the ability to process
  953 + options in the form of `-s --long --file=file_name.ext`.
  954 +- `.fallthrough()`: Allow extra unmatched options and positionals to "fall
  955 + through" and be matched on a parent option. Subcommands always are allowed to
  956 + "fall through" as in they will first attempt to match on the current
  957 + subcommand and if they fail will progressively check parents for matching
  958 + subcommands.
  959 +- `.configurable()`: Allow the subcommand to be triggered from a configuration
  960 + file. By default subcommand options in a configuration file do not trigger a
  961 + subcommand but will just update default values.
  962 +- `.disable()`: Specify that the subcommand is disabled, if given with a bool
  963 + value it will enable or disable the subcommand or option group.
  964 +- `.disabled_by_default()`: Specify that at the start of parsing the
  965 + subcommand/option_group should be disabled. This is useful for allowing some
  966 + Subcommands to trigger others.
  967 +- `.enabled_by_default()`: Specify that at the start of each parse the
  968 + subcommand/option_group should be enabled. This is useful for allowing some
  969 + Subcommands to disable others.
  970 +- `.silent()`: Specify that the subcommand is silent meaning that if used it
  971 + won't show up in the subcommand list. This allows the use of subcommands as
  972 + modifiers
  973 +- `.validate_positionals()`: Specify that positionals should pass validation
  974 + before matching. Validation is specified through `transform`, `check`, and
  975 + `each` for an option. If an argument fails validation it is not an error and
  976 + matching proceeds to the next available positional or extra arguments.
  977 +- `.validate_optional_arguments()`:๐Ÿ†• Specify that optional arguments should
  978 + pass validation before being assigned to an option. Validation is specified
  979 + through `transform`, `check`, and `each` for an option. If an argument fails
  980 + validation it is not an error and matching proceeds to the next available
  981 + positional subcommand or extra arguments.
  982 +- `.excludes(option_or_subcommand)`: If given an option pointer or pointer to
  983 + another subcommand, these subcommands cannot be given together. In the case of
  984 + options, if the option is passed the subcommand cannot be used and will
  985 + generate an error.
  986 +- `.needs(option_or_subcommand)`: If given an option pointer or pointer to
  987 + another subcommand, the subcommands will require the given option to have been
  988 + given before this subcommand is validated which occurs prior to execution of
  989 + any callback or after parsing is completed.
602 990 - `.require_option()`: Require 1 or more options or option groups be used.
603   -- `.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.
604   -- `.require_option(min, max)`: Explicitly set min and max allowed options or option groups. Setting `max` to 0 implies unlimited options.
  991 +- `.require_option(N)`: Require `N` options or option groups, if `N>0`, or up to
  992 + `N` if `N<0`. `N=0` resets to the default to 0 or more.
  993 +- `.require_option(min, max)`: Explicitly set min and max allowed options or
  994 + option groups. Setting `max` to 0 implies unlimited options.
605 995 - `.require_subcommand()`: Require 1 or more subcommands.
606   -- `.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.
607   -- `.require_subcommand(min, max)`: Explicitly set min and max allowed subcommands. Setting `max` to 0 is unlimited.
608   -- `.add_subcommand(name="", description="")`: Add a subcommand, returns a pointer to the internally stored subcommand.
609   -- `.add_subcommand(shared_ptr<App>)`: Add a subcommand by shared_ptr, returns a pointer to the internally stored subcommand.
  996 +- `.require_subcommand(N)`: Require `N` subcommands if `N>0`, or up to `N` if
  997 + `N<0`. `N=0` resets to the default to 0 or more.
  998 +- `.require_subcommand(min, max)`: Explicitly set min and max allowed
  999 + subcommands. Setting `max` to 0 is unlimited.
  1000 +- `.add_subcommand(name="", description="")`: Add a subcommand, returns a
  1001 + pointer to the internally stored subcommand.
  1002 +- `.add_subcommand(shared_ptr<App>)`: Add a subcommand by shared_ptr, returns a
  1003 + pointer to the internally stored subcommand.
610 1004 - `.remove_subcommand(App)`: Remove a subcommand from the app or subcommand.
611   -- `.got_subcommand(App_or_name)`: Check to see if a subcommand was received on the command line.
612   -- `.get_subcommands(filter)`: The list of subcommands that match a particular filter function.
613   -- `.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.
  1005 +- `.got_subcommand(App_or_name)`: Check to see if a subcommand was received on
  1006 + the command line.
  1007 +- `.get_subcommands(filter)`: The list of subcommands that match a particular
  1008 + filter function.
  1009 +- `.add_option_group(name="", description="")`: Add an
  1010 + [option group](#option-groups) to an App, an option group is specialized
  1011 + subcommand intended for containing groups of options or other groups for
  1012 + controlling how options interact.
614 1013 - `.get_parent()`: Get the parent App or `nullptr` if called on main App.
615   -- `.get_option(name)`: Get an option pointer by option name will throw if the specified option is not available, nameless subcommands are also searched
616   -- `.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.
617   -- `.get_options(filter)`: Get the list of all defined option pointers (useful for processing the app for custom output formats).
618   -- `.parse_order()`: Get the list of option pointers in the order they were parsed (including duplicates).
619   -- `.formatter(fmt)`: Set a formatter, with signature `std::string(const App*, std::string, AppFormatMode)`. See Formatting for more details.
  1014 +- `.get_option(name)`: Get an option pointer by option name will throw if the
  1015 + specified option is not available, nameless subcommands are also searched
  1016 +- `.get_option_no_throw(name)`: Get an option pointer by option name. This
  1017 + function will return a `nullptr` instead of throwing if the option is not
  1018 + available.
  1019 +- `.get_options(filter)`: Get the list of all defined option pointers (useful
  1020 + for processing the app for custom output formats).
  1021 +- `.parse_order()`: Get the list of option pointers in the order they were
  1022 + parsed (including duplicates).
  1023 +- `.formatter(fmt)`: Set a formatter, with signature
  1024 + `std::string(const App*, std::string, AppFormatMode)`. See Formatting for more
  1025 + details.
620 1026 - `.description(str)`: Set/change the description.
621 1027 - `.get_description()`: Access the description.
622   -- `.alias(str)`: set an alias for the subcommand, this allows subcommands to be called by more than one name.
  1028 +- `.alias(str)`: set an alias for the subcommand, this allows subcommands to be
  1029 + called by more than one name.
623 1030 - `.parsed()`: True if this subcommand was given on the command line.
624 1031 - `.count()`: Returns the number of times the subcommand was called.
625   -- `.count(option_name)`: Returns the number of times a particular option was called.
626   -- `.count_all()`: Returns the total number of arguments a particular subcommand processed, on the main App it returns the total number of processed commands.
  1032 +- `.count(option_name)`: Returns the number of times a particular option was
  1033 + called.
  1034 +- `.count_all()`: Returns the total number of arguments a particular subcommand
  1035 + processed, on the main App it returns the total number of processed commands.
627 1036 - `.name(name)`: Add or change the name.
628   -- `.callback(void() function)`: Set the callback for an app. Either sets the `pre_parse_callback` or the `final_callback` depending on the value of `immediate_callback`. See [Subcommand callbacks](#callbacks) for some additional details.
629   -- `.parse_complete_callback(void() function)`: Set the callback that runs at the completion of parsing. For subcommands this is executed at the completion of the single subcommand and can be executed multiple times. See [Subcommand callbacks](#callbacks) for some additional details.
630   -- `.final_callback(void() function)`: Set the callback that runs at the end of all processing. This is the last thing that is executed before returning. See [Subcommand callbacks](#callbacks) for some additional details.
631   -- `.immediate_callback()`: Specifies whether the callback for a subcommand should be run as a `parse_complete_callback`(true) or `final_callback`(false). When used on the main app it will execute the main app callback prior to the callbacks for a subcommand if they do not also have the `immediate_callback` flag set. It is preferable to use the `parse_complete_callback` or `final_callback` directly instead of the `callback` and `immediate_callback` if one wishes to control the ordering and timing of callback. Though `immediate_callback` can be used to swap them if that is needed.
632   -- `.pre_parse_callback(void(std::size_t) function)`: Set a callback that executes after the first argument of an application is processed. See [Subcommand callbacks](#callbacks) for some additional details.
  1037 +- `.callback(void() function)`: Set the callback for an app. Either sets the
  1038 + `pre_parse_callback` or the `final_callback` depending on the value of
  1039 + `immediate_callback`. See [Subcommand callbacks](#callbacks) for some
  1040 + additional details.
  1041 +- `.parse_complete_callback(void() function)`: Set the callback that runs at the
  1042 + completion of parsing. For subcommands this is executed at the completion of
  1043 + the single subcommand and can be executed multiple times. See
  1044 + [Subcommand callbacks](#callbacks) for some additional details.
  1045 +- `.final_callback(void() function)`: Set the callback that runs at the end of
  1046 + all processing. This is the last thing that is executed before returning. See
  1047 + [Subcommand callbacks](#callbacks) for some additional details.
  1048 +- `.immediate_callback()`: Specifies whether the callback for a subcommand
  1049 + should be run as a `parse_complete_callback`(true) or `final_callback`(false).
  1050 + When used on the main app it will execute the main app callback prior to the
  1051 + callbacks for a subcommand if they do not also have the `immediate_callback`
  1052 + flag set. It is preferable to use the `parse_complete_callback` or
  1053 + `final_callback` directly instead of the `callback` and `immediate_callback`
  1054 + if one wishes to control the ordering and timing of callback. Though
  1055 + `immediate_callback` can be used to swap them if that is needed.
  1056 +- `.pre_parse_callback(void(std::size_t) function)`: Set a callback that
  1057 + executes after the first argument of an application is processed. See
  1058 + [Subcommand callbacks](#callbacks) for some additional details.
633 1059 - `.allow_extras()`: Do not throw an error if extra arguments are left over.
634   -- `.positionals_at_end()`: Specify that positional arguments occur as the last arguments and throw an error if an unexpected positional is encountered.
635   -- `.prefix_command()`: Like `allow_extras`, but stop immediately on the first unrecognized item. It is ideal for allowing your app or subcommand to be a "prefix" to calling another app.
  1060 +- `.positionals_at_end()`: Specify that positional arguments occur as the last
  1061 + arguments and throw an error if an unexpected positional is encountered.
  1062 +- `.prefix_command()`: Like `allow_extras`, but stop immediately on the first
  1063 + unrecognized item. It is ideal for allowing your app or subcommand to be a
  1064 + "prefix" to calling another app.
636 1065 - `.footer(message)`: Set text to appear at the bottom of the help string.
637   -- `.footer(std::string())`: Set a callback to generate a string that will appear at the end of the help string.
638   -- `.set_help_flag(name, message)`: Set the help flag name and message, returns a pointer to the created option.
639   -- `.set_version_flag(name, versionString or callback, help_message)`: Set the version flag name and version string or callback and optional help message, returns a pointer to the created option.
640   -- `.set_help_all_flag(name, message)`: Set the help all flag name and message, returns a pointer to the created option. Expands subcommands.
641   -- `.failure_message(func)`: Set the failure message function. Two provided: `CLI::FailureMessage::help` and `CLI::FailureMessage::simple` (the default).
642   -- `.group(name)`: Set a group name, defaults to `"Subcommands"`. Setting `""` will be hide the subcommand.
643   -- `[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. The operation will throw an exception if the option name is not valid.
644   -
645   -> 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.
  1066 +- `.footer(std::string())`: Set a callback to generate a string that will appear
  1067 + at the end of the help string.
  1068 +- `.set_help_flag(name, message)`: Set the help flag name and message, returns a
  1069 + pointer to the created option.
  1070 +- `.set_version_flag(name, versionString or callback, help_message)`: Set the
  1071 + version flag name and version string or callback and optional help message,
  1072 + returns a pointer to the created option.
  1073 +- `.set_help_all_flag(name, message)`: Set the help all flag name and message,
  1074 + returns a pointer to the created option. Expands subcommands.
  1075 +- `.failure_message(func)`: Set the failure message function. Two provided:
  1076 + `CLI::FailureMessage::help` and `CLI::FailureMessage::simple` (the default).
  1077 +- `.group(name)`: Set a group name, defaults to `"Subcommands"`. Setting `""`
  1078 + will be hide the subcommand.
  1079 +- `[option_name]`: retrieve a const pointer to an option given by `option_name`
  1080 + for Example `app["--flag1"]` will get a pointer to the option for the
  1081 + "--flag1" value, `app["--flag1"]->as<bool>()` will get the results of the
  1082 + command line for a flag. The operation will throw an exception if the option
  1083 + name is not valid.
  1084 +
  1085 +> Note: if you have a fixed number of required positional options, that will
  1086 +> match before subcommand names. `{}` is an empty filter function, and any
  1087 +> positional argument will match before repeated subcommand names.
646 1088  
647 1089 #### Callbacks
648 1090  
649   -A subcommand has three 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.
650   -The second callback is executed after parsing. This is known as the `parse_complete_callback`. For subcommands this is executed immediately after parsing and can be executed multiple times if a subcommand is called multiple times. On the main app this callback is executed after all the `parse_complete_callback`s for the subcommands are executed but prior to any `final_callback` calls in the subcommand or option groups. If the main app or subcommand has a config file, no data from the config file will be reflected in `parse_complete_callback` on named subcommands. For `option_group`s the `parse_complete_callback` is executed prior to the `parse_complete_callback` on the main app but after the `config_file` is loaded (if specified). The `final_callback` is executed after all processing is complete. After the `parse_complete_callback` is executed on the main app, the used subcommand `final_callback` are executed followed by the "final callback" for option groups. The last thing to execute is the `final_callback` for the `main_app`.
  1091 +A subcommand has three optional callbacks that are executed at different stages
  1092 +of processing. The `preparse_callback` is executed once after the first argument
  1093 +of a subcommand or application is processed and gives an argument for the number
  1094 +of remaining arguments to process. For the main app the first argument is
  1095 +considered the program name, for subcommands the first argument is the
  1096 +subcommand name. For Option groups and nameless subcommands the first argument
  1097 +is after the first argument or subcommand is processed from that group. The
  1098 +second callback is executed after parsing. This is known as the
  1099 +`parse_complete_callback`. For subcommands this is executed immediately after
  1100 +parsing and can be executed multiple times if a subcommand is called multiple
  1101 +times. On the main app this callback is executed after all the
  1102 +`parse_complete_callback`s for the subcommands are executed but prior to any
  1103 +`final_callback` calls in the subcommand or option groups. If the main app or
  1104 +subcommand has a config file, no data from the config file will be reflected in
  1105 +`parse_complete_callback` on named subcommands. For `option_group`s the
  1106 +`parse_complete_callback` is executed prior to the `parse_complete_callback` on
  1107 +the main app but after the `config_file` is loaded (if specified). The
  1108 +`final_callback` is executed after all processing is complete. After the
  1109 +`parse_complete_callback` is executed on the main app, the used subcommand
  1110 +`final_callback` are executed followed by the "final callback" for option
  1111 +groups. The last thing to execute is the `final_callback` for the `main_app`.
651 1112 For example say an application was set up like
652 1113  
653 1114 ```cpp
... ... @@ -667,22 +1128,30 @@ program --opt1 opt1_val sub1 --sub1opt --sub1optb val sub2 --sub2opt sub1 --sub
667 1128 ```
668 1129  
669 1130 - `pa` will be called prior to parsing any values with an argument of 13.
670   -- `pc1` will be called immediately after processing the `sub1` command with a value of 10.
  1131 +- `pc1` will be called immediately after processing the `sub1` command with a
  1132 + value of 10.
671 1133 - `c1` will be called when the `sub2` command is encountered.
672 1134 - `pc2` will be called with value of 6 after the `sub2` command is encountered.
673 1135 - `c1` will be called again after the second `sub2` command is encountered.
674 1136 - `ac1` will be called after processing of all arguments
675 1137 - `c2` will be called once after processing all arguments.
676   -- `ac2` will be called last after completing all lower level callbacks have been executed.
  1138 +- `ac2` will be called last after completing all lower level callbacks have been
  1139 + executed.
677 1140  
678   -A subcommand is considered terminated when one of the following conditions are met.
  1141 +A subcommand is considered terminated when one of the following conditions are
  1142 +met.
679 1143  
680 1144 1. There are no more arguments to process
681   -2. Another subcommand is encountered that would not fit in an optional slot of the subcommand
682   -3. The `positional_mark` (`--`) is encountered and there are no available positional slots in the subcommand.
  1145 +2. Another subcommand is encountered that would not fit in an optional slot of
  1146 + the subcommand
  1147 +3. The `positional_mark` (`--`) is encountered and there are no available
  1148 + positional slots in the subcommand.
683 1149 4. The `subcommand_terminator` mark (`++`) is encountered
684 1150  
685   -Prior to executed a `parse_complete_callback` all contained options are processed before the callback is triggered. If a subcommand with a `parse_complete_callback` is called again, then the contained options are reset, and can be triggered again.
  1151 +Prior to executed a `parse_complete_callback` all contained options are
  1152 +processed before the callback is triggered. If a subcommand with a
  1153 +`parse_complete_callback` is called again, then the contained options are reset,
  1154 +and can be triggered again.
686 1155  
687 1156 #### Option groups
688 1157  
... ... @@ -692,7 +1161,18 @@ The subcommand method
692 1161 .add_option_group(name,description)
693 1162 ```
694 1163  
695   -Will create an option group, and return a pointer to it. The argument for `description` is optional and can be omitted. 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 example](https://github.com/CLIUtils/CLI11/blob/main/examples/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. The name given in an option group must not contain newlines or null characters.
  1164 +Will create an option group, and return a pointer to it. The argument for
  1165 +`description` is optional and can be omitted. An option group allows creation of
  1166 +a collection of options, similar to the groups function on options, but with
  1167 +additional controls and requirements. They allow specific sets of options to be
  1168 +composed and controlled as a collective. For an example see
  1169 +[range example](https://github.com/CLIUtils/CLI11/blob/main/examples/ranges.cpp).
  1170 +Option groups are a specialization of an App so all
  1171 +[functions](#subcommand-options) that work with an App or subcommand also work
  1172 +on option groups. Options can be created as part of an option group using the
  1173 +add functions just like a subcommand, or previously created options can be added
  1174 +through. The name given in an option group must not contain newlines or null
  1175 +characters.
696 1176  
697 1177 ```cpp
698 1178 ogroup->add_option(option_pointer);
... ... @@ -700,49 +1180,75 @@ ogroup-&gt;add_options(option_pointer);
700 1180 ogroup->add_options(option1,option2,option3,...);
701 1181 ```
702 1182  
703   -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
  1183 +The option pointers used in this function must be options defined in the parent
  1184 +application of the option group otherwise an error will be generated.
  1185 +Subcommands can also be added via
704 1186  
705 1187 ```cpp
706 1188 ogroup->add_subcommand(subcom_pointer);
707 1189 ```
708 1190  
709   -This results in the subcommand being moved from its parent into the option group.
710   -
711   -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.
712   -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.
713   -
714   -The `CLI::TriggerOn` and `CLI::TriggerOff` methods are helper functions to allow the use of options/subcommands from one group to trigger another group on or off.
  1191 +This results in the subcommand being moved from its parent into the option
  1192 +group.
  1193 +
  1194 +Options in an option group are searched for a command line match after any
  1195 +options in the main app, so any positionals in the main app would be matched
  1196 +first. So care must be taken to make sure of the order when using positional
  1197 +arguments and option groups. Option groups work well with `excludes` and
  1198 +`require_options` methods, as an application will treat an option group as a
  1199 +single option for the purpose of counting and requirements, and an option group
  1200 +will be considered used if any of the options or subcommands contained in it are
  1201 +used. Option groups allow specifying requirements such as requiring 1 of 3
  1202 +options in one group and 1 of 3 options in a different group. Option groups can
  1203 +contain other groups as well. Disabling an option group will turn off all
  1204 +options within the group.
  1205 +
  1206 +The `CLI::TriggerOn` and `CLI::TriggerOff` methods are helper functions to allow
  1207 +the use of options/subcommands from one group to trigger another group on or
  1208 +off.
715 1209  
716 1210 ```cpp
717 1211 CLI::TriggerOn(group1_pointer, triggered_group);
718 1212 CLI::TriggerOff(group2_pointer, disabled_group);
719 1213 ```
720 1214  
721   -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.
  1215 +These functions make use of `preparse_callback`, `enabled_by_default()` and
  1216 +`disabled_by_default`. The triggered group may be a vector of group pointers.
  1217 +These methods should only be used once per group and will override any previous
  1218 +use of the underlying functions. More complex arrangements can be accomplished
  1219 +using similar methodology with a custom `preparse_callback` function that does
  1220 +more.
722 1221  
723   -Additional helper functions `deprecate_option` and `retire_option` are available to deprecate or retire options
  1222 +Additional helper functions `deprecate_option` and `retire_option` are available
  1223 +to deprecate or retire options
724 1224  
725 1225 ```cpp
726 1226 CLI::deprecate_option(option *, replacement_name="");
727 1227 CLI::deprecate_option(App,option_name,replacement_name="");
728 1228 ```
729 1229  
730   -will specify that the option is deprecated which will display a message in the help and a warning on first usage. Deprecated options function normally but will add a message in the help and display a warning on first use.
  1230 +will specify that the option is deprecated which will display a message in the
  1231 +help and a warning on first usage. Deprecated options function normally but will
  1232 +add a message in the help and display a warning on first use.
731 1233  
732 1234 ```cpp
733 1235 CLI::retire_option(App,option *);
734 1236 CLI::retire_option(App,option_name);
735 1237 ```
736 1238  
737   -will create an option that does nothing by default and will display a warning on first usage that the option is retired and has no effect. If the option exists it is replaces with a dummy option that takes the same arguments.
  1239 +will create an option that does nothing by default and will display a warning on
  1240 +first usage that the option is retired and has no effect. If the option exists
  1241 +it is replaces with a dummy option that takes the same arguments.
738 1242  
739   -If an empty string is passed the option group name the entire group will be hidden in the help results. For example.
  1243 +If an empty string is passed the option group name the entire group will be
  1244 +hidden in the help results. For example.
740 1245  
741 1246 ```cpp
742 1247 auto hidden_group=app.add_option_group("");
743 1248 ```
744 1249  
745   -will create a group such that no options in that group are displayed in the help string.
  1250 +will create a group such that no options in that group are displayed in the help
  1251 +string.
746 1252  
747 1253 ### Configuration file
748 1254  
... ... @@ -753,7 +1259,16 @@ app.set_config(option_name=&quot;&quot;,
753 1259 required=false)
754 1260 ```
755 1261  
756   -If this is called with no arguments, it will remove the configuration file option (like `set_help_flag`). Setting 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 [TOML][] format by default, though the default reader can also accept files in INI format as well. It should be noted that CLI11 does not contain a full TOML parser but can read strings from most TOML file and run them through the CLI11 parser. Other formats can be added by an adept user, some variations are available through customization points in the default formatter. An example of a TOML file:
  1262 +If this is called with no arguments, it will remove the configuration file
  1263 +option (like `set_help_flag`). Setting a configuration option is special. If it
  1264 +is present, it will be read along with the normal command line arguments. The
  1265 +file will be read if it exists, and does not throw an error unless `required` is
  1266 +`true`. Configuration files are in [TOML][] format by default, though the
  1267 +default reader can also accept files in INI format as well. It should be noted
  1268 +that CLI11 does not contain a full TOML parser but can read strings from most
  1269 +TOML file and run them through the CLI11 parser. Other formats can be added by
  1270 +an adept user, some variations are available through customization points in the
  1271 +default formatter. An example of a TOML file:
757 1272  
758 1273 ```toml
759 1274 # Comments are supported, using a #
... ... @@ -787,10 +1302,23 @@ in_subcommand = Wow
787 1302 sub.subcommand = true
788 1303 ```
789 1304  
790   -Spaces before and after the name and argument are ignored. Multiple arguments are separated by spaces. One set of quotes will be removed, preserving spaces (the same way the command line works). Boolean options can be `true`, `on`, `1`, `yes`, `enable`; or `false`, `off`, `0`, `no`, `disable` (case insensitive). Sections (and `.` separated names) are treated as subcommands (note: this does not necessarily mean that subcommand was passed, it just sets the "defaults"). You cannot set positional-only arguments. Subcommands can be triggered from configuration files if the `configurable` flag was set on the subcommand. Then the use of `[subcommand]` notation will trigger a subcommand and cause it to act as if it were on the command line.
791   -
792   -To print a configuration file from the passed
793   -arguments, use `.config_to_str(default_also=false, write_description=false)`, where `default_also` will also show any defaulted arguments, and `write_description` will include the app and option descriptions. See [Config files](https://cliutils.github.io/CLI11/book/chapters/config.html) for some additional details and customization points.
  1305 +Spaces before and after the name and argument are ignored. Multiple arguments
  1306 +are separated by spaces. One set of quotes will be removed, preserving spaces
  1307 +(the same way the command line works). Boolean options can be `true`, `on`, `1`,
  1308 +`yes`, `enable`; or `false`, `off`, `0`, `no`, `disable` (case insensitive).
  1309 +Sections (and `.` separated names) are treated as subcommands (note: this does
  1310 +not necessarily mean that subcommand was passed, it just sets the "defaults").
  1311 +You cannot set positional-only arguments. Subcommands can be triggered from
  1312 +configuration files if the `configurable` flag was set on the subcommand. Then
  1313 +the use of `[subcommand]` notation will trigger a subcommand and cause it to act
  1314 +as if it were on the command line.
  1315 +
  1316 +To print a configuration file from the passed arguments, use
  1317 +`.config_to_str(default_also=false, write_description=false)`, where
  1318 +`default_also` will also show any defaulted arguments, and `write_description`
  1319 +will include the app and option descriptions. See
  1320 +[Config files](https://cliutils.github.io/CLI11/book/chapters/config.html) for
  1321 +some additional details and customization points.
794 1322  
795 1323 If it is desired that multiple configuration be allowed. Use
796 1324  
... ... @@ -798,23 +1326,42 @@ If it is desired that multiple configuration be allowed. Use
798 1326 app.set_config("--config")->expected(1, X);
799 1327 ```
800 1328  
801   -Where X is some positive number and will allow up to `X` configuration files to be specified by separate `--config` arguments. Value strings with quote characters in it will be printed with a single quote. All other arguments will use double quote. Empty strings will use a double quoted argument. Numerical or boolean values are not quoted.
  1329 +Where X is some positive number and will allow up to `X` configuration files to
  1330 +be specified by separate `--config` arguments. Value strings with quote
  1331 +characters in it will be printed with a single quote. All other arguments will
  1332 +use double quote. Empty strings will use a double quoted argument. Numerical or
  1333 +boolean values are not quoted.
802 1334  
803   -For options or flags which allow 0 arguments to be passed using an empty string in the config file, `{}`, or `[]` will convert the result to the default value specified via `default_str` or `default_val` on the option ๐Ÿ†•. If no user specified default is given the result is an empty string or the converted value of an empty string.
  1335 +For options or flags which allow 0 arguments to be passed using an empty string
  1336 +in the config file, `{}`, or `[]` will convert the result to the default value
  1337 +specified via `default_str` or `default_val` on the option ๐Ÿ†•. If no user
  1338 +specified default is given the result is an empty string or the converted value
  1339 +of an empty string.
804 1340  
805   -NOTE: Transforms and checks can be used with the option pointer returned from set_config like any other option to validate the input if needed. It can also be used with the built in transform `CLI::FileOnDefaultPath` to look in a default path as well as the current one. For example
  1341 +NOTE: Transforms and checks can be used with the option pointer returned from
  1342 +set_config like any other option to validate the input if needed. It can also be
  1343 +used with the built in transform `CLI::FileOnDefaultPath` to look in a default
  1344 +path as well as the current one. For example
806 1345  
807 1346 ```cpp
808 1347 app.set_config("--config")->transform(CLI::FileOnDefaultPath("/to/default/path/"));
809 1348 ```
810 1349  
811   -See [Transforming Validators](#transforming-validators) for additional details on this validator. Multiple transforms or validators can be used either by multiple calls or using `|` operations with the transform.
  1350 +See [Transforming Validators](#transforming-validators) for additional details
  1351 +on this validator. Multiple transforms or validators can be used either by
  1352 +multiple calls or using `|` operations with the transform.
812 1353  
813 1354 ### Inheriting defaults
814 1355  
815   -Many of the defaults for subcommands and even options are inherited from their creators. The inherited default values for subcommands are `allow_extras`, `prefix_command`, `ignore_case`, `ignore_underscore`, `fallthrough`, `group`, `footer`,`immediate_callback` and maximum number of required subcommands. The help flag existence, name, and description are inherited, as well.
  1356 +Many of the defaults for subcommands and even options are inherited from their
  1357 +creators. The inherited default values for subcommands are `allow_extras`,
  1358 +`prefix_command`, `ignore_case`, `ignore_underscore`, `fallthrough`, `group`,
  1359 +`footer`,`immediate_callback` and maximum number of required subcommands. The
  1360 +help flag existence, name, and description are inherited, as well.
816 1361  
817   -Options have defaults for `group`, `required`, `multi_option_policy`, `ignore_case`, `ignore_underscore`, `delimiter`, and `disable_flag_override`. To set these defaults, you should set the `option_defaults()` object, for example:
  1362 +Options have defaults for `group`, `required`, `multi_option_policy`,
  1363 +`ignore_case`, `ignore_underscore`, `delimiter`, and `disable_flag_override`. To
  1364 +set these defaults, you should set the `option_defaults()` object, for example:
818 1365  
819 1366 ```cpp
820 1367 app.option_defaults()->required();
... ... @@ -825,32 +1372,74 @@ The default settings for options are inherited to subcommands, as well.
825 1372  
826 1373 ### Formatting
827 1374  
828   -The job of formatting help printouts is delegated to a formatter callable object on Apps and Options. You are free to replace either formatter by calling `formatter(fmt)` on an `App`, where fmt is any copyable callable with the correct signature.
829   -CLI11 comes with a default App formatter functional, `Formatter`. It is customizable; you can set `label(key, value)` to replace the default labels like `REQUIRED`, and `column_width(n)` to set the width of the columns before you add the functional to the app or option. You can also override almost any stage of the formatting process in a subclass of either formatter. If you want to make a new formatter from scratch, you can do
830   -that too; you just need to implement the correct signature. The first argument is a const pointer to the in question. The formatter will get a `std::string` usage name as the second option, and a `AppFormatMode` mode for the final option. It should return a `std::string`.
831   -
832   -The `AppFormatMode` can be `Normal`, `All`, or `Sub`, and it indicates the situation the help was called in. `Sub` is optional, but the default formatter uses it to make sure expanded subcommands are called with
833   -their own formatter since you can't access anything but the call operator once a formatter has been set.
  1375 +The job of formatting help printouts is delegated to a formatter callable object
  1376 +on Apps and Options. You are free to replace either formatter by calling
  1377 +`formatter(fmt)` on an `App`, where fmt is any copyable callable with the
  1378 +correct signature. CLI11 comes with a default App formatter functional,
  1379 +`Formatter`. It is customizable; you can set `label(key, value)` to replace the
  1380 +default labels like `REQUIRED`, and `column_width(n)` to set the width of the
  1381 +columns before you add the functional to the app or option. You can also
  1382 +override almost any stage of the formatting process in a subclass of either
  1383 +formatter. If you want to make a new formatter from scratch, you can do that
  1384 +too; you just need to implement the correct signature. The first argument is a
  1385 +const pointer to the in question. The formatter will get a `std::string` usage
  1386 +name as the second option, and a `AppFormatMode` mode for the final option. It
  1387 +should return a `std::string`.
  1388 +
  1389 +The `AppFormatMode` can be `Normal`, `All`, or `Sub`, and it indicates the
  1390 +situation the help was called in. `Sub` is optional, but the default formatter
  1391 +uses it to make sure expanded subcommands are called with their own formatter
  1392 +since you can't access anything but the call operator once a formatter has been
  1393 +set.
834 1394  
835 1395 ### Subclassing
836 1396  
837   -The App class was designed allow toolkits to subclass it, to provide preset default options (see above) and setup/teardown code. Subcommands remain an unsubclassed `App`, since those are not expected to need setup and teardown. The default `App` only adds a help flag, `-h,--help`, than can removed/replaced using `.set_help_flag(name, help_string)`. You can also set a help-all flag with `.set_help_all_flag(name, help_string)`; this will expand the subcommands (one level only). You can remove options if you have pointers to them using `.remove_option(opt)`. You can add a `pre_callback` override to customize the after parse
838   -but before run behavior, while
839   -still giving the user freedom to `callback` on the main app.
840   -
841   -The most important parse function is `parse(std::vector<std::string>)`, which takes a reversed list of arguments (so that `pop_back` processes the args in the correct order). `get_help_ptr` and `get_config_ptr` give you access to the help/config option pointers. The standard `parse` manually sets the name from the first argument, so it should not be in this vector. You can also use `parse(string, bool)` to split up and parse a single string; the optional boolean should be set to true if you are
842   -including the program name in the string, and false otherwise. The program name can contain spaces if it is an existing file, otherwise can be enclosed in quotes(single quote, double quote or backtick). Embedded quote characters can be escaped with `\`.
843   -
844   -Also, in a related note, the `App` you get a pointer to is stored in the parent `App` in a `shared_ptr`s (similar to `Option`s) and are deleted when the main `App` goes out of scope unless the object has another owner.
  1397 +The App class was designed allow toolkits to subclass it, to provide preset
  1398 +default options (see above) and setup/teardown code. Subcommands remain an
  1399 +unsubclassed `App`, since those are not expected to need setup and teardown. The
  1400 +default `App` only adds a help flag, `-h,--help`, than can removed/replaced
  1401 +using `.set_help_flag(name, help_string)`. You can also set a help-all flag with
  1402 +`.set_help_all_flag(name, help_string)`; this will expand the subcommands (one
  1403 +level only). You can remove options if you have pointers to them using
  1404 +`.remove_option(opt)`. You can add a `pre_callback` override to customize the
  1405 +after parse but before run behavior, while still giving the user freedom to
  1406 +`callback` on the main app.
  1407 +
  1408 +The most important parse function is `parse(std::vector<std::string>)`, which
  1409 +takes a reversed list of arguments (so that `pop_back` processes the args in the
  1410 +correct order). `get_help_ptr` and `get_config_ptr` give you access to the
  1411 +help/config option pointers. The standard `parse` manually sets the name from
  1412 +the first argument, so it should not be in this vector. You can also use
  1413 +`parse(string, bool)` to split up and parse a single string; the optional
  1414 +boolean should be set to true if you are including the program name in the
  1415 +string, and false otherwise. The program name can contain spaces if it is an
  1416 +existing file, otherwise can be enclosed in quotes(single quote, double quote or
  1417 +backtick). Embedded quote characters can be escaped with `\`.
  1418 +
  1419 +Also, in a related note, the `App` you get a pointer to is stored in the parent
  1420 +`App` in a `shared_ptr`s (similar to `Option`s) and are deleted when the main
  1421 +`App` goes out of scope unless the object has another owner.
845 1422  
846 1423 ### How it works
847 1424  
848   -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
849   -`false` if it failed.
850   -
851   -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>>`).
852   -
853   -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 of 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:
  1425 +Every `add_` option you have seen so far depends on one method that takes a
  1426 +lambda function. Each of these methods is just making a different lambda
  1427 +function with capture to populate the option. The function has full access to
  1428 +the vector of strings, so it knows how many times an option was passed or how
  1429 +many arguments it received. The lambda returns `true` if it could validate the
  1430 +option strings, and `false` if it failed.
  1431 +
  1432 +Other values can be added as long as they support `operator>>` (and defaults can
  1433 +be printed if they support `operator<<`). To add a new type, for example,
  1434 +provide a custom `operator>>` with an `istream` (inside the CLI namespace is
  1435 +fine if you don't want to interfere with an existing `operator>>`).
  1436 +
  1437 +If you wanted to extend this to support a completely new type, use a lambda or
  1438 +add a specialization of the `lexical_cast` function template in the namespace of
  1439 +the type you need to convert to. Some examples of some new parsers for
  1440 +`complex<double>` that support all of the features of a standard `add_options`
  1441 +call are in [one of the tests](./tests/NewParseTest.cpp). A simpler example is
  1442 +shown below:
854 1443  
855 1444 #### Example
856 1445  
... ... @@ -863,7 +1452,10 @@ app.add_option(&quot;--fancy-count&quot;, [](std::vector&lt;std::string&gt; val){
863 1452  
864 1453 ### Utilities
865 1454  
866   -There are a few other utilities that are often useful in CLI programming. These are in separate headers, and do not appear in `CLI11.hpp`, but are completely independent and can be used as needed. The `Timer`/`AutoTimer` class allows you to easily time a block of code, with custom print output.
  1455 +There are a few other utilities that are often useful in CLI programming. These
  1456 +are in separate headers, and do not appear in `CLI11.hpp`, but are completely
  1457 +independent and can be used as needed. The `Timer`/`AutoTimer` class allows you
  1458 +to easily time a block of code, with custom print output.
867 1459  
868 1460 ```cpp
869 1461 {
... ... @@ -872,12 +1464,18 @@ some_long_running_process();
872 1464 }
873 1465 ```
874 1466  
875   -This will create a timer with a title (default: `Timer`), and will customize the output using the predefined `Big` output (default: `Simple`). Because it is an `AutoTimer`, it will print out the time elapsed when the timer is destroyed at the end of the block. If you use `Timer` instead, you can use `to_string` or `std::cout << timer << std::endl;` to print the time. The print function can be any function that takes two strings, the title and the time, and returns a formatted
876   -string for printing.
  1467 +This will create a timer with a title (default: `Timer`), and will customize the
  1468 +output using the predefined `Big` output (default: `Simple`). Because it is an
  1469 +`AutoTimer`, it will print out the time elapsed when the timer is destroyed at
  1470 +the end of the block. If you use `Timer` instead, you can use `to_string` or
  1471 +`std::cout << timer << std::endl;` to print the time. The print function can be
  1472 +any function that takes two strings, the title and the time, and returns a
  1473 +formatted string for printing.
877 1474  
878 1475 ### Other libraries
879 1476  
880   -If you use the excellent [Rang][] library to add color to your terminal in a safe, multi-platform way, you can combine it with CLI11 nicely:
  1477 +If you use the excellent [Rang][] library to add color to your terminal in a
  1478 +safe, multi-platform way, you can combine it with CLI11 nicely:
881 1479  
882 1480 ```cpp
883 1481 std::atexit([](){std::cout << rang::style::reset;});
... ... @@ -889,9 +1487,11 @@ try {
889 1487 }
890 1488 ```
891 1489  
892   -This will print help in blue, errors in red, and will reset before returning the terminal to the user.
  1490 +This will print help in blue, errors in red, and will reset before returning the
  1491 +terminal to the user.
893 1492  
894   -If you are on a Unix-like system, and you'd like to handle control-c and color, you can add:
  1493 +If you are on a Unix-like system, and you'd like to handle control-c and color,
  1494 +you can add:
895 1495  
896 1496 ```cpp
897 1497 #include <csignal>
... ... @@ -915,41 +1515,88 @@ And, in your main function:
915 1515  
916 1516 ## API
917 1517  
918   -The API is [documented here][api-docs]. Also see the [CLI11 tutorial GitBook][gitbook].
  1518 +The API is [documented here][api-docs]. Also see the [CLI11 tutorial
  1519 +GitBook][gitbook].
919 1520  
920 1521 ## Examples
921 1522  
922   -Several short examples of different features are included in the repository. A brief description of each is included here
923   -
924   -- [callback_passthrough](https://github.com/CLIUtils/CLI11/blob/main/examples/callback_passthrough.cpp): Example of directly passing remaining arguments through to a callback function which generates a CLI11 application based on existing arguments.
925   -- [custom_parse](https://github.com/CLIUtils/CLI11/blob/main/examples/custom_parse.cpp): Based on [Issue #566](https://github.com/CLIUtils/CLI11/issues/566), example of custom parser
926   -- [digit_args](https://github.com/CLIUtils/CLI11/blob/main/examples/digit_args.cpp): Based on [Issue #123](https://github.com/CLIUtils/CLI11/issues/123), uses digit flags to pass a value
927   -- [enum](https://github.com/CLIUtils/CLI11/blob/main/examples/enum.cpp): Using enumerations in an option, and the use of [CheckedTransformer](#transforming-validators)
928   -- [enum_ostream](https://github.com/CLIUtils/CLI11/blob/main/examples/enum_ostream.cpp): In addition to the contents of example enum.cpp, this example shows how a custom ostream operator overrides CLI11's enum streaming.
929   -- [formatter](https://github.com/CLIUtils/CLI11/blob/main/examples/formatter.cpp): Illustrating usage of a custom formatter
930   -- [groups](https://github.com/CLIUtils/CLI11/blob/main/examples/groups.cpp): Example using groups of options for help grouping and a the timer helper class
931   -- [inter_argument_order](https://github.com/CLIUtils/CLI11/blob/main/examples/inter_argument_order.cpp): An app to practice mixing unlimited arguments, but still recover the original order.
932   -- [json](https://github.com/CLIUtils/CLI11/blob/main/examples/json.cpp): Using JSON as a config file parser
933   -- [modhelp](https://github.com/CLIUtils/CLI11/blob/main/examples/modhelp.cpp): How to modify the help flag to do something other than default
934   -- [nested](https://github.com/CLIUtils/CLI11/blob/main/examples/nested.cpp): Nested subcommands
935   -- [option_groups](https://github.com/CLIUtils/CLI11/blob/main/examples/option_groups.cpp): Illustrating the use of option groups and a required number of options. Based on [Issue #88](https://github.com/CLIUtils/CLI11/issues/88) to set interacting groups of options
936   -- [positional_arity](https://github.com/CLIUtils/CLI11/blob/main/examples/positional_arity.cpp): Illustrating use of `preparse_callback` to handle situations where the number of arguments can determine which should get parsed, Based on [Issue #166](https://github.com/CLIUtils/CLI11/issues/166)
937   -- [positional_validation](https://github.com/CLIUtils/CLI11/blob/main/examples/positional_validation.cpp): Example of how positional arguments are validated using the `validate_positional` flag, also based on [Issue #166](https://github.com/CLIUtils/CLI11/issues/166)
938   -- [prefix_command](https://github.com/CLIUtils/CLI11/blob/main/examples/prefix_command.cpp): Illustrating use of the `prefix_command` flag.
939   -- [ranges](https://github.com/CLIUtils/CLI11/blob/main/examples/ranges.cpp): App to demonstrate exclusionary option groups based on [Issue #88](https://github.com/CLIUtils/CLI11/issues/88)
940   -- [shapes](https://github.com/CLIUtils/CLI11/blob/main/examples/shapes.cpp): Illustrating how to set up repeated subcommands Based on [gitter discussion](https://gitter.im/CLI11gitter/Lobby?at=5c7af6b965ffa019ea788cd5)
941   -- [simple](https://github.com/CLIUtils/CLI11/blob/main/examples/simple.cpp): A simple example of how to set up a CLI11 Application with different flags and options
942   -- [subcom_help](https://github.com/CLIUtils/CLI11/blob/main/examples/subcom_help.cpp): Configuring help for subcommands
943   -- [subcom_partitioned](https://github.com/CLIUtils/CLI11/blob/main/examples/subcom_partitioned.cpp): Example with a timer and subcommands generated separately and added to the main app later.
944   -- [subcommands](https://github.com/CLIUtils/CLI11/blob/main/examples/subcommands.cpp): Short example of subcommands
945   -- [validators](https://github.com/CLIUtils/CLI11/blob/main/examples/validators.cpp): Example illustrating use of validators
  1523 +Several short examples of different features are included in the repository. A
  1524 +brief description of each is included here
  1525 +
  1526 +- [callback_passthrough](https://github.com/CLIUtils/CLI11/blob/main/examples/callback_passthrough.cpp):
  1527 + Example of directly passing remaining arguments through to a callback function
  1528 + which generates a CLI11 application based on existing arguments.
  1529 +- [custom_parse](https://github.com/CLIUtils/CLI11/blob/main/examples/custom_parse.cpp):
  1530 + Based on [Issue #566](https://github.com/CLIUtils/CLI11/issues/566), example
  1531 + of custom parser
  1532 +- [digit_args](https://github.com/CLIUtils/CLI11/blob/main/examples/digit_args.cpp):
  1533 + Based on [Issue #123](https://github.com/CLIUtils/CLI11/issues/123), uses
  1534 + digit flags to pass a value
  1535 +- [enum](https://github.com/CLIUtils/CLI11/blob/main/examples/enum.cpp): Using
  1536 + enumerations in an option, and the use of
  1537 + [CheckedTransformer](#transforming-validators)
  1538 +- [enum_ostream](https://github.com/CLIUtils/CLI11/blob/main/examples/enum_ostream.cpp):
  1539 + In addition to the contents of example enum.cpp, this example shows how a
  1540 + custom ostream operator overrides CLI11's enum streaming.
  1541 +- [formatter](https://github.com/CLIUtils/CLI11/blob/main/examples/formatter.cpp):
  1542 + Illustrating usage of a custom formatter
  1543 +- [groups](https://github.com/CLIUtils/CLI11/blob/main/examples/groups.cpp):
  1544 + Example using groups of options for help grouping and a the timer helper class
  1545 +- [inter_argument_order](https://github.com/CLIUtils/CLI11/blob/main/examples/inter_argument_order.cpp):
  1546 + An app to practice mixing unlimited arguments, but still recover the original
  1547 + order.
  1548 +- [json](https://github.com/CLIUtils/CLI11/blob/main/examples/json.cpp): Using
  1549 + JSON as a config file parser
  1550 +- [modhelp](https://github.com/CLIUtils/CLI11/blob/main/examples/modhelp.cpp):
  1551 + How to modify the help flag to do something other than default
  1552 +- [nested](https://github.com/CLIUtils/CLI11/blob/main/examples/nested.cpp):
  1553 + Nested subcommands
  1554 +- [option_groups](https://github.com/CLIUtils/CLI11/blob/main/examples/option_groups.cpp):
  1555 + Illustrating the use of option groups and a required number of options. Based
  1556 + on [Issue #88](https://github.com/CLIUtils/CLI11/issues/88) to set interacting
  1557 + groups of options
  1558 +- [positional_arity](https://github.com/CLIUtils/CLI11/blob/main/examples/positional_arity.cpp):
  1559 + Illustrating use of `preparse_callback` to handle situations where the number
  1560 + of arguments can determine which should get parsed, Based on
  1561 + [Issue #166](https://github.com/CLIUtils/CLI11/issues/166)
  1562 +- [positional_validation](https://github.com/CLIUtils/CLI11/blob/main/examples/positional_validation.cpp):
  1563 + Example of how positional arguments are validated using the
  1564 + `validate_positional` flag, also based on
  1565 + [Issue #166](https://github.com/CLIUtils/CLI11/issues/166)
  1566 +- [prefix_command](https://github.com/CLIUtils/CLI11/blob/main/examples/prefix_command.cpp):
  1567 + Illustrating use of the `prefix_command` flag.
  1568 +- [ranges](https://github.com/CLIUtils/CLI11/blob/main/examples/ranges.cpp): App
  1569 + to demonstrate exclusionary option groups based on
  1570 + [Issue #88](https://github.com/CLIUtils/CLI11/issues/88)
  1571 +- [shapes](https://github.com/CLIUtils/CLI11/blob/main/examples/shapes.cpp):
  1572 + Illustrating how to set up repeated subcommands Based on
  1573 + [gitter discussion](https://gitter.im/CLI11gitter/Lobby?at=5c7af6b965ffa019ea788cd5)
  1574 +- [simple](https://github.com/CLIUtils/CLI11/blob/main/examples/simple.cpp): A
  1575 + simple example of how to set up a CLI11 Application with different flags and
  1576 + options
  1577 +- [subcom_help](https://github.com/CLIUtils/CLI11/blob/main/examples/subcom_help.cpp):
  1578 + Configuring help for subcommands
  1579 +- [subcom_partitioned](https://github.com/CLIUtils/CLI11/blob/main/examples/subcom_partitioned.cpp):
  1580 + Example with a timer and subcommands generated separately and added to the
  1581 + main app later.
  1582 +- [subcommands](https://github.com/CLIUtils/CLI11/blob/main/examples/subcommands.cpp):
  1583 + Short example of subcommands
  1584 +- [validators](https://github.com/CLIUtils/CLI11/blob/main/examples/validators.cpp):
  1585 + Example illustrating use of validators
946 1586  
947 1587 ## Contribute
948 1588  
949   -To contribute, open an [issue][github issues] or [pull request][github pull requests] on GitHub, or ask a question on [gitter][]. There is also a short note to contributors [here](./.github/CONTRIBUTING.md).
950   -This readme roughly follows the [Standard Readme Style][] and includes a mention of almost every feature of the library. More complex features are documented in more detail in the [CLI11 tutorial GitBook][gitbook].
  1589 +To contribute, open an [issue][github issues] or [pull
  1590 +request][github pull requests] on GitHub, or ask a question on [gitter][]. There
  1591 +is also a short note to contributors [here](./.github/CONTRIBUTING.md). This
  1592 +readme roughly follows the [Standard Readme Style][] and includes a mention of
  1593 +almost every feature of the library. More complex features are documented in
  1594 +more detail in the [CLI11 tutorial GitBook][gitbook].
951 1595  
952   -This project was created by [Henry Schreiner](https://github.com/henryiii) and major features were added by [Philip Top](https://github.com/phlptp). Special thanks to all the contributors ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
  1596 +This project was created by [Henry Schreiner](https://github.com/henryiii) and
  1597 +major features were added by [Philip Top](https://github.com/phlptp). Special
  1598 +thanks to all the contributors
  1599 +([emoji key](https://allcontributors.org/docs/en/emoji-key)):
953 1600  
954 1601 <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
955 1602 <!-- prettier-ignore-start -->
... ... @@ -1028,25 +1675,35 @@ This project was created by [Henry Schreiner](https://github.com/henryiii) and m
1028 1675  
1029 1676 <!-- ALL-CONTRIBUTORS-LIST:END -->
1030 1677  
1031   -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
  1678 +This project follows the
  1679 +[all-contributors](https://github.com/all-contributors/all-contributors)
  1680 +specification. Contributions of any kind welcome!
1032 1681  
1033 1682 ## License
1034 1683  
1035   -As of version 1.0, this library is available under a 3-Clause BSD license. See the [LICENSE](./LICENSE) file for details.
  1684 +As of version 1.0, this library is available under a 3-Clause BSD license. See
  1685 +the [LICENSE](./LICENSE) file for details.
1036 1686  
1037   -CLI11 was developed at the [University of Cincinnati][] to support of the [GooFit][] library under [NSF Award 1414736][]. Version 0.9 was featured in a [DIANA/HEP][] meeting at CERN ([see the slides][diana slides]). Please give it a try! Feedback is always welcome.
  1687 +CLI11 was developed at the [University of Cincinnati][] to support of the
  1688 +[GooFit][] library under [NSF Award 1414736][]. Version 0.9 was featured in a
  1689 +[DIANA/HEP][] meeting at CERN ([see the slides][diana slides]). Please give it a
  1690 +try! Feedback is always welcome.
1038 1691  
1039 1692 [doi-badge]: https://zenodo.org/badge/80064252.svg
1040 1693 [doi-link]: https://zenodo.org/badge/latestdoi/80064252
1041   -[azure-badge]: https://dev.azure.com/CLIUtils/CLI11/_apis/build/status/CLIUtils.CLI11?branchName=main
  1694 +[azure-badge]:
  1695 + https://dev.azure.com/CLIUtils/CLI11/_apis/build/status/CLIUtils.CLI11?branchName=main
1042 1696 [azure]: https://dev.azure.com/CLIUtils/CLI11
1043 1697 [actions-link]: https://github.com/CLIUtils/CLI11/actions
1044   -[actions-badge]: https://github.com/CLIUtils/CLI11/actions/workflows/tests.yml/badge.svg
1045   -[appveyor-badge]: https://ci.appveyor.com/api/projects/status/82niaxpaa28dwbms/branch/main?svg=true
  1698 +[actions-badge]:
  1699 + https://github.com/CLIUtils/CLI11/actions/workflows/tests.yml/badge.svg
  1700 +[appveyor-badge]:
  1701 + https://ci.appveyor.com/api/projects/status/82niaxpaa28dwbms/branch/main?svg=true
1046 1702 [appveyor]: https://ci.appveyor.com/project/HenrySchreiner/cli11
1047 1703 [repology-badge]: https://repology.org/badge/latest-versions/cli11.svg
1048 1704 [repology]: https://repology.org/project/cli11/versions
1049   -[codecov-badge]: https://codecov.io/gh/CLIUtils/CLI11/branch/main/graph/badge.svg?token=2O4wfs8NJO
  1705 +[codecov-badge]:
  1706 + https://codecov.io/gh/CLIUtils/CLI11/branch/main/graph/badge.svg?token=2O4wfs8NJO
1050 1707 [codecov]: https://codecov.io/gh/CLIUtils/CLI11
1051 1708 [gitter-badge]: https://badges.gitter.im/CLI11gitter/Lobby.svg
1052 1709 [gitter]: https://gitter.im/CLI11gitter/Lobby
... ... @@ -1063,7 +1720,8 @@ CLI11 was developed at the [University of Cincinnati][] to support of the [GooFi
1063 1720 [click]: http://click.pocoo.org
1064 1721 [api-docs]: https://CLIUtils.github.io/CLI11/index.html
1065 1722 [rang]: https://github.com/agauniyal/rang
1066   -[boost program options]: http://www.boost.org/doc/libs/1_63_0/doc/html/program_options.html
  1723 +[boost program options]:
  1724 + http://www.boost.org/doc/libs/1_63_0/doc/html/program_options.html
1067 1725 [the lean mean c++ option parser]: http://optionparser.sourceforge.net
1068 1726 [tclap]: http://tclap.sourceforge.net
1069 1727 [cxxopts]: https://github.com/jarro2783/cxxopts
... ... @@ -1074,7 +1732,8 @@ CLI11 was developed at the [University of Cincinnati][] to support of the [GooFi
1074 1732 [nsf award 1414736]: https://nsf.gov/awardsearch/showAward?AWD_ID=1414736
1075 1733 [university of cincinnati]: http://www.uc.edu
1076 1734 [gitbook]: https://cliutils.github.io/CLI11/book/
1077   -[cli11 advanced topics/custom converters]: https://cliutils.gitlab.io/CLI11Tutorial/chapters/advanced-topics.html#custom-converters
  1735 +[cli11 advanced topics/custom converters]:
  1736 + https://cliutils.gitlab.io/CLI11Tutorial/chapters/advanced-topics.html#custom-converters
1078 1737 [programoptions.hxx]: https://github.com/Fytch/ProgramOptions.hxx
1079 1738 [argument aggregator]: https://github.com/vietjtnguyen/argagg
1080 1739 [args]: https://github.com/Taywee/args
... ... @@ -1089,13 +1748,18 @@ CLI11 was developed at the [University of Cincinnati][] to support of the [GooFi
1089 1748 [wandbox-badge]: https://img.shields.io/badge/try_2.1-online-blue.svg
1090 1749 [wandbox-link]: https://wandbox.org/permlink/CA5bymNHh0AczdeN
1091 1750 [releases-badge]: https://img.shields.io/github/release/CLIUtils/CLI11.svg
1092   -[cli11-po-compare]: https://iscinumpy.gitlab.io/post/comparing-cli11-and-boostpo/
1093   -[diana slides]: https://indico.cern.ch/event/619465/contributions/2507949/attachments/1448567/2232649/20170424-diana-2.pdf
  1751 +[cli11-po-compare]:
  1752 + https://iscinumpy.gitlab.io/post/comparing-cli11-and-boostpo/
  1753 +[diana slides]:
  1754 + https://indico.cern.ch/event/619465/contributions/2507949/attachments/1448567/2232649/20170424-diana-2.pdf
1094 1755 [awesome c++]: https://github.com/fffaraz/awesome-cpp/blob/master/README.md#cli
1095 1756 [cli]: https://codesynthesis.com/projects/cli/
1096   -[single file libs]: https://github.com/nothings/single_file_libs/blob/master/README.md
1097   -[codacy-badge]: https://app.codacy.com/project/badge/Grade/2796b969c1b54321a02ad08affec0800
1098   -[codacy-link]: https://www.codacy.com/gh/CLIUtils/CLI11/dashboard?utm_source=github.com&utm_medium=referral&utm_content=CLIUtils/CLI11&utm_campaign=Badge_Grade
  1757 +[single file libs]:
  1758 + https://github.com/nothings/single_file_libs/blob/master/README.md
  1759 +[codacy-badge]:
  1760 + https://app.codacy.com/project/badge/Grade/2796b969c1b54321a02ad08affec0800
  1761 +[codacy-link]:
  1762 + https://www.codacy.com/gh/CLIUtils/CLI11/dashboard?utm_source=github.com&utm_medium=referral&utm_content=CLIUtils/CLI11&utm_campaign=Badge_Grade
1099 1763 [hunter]: https://docs.hunter.sh/en/latest/packages/pkg/CLI11.html
1100 1764 [standard readme style]: https://github.com/RichardLitt/standard-readme
1101 1765 [argparse]: https://github.com/p-ranav/argparse
... ...
azure-pipelines.yml
... ... @@ -21,7 +21,11 @@ variables:
21 21 jobs:
22 22 - job: ClangTidy
23 23 variables:
24   - CXX_FLAGS: "-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11"
  24 + CXX_FLAGS: >
  25 + -Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties
  26 + -Wmissing-declarations -Woverlength-strings -Wshadow
  27 + -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code
  28 + -std=c++11
25 29 cli11.options: -DCLI11_CLANG_TIDY=ON -DCLI11_CLANG_TIDY_OPTIONS="-fix"
26 30 cli11.std: 11
27 31 cli11.single: OFF
... ...
book/README.md
1 1 # CLI11: An introduction
2 2  
3   -This gitbook is designed to provide an introduction to using the CLI11 library to write your own command line programs. The library is designed to be clean, intuitive, but powerful. There are no requirements beyond C++11 support (and even `<regex>` support not required). It works on Mac, Linux, and Windows, and has 100% test coverage on all three systems. You can simply drop in a single header file (`CLI11.hpp` available in [releases][]) to use CLI11 in your own application. Other ways to integrate it into a build system are listed in the [README][].
4   -
5   -The library was inspired the Python libraries [Plumbum][] and [Click][], and incorporates many of their user friendly features. The library is extensively documented, with a [friendly introduction][readme], this tutorial book, and more technical [API docs][].
6   -
7   -> Feel free to contribute to [this documentation here][cli11tutorial] if something can be improved!
8   -
9   -The syntax is simple and scales from a basic application to a massive physics analysis with multiple models and many parameters and switches. For example, this is a simple program that has an optional parameter that defaults to 0:
  3 +This gitbook is designed to provide an introduction to using the CLI11 library
  4 +to write your own command line programs. The library is designed to be clean,
  5 +intuitive, but powerful. There are no requirements beyond C++11 support (and
  6 +even `<regex>` support not required). It works on Mac, Linux, and Windows, and
  7 +has 100% test coverage on all three systems. You can simply drop in a single
  8 +header file (`CLI11.hpp` available in [releases][]) to use CLI11 in your own
  9 +application. Other ways to integrate it into a build system are listed in the
  10 +[README][].
  11 +
  12 +The library was inspired the Python libraries [Plumbum][] and [Click][], and
  13 +incorporates many of their user friendly features. The library is extensively
  14 +documented, with a [friendly introduction][readme], this tutorial book, and more
  15 +technical [API docs][].
  16 +
  17 +> Feel free to contribute to [this documentation here][cli11tutorial] if
  18 +> something can be improved!
  19 +
  20 +The syntax is simple and scales from a basic application to a massive physics
  21 +analysis with multiple models and many parameters and switches. For example,
  22 +this is a simple program that has an optional parameter that defaults to 0:
10 23  
11 24 ```term
12 25 gitbook $ ./a.out
... ... @@ -24,13 +37,16 @@ Options:
24 37 -p INT Parameter
25 38 ```
26 39  
27   -Like any good command line application, help is provided. This program can be implemented in 10 lines:
  40 +Like any good command line application, help is provided. This program can be
  41 +implemented in 10 lines:
28 42  
29 43 [include](code/intro.cpp)
30 44  
31 45 [Source code](https://github.com/CLIUtils/CLI11/blob/main/book/code/intro.cpp)
32 46  
33   -Unlike some other libraries, this is enough to exit correctly and cleanly if help is requested or if incorrect arguments are passed. You can try this example out for yourself. To compile with GCC:
  47 +Unlike some other libraries, this is enough to exit correctly and cleanly if
  48 +help is requested or if incorrect arguments are passed. You can try this example
  49 +out for yourself. To compile with GCC:
34 50  
35 51 ```term
36 52 gitbook:examples $ c++ -std=c++11 intro.cpp
... ... @@ -45,13 +61,26 @@ app.add_option(&quot;-f,--file&quot;, file, &quot;Require an existing file&quot;)
45 61 ->check(CLI::ExistingFile);
46 62 ```
47 63  
48   -You can use any valid type; the above example could have used a `boost::file_system` file instead of a `std::string`. The value is a real value and does not require any special lookups to access. You do not have to risk typos by repeating the values after parsing like some libraries require. The library also handles positional arguments, flags, fixed or unlimited repeating options, interdependent options, flags, custom validators, help groups, and more.
49   -
50   -You can use subcommands, as well. Subcommands support callback lambda functions when parsed, or they can be checked later. You can infinitely nest subcommands, and each is a full `App` instance, supporting everything listed above.
51   -
52   -Reading/producing `.ini` files for configuration is also supported, as is using environment variables as input. The base `App` can be subclassed and customized for use in a toolkit (like [GooFit][]). All the standard shell idioms, like `--`, work as well.
53   -
54   -CLI11 was developed at the [University of Cincinnati][] in support of the [GooFit][] library under [NSF Award 1414736][nsf 1414736]. It was featured in a [DIANA/HEP][] meeting at CERN. Please give it a try! Feedback is always welcome.
  64 +You can use any valid type; the above example could have used a
  65 +`boost::file_system` file instead of a `std::string`. The value is a real value
  66 +and does not require any special lookups to access. You do not have to risk
  67 +typos by repeating the values after parsing like some libraries require. The
  68 +library also handles positional arguments, flags, fixed or unlimited repeating
  69 +options, interdependent options, flags, custom validators, help groups, and
  70 +more.
  71 +
  72 +You can use subcommands, as well. Subcommands support callback lambda functions
  73 +when parsed, or they can be checked later. You can infinitely nest subcommands,
  74 +and each is a full `App` instance, supporting everything listed above.
  75 +
  76 +Reading/producing `.ini` files for configuration is also supported, as is using
  77 +environment variables as input. The base `App` can be subclassed and customized
  78 +for use in a toolkit (like [GooFit][]). All the standard shell idioms, like
  79 +`--`, work as well.
  80 +
  81 +CLI11 was developed at the [University of Cincinnati][] in support of the
  82 +[GooFit][] library under [NSF Award 1414736][nsf 1414736]. It was featured in a
  83 +[DIANA/HEP][] meeting at CERN. Please give it a try! Feedback is always welcome.
55 84  
56 85 [goofit]: https://github.com/GooFit/GooFit
57 86 [diana/hep]: https://diana-hep.org
... ...
book/chapters/advanced-topics.md
... ... @@ -9,12 +9,15 @@ std::string opt;
9 9 app.add_option("--my_option", opt)->envname("MY_OPTION");
10 10 ```
11 11  
12   -If not given on the command line, the environment variable will be checked and read from if it exists. All the standard tools, like default and required, work as expected.
13   -If passed on the command line, this will ignore the environment variable.
  12 +If not given on the command line, the environment variable will be checked and
  13 +read from if it exists. All the standard tools, like default and required, work
  14 +as expected. If passed on the command line, this will ignore the environment
  15 +variable.
14 16  
15 17 ## Needs/excludes
16 18  
17   -You can set a network of requirements. For example, if flag a needs flag b but cannot be given with flag c, that would be:
  19 +You can set a network of requirements. For example, if flag a needs flag b but
  20 +cannot be given with flag c, that would be:
18 21  
19 22 ```cpp
20 23 auto a = app.add_flag("-a");
... ... @@ -25,11 +28,14 @@ a-&gt;needs(b);
25 28 a->excludes(c);
26 29 ```
27 30  
28   -CLI11 will make sure your network of requirements makes sense, and will throw an error immediately if it does not.
  31 +CLI11 will make sure your network of requirements makes sense, and will throw an
  32 +error immediately if it does not.
29 33  
30 34 ## Custom option callbacks
31 35  
32   -You can make a completely generic option with a custom callback. For example, if you wanted to add a complex number (already exists, so please don't actually do this):
  36 +You can make a completely generic option with a custom callback. For example, if
  37 +you wanted to add a complex number (already exists, so please don't actually do
  38 +this):
33 39  
34 40 ```cpp
35 41 CLI::Option *
... ... @@ -62,7 +68,13 @@ add_option(app, &quot;-c,--complex&quot;, comp);
62 68  
63 69 ## Custom converters
64 70  
65   -You can add your own converters to allow CLI11 to accept more option types in the standard calls. These can only be used for "single" size options (so complex, vector, etc. are a separate topic). If you set up a custom `istringstream& operator <<` overload before include CLI11, you can support different conversions. If you place this in the CLI namespace, you can even keep this from affecting the rest of your code. Here's how you could add `boost::optional` for a compiler that does not have `__has_include`:
  71 +You can add your own converters to allow CLI11 to accept more option types in
  72 +the standard calls. These can only be used for "single" size options (so
  73 +complex, vector, etc. are a separate topic). If you set up a custom
  74 +`istringstream& operator <<` overload before include CLI11, you can support
  75 +different conversions. If you place this in the CLI namespace, you can even keep
  76 +this from affecting the rest of your code. Here's how you could add
  77 +`boost::optional` for a compiler that does not have `__has_include`:
66 78  
67 79 ```cpp
68 80 // CLI11 already does this if __has_include is defined
... ... @@ -87,7 +99,10 @@ template &lt;typename T&gt; std::istringstream &amp;operator&gt;&gt;(std::istringstream &amp;in, boo
87 99 #include <CLI11.hpp>
88 100 ```
89 101  
90   -This is an example of how to use the system only; if you are just looking for a way to activate `boost::optional` support on older compilers, you should define `CLI11_BOOST_OPTIONAL` before including a CLI11 file, you'll get the `boost::optional` support.
  102 +This is an example of how to use the system only; if you are just looking for a
  103 +way to activate `boost::optional` support on older compilers, you should define
  104 +`CLI11_BOOST_OPTIONAL` before including a CLI11 file, you'll get the
  105 +`boost::optional` support.
91 106  
92 107 ## Custom converters and type names: std::chrono example
93 108  
... ...
book/chapters/an-advanced-example.md
1 1 # Making a git clone
2 2  
3   -Let's try our hand at a little `git` clone, called `geet`. It will just print it's intent, rather than running actual code, since it's just a demonstration. Let's start by adding an app and requiring 1 subcommand to run:
  3 +Let's try our hand at a little `git` clone, called `geet`. It will just print
  4 +it's intent, rather than running actual code, since it's just a demonstration.
  5 +Let's start by adding an app and requiring 1 subcommand to run:
4 6  
5 7 [include:"Intro"](../code/geet.cpp)
6 8  
... ... @@ -12,7 +14,8 @@ Now, let&#39;s add `commit`:
12 14  
13 15 [include:"Commit"](../code/geet.cpp)
14 16  
15   -All that's need now is the parse call. We'll print a little message after the code runs, and then return:
  17 +All that's need now is the parse call. We'll print a little message after the
  18 +code runs, and then return:
16 19  
17 20 [include:"Parse"](../code/geet.cpp)
18 21  
... ... @@ -28,4 +31,9 @@ You&#39;ll see it behaves pretty much like `git`.
28 31  
29 32 ## Multi-file App parse code
30 33  
31   -This example could be made much nicer if it was split into files, one per subcommand. If you simply use shared pointers instead of raw values in the lambda capture, you can tie the lifetime to the lambda function lifetime. CLI11 has a [multifile example](https://github.com/CLIUtils/CLI11/tree/main/examples/subcom_in_files) in its example folder.
  34 +This example could be made much nicer if it was split into files, one per
  35 +subcommand. If you simply use shared pointers instead of raw values in the
  36 +lambda capture, you can tie the lifetime to the lambda function lifetime. CLI11
  37 +has a
  38 +[multifile example](https://github.com/CLIUtils/CLI11/tree/main/examples/subcom_in_files)
  39 +in its example folder.
... ...
book/chapters/basics.md
... ... @@ -4,17 +4,30 @@ The simplest CLI11 program looks like this:
4 4  
5 5 [include](../code/simplest.cpp)
6 6  
7   -The first line includes the library; this explicitly uses the single file edition (see [Selecting an edition](/chapters/installation)).
8   -
9   -After entering the main function, you'll see that a `CLI::App` object is created. This is the basis for all interactions with the library. You could optionally provide a description for your app here.
10   -
11   -A normal CLI11 application would define some flags and options next. This is a simplest possible example, so we'll go on.
12   -
13   -The macro `CLI11_PARSE` just runs five simple lines. This internally runs `app.parse(argc, argv)`, which takes the command line info from C++ and parses it. If there is an error, it throws a `ParseError`; if you catch it, you can use `app.exit` with the error as an argument to print a nice message and produce the correct return code for your application.
14   -
15   -If you just use `app.parse` directly, your application will still work, but the stack will not be correctly unwound since you have an uncaught exception, and the command line output will be cluttered, especially for help.
16   -
17   -For this (and most of the examples in this book) we will assume that we have the `CLI11.hpp` file in the current directory and that we are creating an output executable `a.out` on a macOS or Linux system. The commands to compile and test this example would be:
  7 +The first line includes the library; this explicitly uses the single file
  8 +edition (see [Selecting an edition](/chapters/installation)).
  9 +
  10 +After entering the main function, you'll see that a `CLI::App` object is
  11 +created. This is the basis for all interactions with the library. You could
  12 +optionally provide a description for your app here.
  13 +
  14 +A normal CLI11 application would define some flags and options next. This is a
  15 +simplest possible example, so we'll go on.
  16 +
  17 +The macro `CLI11_PARSE` just runs five simple lines. This internally runs
  18 +`app.parse(argc, argv)`, which takes the command line info from C++ and parses
  19 +it. If there is an error, it throws a `ParseError`; if you catch it, you can use
  20 +`app.exit` with the error as an argument to print a nice message and produce the
  21 +correct return code for your application.
  22 +
  23 +If you just use `app.parse` directly, your application will still work, but the
  24 +stack will not be correctly unwound since you have an uncaught exception, and
  25 +the command line output will be cluttered, especially for help.
  26 +
  27 +For this (and most of the examples in this book) we will assume that we have the
  28 +`CLI11.hpp` file in the current directory and that we are creating an output
  29 +executable `a.out` on a macOS or Linux system. The commands to compile and test
  30 +this example would be:
18 31  
19 32 ```term
20 33 gitbook:examples $ g++ -std=c++11 simplest.cpp
... ...
book/chapters/config.md
... ... @@ -2,17 +2,25 @@
2 2  
3 3 ## Reading a configure file
4 4  
5   -You can tell your app to allow configure files with `set_config("--config")`. There are arguments: the first is the option name. If empty, it will clear the config flag. The second item is the default file name. If that is specified, the config will try to read that file. The third item is the help string, with a reasonable default, and the final argument is a boolean (default: false) that indicates that the configuration file is required and an error will be thrown if the file is not found and this is set to true.
  5 +You can tell your app to allow configure files with `set_config("--config")`.
  6 +There are arguments: the first is the option name. If empty, it will clear the
  7 +config flag. The second item is the default file name. If that is specified, the
  8 +config will try to read that file. The third item is the help string, with a
  9 +reasonable default, and the final argument is a boolean (default: false) that
  10 +indicates that the configuration file is required and an error will be thrown if
  11 +the file is not found and this is set to true.
6 12  
7 13 ### Adding a default path
8 14  
9   -if it is desired that config files be searched for a in a default path the `CLI::FileOnDefaultPath` transform can be used.
  15 +if it is desired that config files be searched for a in a default path the
  16 +`CLI::FileOnDefaultPath` transform can be used.
10 17  
11 18 ```cpp
12 19 app.set_config("--config")->transform(CLI::FileOnDefaultPath("/default_path/"));
13 20 ```
14 21  
15   -This will allow specified files to either exist as given or on a specified default path.
  22 +This will allow specified files to either exist as given or on a specified
  23 +default path.
16 24  
17 25 ```cpp
18 26 app.set_config("--config")
... ... @@ -20,7 +28,10 @@ app.set_config(&quot;--config&quot;)
20 28 ->transform(CLI::FileOnDefaultPath("/default_path2/",false));
21 29 ```
22 30  
23   -Multiple default paths can be specified through this mechanism. The last transform given is executed first so the error return must be disabled so it can be chained to the first. The same effect can be achieved though the or(`|`) operation with validators
  31 +Multiple default paths can be specified through this mechanism. The last
  32 +transform given is executed first so the error return must be disabled so it can
  33 +be chained to the first. The same effect can be achieved though the or(`|`)
  34 +operation with validators
24 35  
25 36 ```cpp
26 37 app.set_config("--config")
... ... @@ -29,32 +40,39 @@ app.set_config(&quot;--config&quot;)
29 40  
30 41 ### Extra fields
31 42  
32   -Sometimes configuration files are used for multiple purposes so CLI11 allows options on how to deal with extra fields
  43 +Sometimes configuration files are used for multiple purposes so CLI11 allows
  44 +options on how to deal with extra fields
33 45  
34 46 ```cpp
35 47 app.allow_config_extras(true);
36 48 ```
37 49  
38   -will allow capture the extras in the extras field of the app. (NOTE: This also sets the `allow_extras` in the app to true)
  50 +will allow capture the extras in the extras field of the app. (NOTE: This also
  51 +sets the `allow_extras` in the app to true)
39 52  
40 53 ```cpp
41 54 app.allow_config_extras(false);
42 55 ```
43 56  
44   -will generate an error if there are any extra fields
45   -for slightly finer control there is a scoped enumeration of the modes or
  57 +will generate an error if there are any extra fields for slightly finer control
  58 +there is a scoped enumeration of the modes or
46 59  
47 60 ```cpp
48 61 app.allow_config_extras(CLI::config_extras_mode::ignore);
49 62 ```
50 63  
51   -will completely ignore extra parameters in the config file. This mode is the default.
  64 +will completely ignore extra parameters in the config file. This mode is the
  65 +default.
52 66  
53 67 ```cpp
54 68 app.allow_config_extras(CLI::config_extras_mode::capture);
55 69 ```
56 70  
57   -will store the unrecognized options in the app extras fields. This option is the closest equivalent to `app.allow_config_extras(true);` with the exception that it does not also set the `allow_extras` flag so using this option without also setting `allow_extras(true)` will generate an error which may or may not be the desired behavior.
  71 +will store the unrecognized options in the app extras fields. This option is the
  72 +closest equivalent to `app.allow_config_extras(true);` with the exception that
  73 +it does not also set the `allow_extras` flag so using this option without also
  74 +setting `allow_extras(true)` will generate an error which may or may not be the
  75 +desired behavior.
58 76  
59 77 ```cpp
60 78 app.allow_config_extras(CLI::config_extras_mode::error);
... ... @@ -66,17 +84,20 @@ is equivalent to `app.allow_config_extras(false);`
66 84 app.allow_config_extras(CLI::config_extras_mode::ignore_all);
67 85 ```
68 86  
69   -will completely ignore any mismatches, extras, or other issues with the config file
  87 +will completely ignore any mismatches, extras, or other issues with the config
  88 +file
70 89  
71 90 ### Getting the used configuration file name
72 91  
73 92 If it is needed to get the configuration file name used this can be obtained via
74 93 `app.get_config_ptr()->as<std::string>()` or
75   -`app["--config"]->as<std::string>()` assuming `--config` was the configuration option name.
  94 +`app["--config"]->as<std::string>()` assuming `--config` was the configuration
  95 +option name.
76 96  
77 97 ## Configure file format
78 98  
79   -Here is an example configuration file, in [TOML](https://github.com/toml-lang/toml) format:
  99 +Here is an example configuration file, in
  100 +[TOML](https://github.com/toml-lang/toml) format:
80 101  
81 102 ```ini
82 103 # Comments are supported, using a #
... ... @@ -93,7 +114,15 @@ in_subcommand = Wow
93 114 subcommand = true # could also be give as sub.subcommand=true
94 115 ```
95 116  
96   -Spaces before and after the name and argument are ignored. Multiple arguments are separated by spaces. One set of quotes will be removed, preserving spaces (the same way the command line works). Boolean options can be `true`, `on`, `1`, `y`, `t`, `+`, `yes`, `enable`; or `false`, `off`, `0`, `no`, `n`, `f`, `-`, `disable`, (case insensitive). Sections (and `.` separated names) are treated as subcommands (note: this does not necessarily mean that subcommand was passed, it just sets the "defaults". If a subcommand is set to `configurable` then passing the subcommand using `[sub]` in a configuration file will trigger the subcommand.)
  117 +Spaces before and after the name and argument are ignored. Multiple arguments
  118 +are separated by spaces. One set of quotes will be removed, preserving spaces
  119 +(the same way the command line works). Boolean options can be `true`, `on`, `1`,
  120 +`y`, `t`, `+`, `yes`, `enable`; or `false`, `off`, `0`, `no`, `n`, `f`, `-`,
  121 +`disable`, (case insensitive). Sections (and `.` separated names) are treated as
  122 +subcommands (note: this does not necessarily mean that subcommand was passed, it
  123 +just sets the "defaults". If a subcommand is set to `configurable` then passing
  124 +the subcommand using `[sub]` in a configuration file will trigger the
  125 +subcommand.)
97 126  
98 127 CLI11 also supports configuration file in INI format.
99 128  
... ... @@ -111,7 +140,9 @@ in_subcommand = Wow
111 140 sub.subcommand = true
112 141 ```
113 142  
114   -The main differences are in vector notation and comment character. Note: CLI11 is not a full TOML parser as it just reads values as strings. It is possible (but not recommended) to mix notation.
  143 +The main differences are in vector notation and comment character. Note: CLI11
  144 +is not a full TOML parser as it just reads values as strings. It is possible
  145 +(but not recommended) to mix notation.
115 146  
116 147 ## Multiple configuration files
117 148  
... ... @@ -121,11 +152,15 @@ If it is desired that multiple configuration be allowed. Use
121 152 app.set_config("--config")->expected(1, X);
122 153 ```
123 154  
124   -Where X is some positive integer and will allow up to `X` configuration files to be specified by separate `--config` arguments.
  155 +Where X is some positive integer and will allow up to `X` configuration files to
  156 +be specified by separate `--config` arguments.
125 157  
126 158 ## Writing out a configure file
127 159  
128   -To print a configuration file from the passed arguments, use `.config_to_str(default_also=false, write_description=false)`, where `default_also` will also show any defaulted arguments, and `write_description` will include option descriptions and the App description
  160 +To print a configuration file from the passed arguments, use
  161 +`.config_to_str(default_also=false, write_description=false)`, where
  162 +`default_also` will also show any defaulted arguments, and `write_description`
  163 +will include option descriptions and the App description
129 164  
130 165 ```cpp
131 166 CLI::App app;
... ... @@ -136,7 +171,8 @@ To print a configuration file from the passed arguments, use `.config_to_str(def
136 171 std::cout<<app.config_to_str(true,true);
137 172 ```
138 173  
139   -if a prefix is needed to print before the options, for example to print a config for just a subcommand, the config formatter can be obtained directly.
  174 +if a prefix is needed to print before the options, for example to print a config
  175 +for just a subcommand, the config formatter can be obtained directly.
140 176  
141 177 ```cpp
142 178 auto fmtr=app.get_config_formatter();
... ... @@ -147,7 +183,11 @@ if a prefix is needed to print before the options, for example to print a config
147 183  
148 184 ### Customization of configure file output
149 185  
150   -The default config parser/generator has some customization points that allow variations on the TOML format. The default formatter has a base configuration that matches the TOML format. It defines 5 characters that define how different aspects of the configuration are handled. You must use `get_config_formatter_base()` to have access to these fields
  186 +The default config parser/generator has some customization points that allow
  187 +variations on the TOML format. The default formatter has a base configuration
  188 +that matches the TOML format. It defines 5 characters that define how different
  189 +aspects of the configuration are handled. You must use
  190 +`get_config_formatter_base()` to have access to these fields
151 191  
152 192 ```cpp
153 193 /// the character used for comments
... ... @@ -176,41 +216,62 @@ std::string configSection;
176 216  
177 217 These can be modified via setter functions
178 218  
179   -- `ConfigBase *comment(char cchar)`: Specify the character to start a comment block
180   -- `ConfigBase *arrayBounds(char aStart, char aEnd)`: Specify the start and end characters for an array
181   -- `ConfigBase *arrayDelimiter(char aSep)`: Specify the delimiter character for an array
182   -- `ConfigBase *valueSeparator(char vSep)`: Specify the delimiter between a name and value
183   -- `ConfigBase *quoteCharacter(char qString, char qChar)` :specify the characters to use around strings and single characters
184   -- `ConfigBase *maxLayers(uint8_t layers)` : specify the maximum number of parent layers to process. This is useful to limit processing for larger config files
185   -- `ConfigBase *parentSeparator(char sep)` : specify the character to separate parent layers from options
186   -- `ConfigBase *section(const std::string &sectionName)` : specify the section name to use to get the option values, only this section will be processed
187   -- `ConfigBase *index(uint16_t sectionIndex)` : specify an index section to use for processing if multiple TOML sections of the same name are present `[[section]]`
188   -
189   -For example, to specify reading a configure file that used `:` to separate name and values:
  219 +- `ConfigBase *comment(char cchar)`: Specify the character to start a comment
  220 + block
  221 +- `ConfigBase *arrayBounds(char aStart, char aEnd)`: Specify the start and end
  222 + characters for an array
  223 +- `ConfigBase *arrayDelimiter(char aSep)`: Specify the delimiter character for
  224 + an array
  225 +- `ConfigBase *valueSeparator(char vSep)`: Specify the delimiter between a name
  226 + and value
  227 +- `ConfigBase *quoteCharacter(char qString, char qChar)` :specify the characters
  228 + to use around strings and single characters
  229 +- `ConfigBase *maxLayers(uint8_t layers)` : specify the maximum number of parent
  230 + layers to process. This is useful to limit processing for larger config files
  231 +- `ConfigBase *parentSeparator(char sep)` : specify the character to separate
  232 + parent layers from options
  233 +- `ConfigBase *section(const std::string &sectionName)` : specify the section
  234 + name to use to get the option values, only this section will be processed
  235 +- `ConfigBase *index(uint16_t sectionIndex)` : specify an index section to use
  236 + for processing if multiple TOML sections of the same name are present
  237 + `[[section]]`
  238 +
  239 +For example, to specify reading a configure file that used `:` to separate name
  240 +and values:
190 241  
191 242 ```cpp
192 243 auto config_base=app.get_config_formatter_base();
193 244 config_base->valueSeparator(':');
194 245 ```
195 246  
196   -The default configuration file will read INI files, but will write out files in the TOML format. To specify outputting INI formatted files use
  247 +The default configuration file will read INI files, but will write out files in
  248 +the TOML format. To specify outputting INI formatted files use
197 249  
198 250 ```cpp
199 251 app.config_formatter(std::make_shared<CLI::ConfigINI>());
200 252 ```
201 253  
202   -which makes use of a predefined modification of the ConfigBase class which TOML also uses. If a custom formatter is used that is not inheriting from the from ConfigBase class `get_config_formatter_base() will return a nullptr if RTTI is on (usually the default), or garbage if RTTI is off, so some care must be exercised in its use with custom configurations.
  254 +which makes use of a predefined modification of the ConfigBase class which TOML
  255 +also uses. If a custom formatter is used that is not inheriting from the from
  256 +ConfigBase class `get_config_formatter_base() will return a nullptr if RTTI is
  257 +on (usually the default), or garbage if RTTI is off, so some care must be
  258 +exercised in its use with custom configurations.
203 259  
204 260 ## Custom formats
205 261  
206   -You can invent a custom format and set that instead of the default INI formatter. You need to inherit from `CLI::Config` and implement the following two functions:
  262 +You can invent a custom format and set that instead of the default INI
  263 +formatter. You need to inherit from `CLI::Config` and implement the following
  264 +two functions:
207 265  
208 266 ```cpp
209 267 std::string to_config(const CLI::App *app, bool default_also, bool, std::string) const;
210 268 std::vector<CLI::ConfigItem> from_config(std::istream &input) const;
211 269 ```
212 270  
213   -The `CLI::ConfigItem`s that you return are simple structures with a name, a vector of parents, and a vector of results. A optionally customizable `to_flag` method on the formatter lets you change what happens when a ConfigItem turns into a flag.
  271 +The `CLI::ConfigItem`s that you return are simple structures with a name, a
  272 +vector of parents, and a vector of results. A optionally customizable `to_flag`
  273 +method on the formatter lets you change what happens when a ConfigItem turns
  274 +into a flag.
214 275  
215 276 Finally, set your new class as new config formatter:
216 277  
... ... @@ -218,7 +279,9 @@ Finally, set your new class as new config formatter:
218 279 app.config_formatter(std::make_shared<NewConfig>());
219 280 ```
220 281  
221   -See [`examples/json.cpp`](https://github.com/CLIUtils/CLI11/blob/main/examples/json.cpp) for a complete JSON config example.
  282 +See
  283 +[`examples/json.cpp`](https://github.com/CLIUtils/CLI11/blob/main/examples/json.cpp)
  284 +for a complete JSON config example.
222 285  
223 286 ### Trivial JSON configuration example
224 287  
... ... @@ -236,21 +299,40 @@ The parser can handle these structures with only a minor tweak
236 299 app.get_config_formatter_base()->valueSeparator(':');
237 300 ```
238 301  
239   -The open and close brackets must be on a separate line and the comma gets interpreted as an array separator but since no values are after the comma they get ignored as well. This will not support multiple layers or sections or any other moderately complex JSON, but can work if the input file is simple.
  302 +The open and close brackets must be on a separate line and the comma gets
  303 +interpreted as an array separator but since no values are after the comma they
  304 +get ignored as well. This will not support multiple layers or sections or any
  305 +other moderately complex JSON, but can work if the input file is simple.
240 306  
241 307 ## Triggering Subcommands
242 308  
243   -Configuration files can be used to trigger subcommands if a subcommand is set to configure. By default configuration file just set the default values of a subcommand. But if the `configure()` option is set on a subcommand then the if the subcommand is utilized via a `[subname]` block in the configuration file it will act as if it were called from the command line. Subsubcommands can be triggered via `[subname.subsubname]`. Using the `[[subname]]` will be as if the subcommand were triggered multiple times from the command line. This functionality can allow the configuration file to act as a scripting file.
  309 +Configuration files can be used to trigger subcommands if a subcommand is set to
  310 +configure. By default configuration file just set the default values of a
  311 +subcommand. But if the `configure()` option is set on a subcommand then the if
  312 +the subcommand is utilized via a `[subname]` block in the configuration file it
  313 +will act as if it were called from the command line. Subsubcommands can be
  314 +triggered via `[subname.subsubname]`. Using the `[[subname]]` will be as if the
  315 +subcommand were triggered multiple times from the command line. This
  316 +functionality can allow the configuration file to act as a scripting file.
244 317  
245   -For custom configuration files this behavior can be triggered by specifying the parent subcommands in the structure and `++` as the name to open a new subcommand scope and `--` to close it. These names trigger the different callbacks of configurable subcommands.
  318 +For custom configuration files this behavior can be triggered by specifying the
  319 +parent subcommands in the structure and `++` as the name to open a new
  320 +subcommand scope and `--` to close it. These names trigger the different
  321 +callbacks of configurable subcommands.
246 322  
247 323 ## Stream parsing
248 324  
249   -In addition to the regular parse functions a `parse_from_stream(std::istream &input)` is available to directly parse a stream operator. For example to process some arguments in an already open file stream. The stream is fed directly in the config parser so bypasses the normal command line parsing.
  325 +In addition to the regular parse functions a
  326 +`parse_from_stream(std::istream &input)` is available to directly parse a stream
  327 +operator. For example to process some arguments in an already open file stream.
  328 +The stream is fed directly in the config parser so bypasses the normal command
  329 +line parsing.
250 330  
251 331 ## Implementation Notes
252 332  
253   -The config file input works with any form of the option given: Long, short, positional, or the environment variable name. When generating a config file it will create an option name in following priority.
  333 +The config file input works with any form of the option given: Long, short,
  334 +positional, or the environment variable name. When generating a config file it
  335 +will create an option name in following priority.
254 336  
255 337 1. First long name
256 338 2. Positional name
... ...
book/chapters/flags.md
1 1 # Adding Flags
2 2  
3   -The most basic addition to a command line program is a flag. This is simply something that does not take any arguments. Adding a flag in CLI11 is done in one of three ways.
  3 +The most basic addition to a command line program is a flag. This is simply
  4 +something that does not take any arguments. Adding a flag in CLI11 is done in
  5 +one of three ways.
4 6  
5 7 ## Boolean flags
6 8  
... ... @@ -11,60 +13,93 @@ bool my_flag{false};
11 13 app.add_flag("-f", my_flag, "Optional description");
12 14 ```
13 15  
14   -This will bind the flag `-f` to the boolean `my_flag`. After the parsing step, `my_flag` will be `false` if the flag was not found on the command line, or `true` if it was. By default, it will be allowed any number of times, but if you explicitly\[^1\] request `->take_last(false)`, it will only be allowed once; passing something like `./my_app -f -f` or `./my_app -ff` will throw a `ParseError` with a nice help description. A flag name may start with any character except ('-', ' ', '\n', and '!'). For long flags, after the first character all characters are allowed except ('=',':','{',' ', '\n'). Names are given as a comma separated string, with the dash or dashes. An flag can have as many names as you want, and afterward, using `count`, you can use any of the names, with dashes as needed.
  16 +This will bind the flag `-f` to the boolean `my_flag`. After the parsing step,
  17 +`my_flag` will be `false` if the flag was not found on the command line, or
  18 +`true` if it was. By default, it will be allowed any number of times, but if you
  19 +explicitly\[^1\] request `->take_last(false)`, it will only be allowed once;
  20 +passing something like `./my_app -f -f` or `./my_app -ff` will throw a
  21 +`ParseError` with a nice help description. A flag name may start with any
  22 +character except ('-', ' ', '\n', and '!'). For long flags, after the first
  23 +character all characters are allowed except ('=',':','{',' ', '\n'). Names are
  24 +given as a comma separated string, with the dash or dashes. An flag can have as
  25 +many names as you want, and afterward, using `count`, you can use any of the
  26 +names, with dashes as needed.
15 27  
16 28 ## Integer flags
17 29  
18   -If you want to allow multiple flags and count their value, simply use any integral variables instead of a bool:
  30 +If you want to allow multiple flags and count their value, simply use any
  31 +integral variables instead of a bool:
19 32  
20 33 ```cpp
21 34 int my_flag{0};
22 35 app.add_flag("-f", my_flag, "Optional description");
23 36 ```
24 37  
25   -After the parsing step, `my_flag` will contain the number of times this flag was found on the command line, including 0 if not found.
  38 +After the parsing step, `my_flag` will contain the number of times this flag was
  39 +found on the command line, including 0 if not found.
26 40  
27   -This behavior can also be controlled manually via `->multi_option_policy(CLI::MultiOptionPolicy::Sum)` as of version 2.2.
  41 +This behavior can also be controlled manually via
  42 +`->multi_option_policy(CLI::MultiOptionPolicy::Sum)` as of version 2.2.
28 43  
29 44 ## Arbitrary type flags
30 45  
31   -CLI11 allows the type of the variable to assign to in the `add_flag` function to be any supported type. This is particularly useful in combination with specifying default values for flags. The allowed types include bool, int, float, vector, enum, or string-like.
  46 +CLI11 allows the type of the variable to assign to in the `add_flag` function to
  47 +be any supported type. This is particularly useful in combination with
  48 +specifying default values for flags. The allowed types include bool, int, float,
  49 +vector, enum, or string-like.
32 50  
33 51 ### Default Flag Values
34 52  
35   -Flag options specified through the `add_flag*` functions allow a syntax for the option names to default particular options to a false value or any other value if some flags are passed. For example:
  53 +Flag options specified through the `add_flag*` functions allow a syntax for the
  54 +option names to default particular options to a false value or any other value
  55 +if some flags are passed. For example:
36 56  
37 57 ```cpp
38 58 app.add_flag("--flag,!--no-flag",result,"help for flag");
39 59 ```
40 60  
41   -specifies that if `--flag` is passed on the command line result will be true or contain a value of 1. If `--no-flag` is
42   -passed `result` will contain false or -1 if `result` is a signed integer type, or 0 if it is an unsigned type. An
43   -alternative form of the syntax is more explicit: `"--flag,--no-flag{false}"`; this is equivalent to the previous
44   -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
45   -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
46   -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).
47   -The default value can be any value. For example if you wished to define a numerical flag:
  61 +specifies that if `--flag` is passed on the command line result will be true or
  62 +contain a value of 1. If `--no-flag` is passed `result` will contain false or -1
  63 +if `result` is a signed integer type, or 0 if it is an unsigned type. An
  64 +alternative form of the syntax is more explicit: `"--flag,--no-flag{false}"`;
  65 +this is equivalent to the previous example. This also works for short form
  66 +options `"-f,!-n"` or `"-f,-n{false}"`. If `variable_to_bind_to` is anything but
  67 +an integer value the default behavior is to take the last value given, while if
  68 +`variable_to_bind_to` is an integer type the behavior will be to sum all the
  69 +given arguments and return the result. This can be modified if needed by
  70 +changing the `multi_option_policy` on each flag (this is not inherited). The
  71 +default value can be any value. For example if you wished to define a numerical
  72 +flag:
48 73  
49 74 ```cpp
50 75 app.add_flag("-1{1},-2{2},-3{3}",result,"numerical flag")
51 76 ```
52 77  
53   -using any of those flags on the command line will result in the specified number in the output. Similar things can be done for string values, and enumerations, as long as the default value can be converted to the given type.
  78 +using any of those flags on the command line will result in the specified number
  79 +in the output. Similar things can be done for string values, and enumerations,
  80 +as long as the default value can be converted to the given type.
54 81  
55 82 ## Pure flags
56 83  
57   -Every command that starts with `add_`, such as the flag commands, return a pointer to the internally stored `CLI::Option` that describes your addition. If you prefer, you can capture this pointer and use it, and that allows you to skip adding a variable to bind to entirely:
  84 +Every command that starts with `add_`, such as the flag commands, return a
  85 +pointer to the internally stored `CLI::Option` that describes your addition. If
  86 +you prefer, you can capture this pointer and use it, and that allows you to skip
  87 +adding a variable to bind to entirely:
58 88  
59 89 ```cpp
60 90 CLI::Option* my_flag = app.add_flag("-f", "Optional description");
61 91 ```
62 92  
63   -After parsing, you can use `my_flag->count()` to count the number of times this was found. You can also directly use the value (`*my_flag`) as a bool. `CLI::Option` will be discussed in more detail later.
  93 +After parsing, you can use `my_flag->count()` to count the number of times this
  94 +was found. You can also directly use the value (`*my_flag`) as a bool.
  95 +`CLI::Option` will be discussed in more detail later.
64 96  
65 97 ## Callback flags
66 98  
67   -If you want to define a callback that runs when you make a flag, you can use `add_flag_function` (C++11 or newer) or `add_flag` (C++14 or newer only) to add a callback function. The function should have the signature `void(std::size_t)`. This could be useful for a version printout, etc.
  99 +If you want to define a callback that runs when you make a flag, you can use
  100 +`add_flag_function` (C++11 or newer) or `add_flag` (C++14 or newer only) to add
  101 +a callback function. The function should have the signature `void(std::size_t)`.
  102 +This could be useful for a version printout, etc.
68 103  
69 104 ```cpp
70 105 auto callback = [](int count){std::cout << "This was called " << count << " times";};
... ... @@ -73,9 +108,15 @@ app.add_flag_function(&quot;-c&quot;, callback, &quot;Optional description&quot;);
73 108  
74 109 ## Aliases
75 110  
76   -The name string, the first item of every `add_` method, can contain as many short and long names as you want, separated by commas. For example, `"-a,--alpha,-b,--beta"` would allow any of those to be recognized on the command line. If you use the same name twice, or if you use the same name in multiple flags, CLI11 will immediately throw a `CLI::ConstructionError` describing your problem (it will not wait until the parsing step).
  111 +The name string, the first item of every `add_` method, can contain as many
  112 +short and long names as you want, separated by commas. For example,
  113 +`"-a,--alpha,-b,--beta"` would allow any of those to be recognized on the
  114 +command line. If you use the same name twice, or if you use the same name in
  115 +multiple flags, CLI11 will immediately throw a `CLI::ConstructionError`
  116 +describing your problem (it will not wait until the parsing step).
77 117  
78   -If you want to make an option case insensitive, you can use the `->ignore_case()` method on the `CLI::Option` to do that. For example,
  118 +If you want to make an option case insensitive, you can use the
  119 +`->ignore_case()` method on the `CLI::Option` to do that. For example,
79 120  
80 121 ```cpp
81 122 bool flag{false};
... ... @@ -122,4 +163,5 @@ Flag int: 3
122 163 Flag plain: 1
123 164 ```
124 165  
125   -\[^1\]: It will not inherit this from the parent defaults, since this is often useful even if you don't want all options to allow multiple passed options.
  166 +\[^1\]: It will not inherit this from the parent defaults, since this is often
  167 +useful even if you don't want all options to allow multiple passed options.
... ...
book/chapters/formatting.md
1 1 # Formatting help output
2 2  
3   -{% hint style='info' %}
4   -New in CLI11 1.6
5   -{% endhint %}
  3 +{% hint style='info' %} New in CLI11 1.6 {% endhint %}
6 4  
7 5 ## Customizing an existing formatter
8 6  
9   -In CLI11, you can control the output of the help printout in full or in part. The default formatter was written in such a way as to be customizable. You can use `app.get_formatter()` to get the current formatter. The formatter you set will be inherited by subcommands that are created after you set the formatter.
  7 +In CLI11, you can control the output of the help printout in full or in part.
  8 +The default formatter was written in such a way as to be customizable. You can
  9 +use `app.get_formatter()` to get the current formatter. The formatter you set
  10 +will be inherited by subcommands that are created after you set the formatter.
10 11  
11 12 There are several configuration options that you can set:
12 13  
... ... @@ -15,7 +16,9 @@ There are several configuration options that you can set:
15 16 | `column_width(width)` | The width of the columns | Both |
16 17 | `label(key, value)` | Set a label to a different value | Both |
17 18  
18   -Labels will map the built in names and type names from key to value if present. For example, if you wanted to change the width of the columns to 40 and the `REQUIRED` label from `(REQUIRED)` to `(MUST HAVE)`:
  19 +Labels will map the built in names and type names from key to value if present.
  20 +For example, if you wanted to change the width of the columns to 40 and the
  21 +`REQUIRED` label from `(REQUIRED)` to `(MUST HAVE)`:
19 22  
20 23 ```cpp
21 24 app.get_formatter()->column_width(40);
... ... @@ -24,7 +27,11 @@ app.get_formatter()-&gt;label(&quot;REQUIRED&quot;, &quot;(MUST HAVE)&quot;);
24 27  
25 28 ## Subclassing
26 29  
27   -You can further configure pieces of the code while still keeping most of the formatting intact by subclassing either formatter and replacing any of the methods with your own. The formatters use virtual functions most places, so you are free to add or change anything about them. For example, if you wanted to remove the info that shows up between the option name and the description:
  30 +You can further configure pieces of the code while still keeping most of the
  31 +formatting intact by subclassing either formatter and replacing any of the
  32 +methods with your own. The formatters use virtual functions most places, so you
  33 +are free to add or change anything about them. For example, if you wanted to
  34 +remove the info that shows up between the option name and the description:
28 35  
29 36 ```cpp
30 37 class MyFormatter : public CLI::Formatter {
... ... @@ -34,11 +41,14 @@ class MyFormatter : public CLI::Formatter {
34 41 app.formatter(std::make_shared<MyFormatter>());
35 42 ```
36 43  
37   -Look at the class definitions in `FormatterFwd.hpp` or the method definitions in `Formatter.hpp` to see what methods you have access to and how they are put together.
  44 +Look at the class definitions in `FormatterFwd.hpp` or the method definitions in
  45 +`Formatter.hpp` to see what methods you have access to and how they are put
  46 +together.
38 47  
39 48 ## Anatomy of a help message
40 49  
41   -This is a normal printout, with `<>` indicating the methods used to produce each line.
  50 +This is a normal printout, with `<>` indicating the methods used to produce each
  51 +line.
42 52  
43 53 ```text
44 54 <make_description(app)>
... ... @@ -55,9 +65,11 @@ This is a normal printout, with `&lt;&gt;` indicating the methods used to produce each
55 65 <make_footer(app)>
56 66 ```
57 67  
58   -`make_usage` calls `make_option_usage(opt)` on all the positionals to build that part of the line. `make_subcommand` passes the subcommand as the app pointer.
  68 +`make_usage` calls `make_option_usage(opt)` on all the positionals to build that
  69 +part of the line. `make_subcommand` passes the subcommand as the app pointer.
59 70  
60   -The `make_groups` print the group name then call `make_option(o)` on the options listed in that group. The normal printout for an option looks like this:
  71 +The `make_groups` print the group name then call `make_option(o)` on the options
  72 +listed in that group. The normal printout for an option looks like this:
61 73  
62 74 ```text
63 75 make_option_opts(o)
... ... @@ -69,5 +81,6 @@ make_option_name(o,p) make_option_desc(o)
69 81  
70 82 Notes:
71 83  
72   -- `*1`: This signature depends on whether the call is from a positional or optional.
  84 +- `*1`: This signature depends on whether the call is from a positional or
  85 + optional.
73 86 - `o` is opt pointer, `p` is true if positional.
... ...
book/chapters/installation.md
... ... @@ -6,7 +6,10 @@
6 6 #include <CLI11.hpp>
7 7 ```
8 8  
9   -This example uses the single file edition of CLI11. You can download `CLI11.hpp` from the latest release and put it into the same folder as your source code, then compile this with C++ enabled. For a larger project, you can just put this in an include folder and you are set.
  9 +This example uses the single file edition of CLI11. You can download `CLI11.hpp`
  10 +from the latest release and put it into the same folder as your source code,
  11 +then compile this with C++ enabled. For a larger project, you can just put this
  12 +in an include folder and you are set.
10 13  
11 14 ## Full edition
12 15  
... ... @@ -14,27 +17,42 @@ This example uses the single file edition of CLI11. You can download `CLI11.hpp`
14 17 #include <CLI/CLI.hpp>
15 18 ```
16 19  
17   -If you want to use CLI11 in its full form, you can also use the original multiple file edition. This has an extra utility (`Timer`), and is does not require that you use a release. The only change to your code would be the include shown above.
  20 +If you want to use CLI11 in its full form, you can also use the original
  21 +multiple file edition. This has an extra utility (`Timer`), and is does not
  22 +require that you use a release. The only change to your code would be the
  23 +include shown above.
18 24  
19 25 ### CMake support for the full edition
20 26  
21   -If you use CMake 3.4+ for your project (highly recommended), CLI11 comes with a powerful CMakeLists.txt file that was designed to also be used with `add_subproject`. You can add the repository to your code (preferably as a git submodule), then add the following line to your project (assuming your folder is called CLI11):
  27 +If you use CMake 3.4+ for your project (highly recommended), CLI11 comes with a
  28 +powerful CMakeLists.txt file that was designed to also be used with
  29 +`add_subproject`. You can add the repository to your code (preferably as a git
  30 +submodule), then add the following line to your project (assuming your folder is
  31 +called CLI11):
22 32  
23 33 ```cmake
24 34 add_subdirectory(CLI11)
25 35 ```
26 36  
27   -Then, you will have a target `CLI11::CLI11` that you can link to with `target_link_libraries`. It will provide the include paths you need for the library. This is the way [GooFit](https://github.com/GooFit/GooFit) uses CLI11, for example.
  37 +Then, you will have a target `CLI11::CLI11` that you can link to with
  38 +`target_link_libraries`. It will provide the include paths you need for the
  39 +library. This is the way [GooFit](https://github.com/GooFit/GooFit) uses CLI11,
  40 +for example.
28 41  
29   -You can also configure and optionally install CLI11, and CMake will create the necessary `lib/cmake/CLI11/CLI11Config.cmake` files, so `find_package(CLI11 CONFIG REQUIRED)` also works.
  42 +You can also configure and optionally install CLI11, and CMake will create the
  43 +necessary `lib/cmake/CLI11/CLI11Config.cmake` files, so
  44 +`find_package(CLI11 CONFIG REQUIRED)` also works.
30 45  
31 46 If you use conan.io, CLI11 supports that too.
32 47  
33 48 ### Running tests on the full edition
34 49  
35   -CLI11 has examples and tests that can be accessed using a CMake build on any platform. Simply build and run ctest to run the 200+ tests to ensure CLI11 works on your system.
  50 +CLI11 has examples and tests that can be accessed using a CMake build on any
  51 +platform. Simply build and run ctest to run the 200+ tests to ensure CLI11 works
  52 +on your system.
36 53  
37   -As an example of the build system, the following code will download and test CLI11 in a simple Alpine Linux docker container [^1]:
  54 +As an example of the build system, the following code will download and test
  55 +CLI11 in a simple Alpine Linux docker container [^1]:
38 56  
39 57 ```term
40 58 gitbook:~ $ docker run -it alpine
... ... @@ -78,7 +96,8 @@ Test project /CLI11/build
78 96 Total Test time (real) = 0.34 sec
79 97 ```
80 98  
81   -For the curious, the CMake options and defaults are listed below. Most options default to off if CLI11 is used as a subdirectory in another project.
  99 +For the curious, the CMake options and defaults are listed below. Most options
  100 +default to off if CLI11 is used as a subdirectory in another project.
82 101  
83 102 | Option | Description |
84 103 | ----------------------------- | ----------------------------------------------------------------------------------------------- |
... ... @@ -89,4 +108,7 @@ For the curious, the CMake options and defaults are listed below. Most options d
89 108 | `CLI11_CLANG_TIDY=OFF` | Run `clang-tidy` on the examples and headers. Requires CMake 3.6+. |
90 109 | `CLI11_CLANG_TIDY_OPTIONS=""` | Options to pass to `clang-tidy`, such as `-fix` (single threaded build only if applying fixes!) |
91 110  
92   -[^1]: Docker is being used to create a pristine disposable environment; there is nothing special about this container. Alpine is being used because it is small, modern, and fast. Commands are similar on any other platform.
  111 +[^1]:
  112 + Docker is being used to create a pristine disposable environment; there is
  113 + nothing special about this container. Alpine is being used because it is
  114 + small, modern, and fast. Commands are similar on any other platform.
... ...
book/chapters/internals.md
... ... @@ -2,7 +2,8 @@
2 2  
3 3 ## Callbacks
4 4  
5   -The library was designed to bind to existing variables without requiring typed classes or inheritance. This is accomplished through lambda functions.
  5 +The library was designed to bind to existing variables without requiring typed
  6 +classes or inheritance. This is accomplished through lambda functions.
6 7  
7 8 This looks like:
8 9  
... ... @@ -14,30 +15,40 @@ Option* add_option(string name, T item) {
14 15 }
15 16 ```
16 17  
17   -Obviously, you can't access `T` after the `add_` method is over, so it stores the string representation of the default value if it receives the special `true` value as the final argument (not shown above).
  18 +Obviously, you can't access `T` after the `add_` method is over, so it stores
  19 +the string representation of the default value if it receives the special `true`
  20 +value as the final argument (not shown above).
18 21  
19 22 ## Parsing
20 23  
21 24 Parsing follows the following procedure:
22 25  
23   -1. `_validate`: Make sure the defined options and subcommands are self consistent.
  26 +1. `_validate`: Make sure the defined options and subcommands are self
  27 + consistent.
24 28 2. `_parse`: Main parsing routine. See below.
25 29 3. `_run_callback`: Run an App callback if present.
26 30  
27 31 The parsing phase is the most interesting:
28 32  
29   -1. `_parse_single`: Run on each entry on the command line and fill the options/subcommands.
  33 +1. `_parse_single`: Run on each entry on the command line and fill the
  34 + options/subcommands.
30 35 2. `_process`: Run the procedure listed below.
31   -3. `_process_extra`: This throws an error if needed on extra arguments that didn't fit in the parse.
  36 +3. `_process_extra`: This throws an error if needed on extra arguments that
  37 + didn't fit in the parse.
32 38  
33   -The `_process` procedure runs the following steps; each step is recursive and completes all subcommands before moving to the next step (new in 1.7). This ensures that interactions between options and subcommand options is consistent.
  39 +The `_process` procedure runs the following steps; each step is recursive and
  40 +completes all subcommands before moving to the next step (new in 1.7). This
  41 +ensures that interactions between options and subcommand options is consistent.
34 42  
35 43 1. `_process_ini`: This reads an INI file and fills/changes options as needed.
36 44 2. `_process_env`: Look for environment variables.
37   -3. `_process_callbacks`: Run the callback functions - this fills out the variables.
  45 +3. `_process_callbacks`: Run the callback functions - this fills out the
  46 + variables.
38 47 4. `_process_help_flags`: Run help flags if present (and quit).
39   -5. `_process_requirements`: Make sure needs/excludes, required number of options present.
  48 +5. `_process_requirements`: Make sure needs/excludes, required number of options
  49 + present.
40 50  
41 51 ## Exceptions
42 52  
43   -The library immediately returns a C++ exception when it detects a problem, such as an incorrect construction or a malformed command line.
  53 +The library immediately returns a C++ exception when it detects a problem, such
  54 +as an incorrect construction or a malformed command line.
... ...
book/chapters/options.md
... ... @@ -2,21 +2,29 @@
2 2  
3 3 ## Simple options
4 4  
5   -The most versatile addition to a command line program is an option. This is like a flag, but it takes an argument. CLI11 handles all the details for many types of options for you, based on their type. To add an option:
  5 +The most versatile addition to a command line program is an option. This is like
  6 +a flag, but it takes an argument. CLI11 handles all the details for many types
  7 +of options for you, based on their type. To add an option:
6 8  
7 9 ```cpp
8 10 int int_option{0};
9 11 app.add_option("-i", int_option, "Optional description");
10 12 ```
11 13  
12   -This will bind the option `-i` to the integer `int_option`. On the command line, a single value that can be converted to an integer will be expected. Non-integer results will fail. If that option is not given, CLI11 will not touch the initial value. This allows you to set up defaults by simply setting your value beforehand. If you want CLI11 to display your default value, you can add `->capture_default_str()` after the option.
  14 +This will bind the option `-i` to the integer `int_option`. On the command line,
  15 +a single value that can be converted to an integer will be expected. Non-integer
  16 +results will fail. If that option is not given, CLI11 will not touch the initial
  17 +value. This allows you to set up defaults by simply setting your value
  18 +beforehand. If you want CLI11 to display your default value, you can add
  19 +`->capture_default_str()` after the option.
13 20  
14 21 ```cpp
15 22 int int_option{0};
16 23 app.add_option("-i", int_option, "Optional description")->capture_default_str();
17 24 ```
18 25  
19   -You can use any C++ int-like type, not just `int`. CLI11 understands the following categories of types:
  26 +You can use any C++ int-like type, not just `int`. CLI11 understands the
  27 +following categories of types:
20 28  
21 29 | Type | CLI11 |
22 30 | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
... ... @@ -31,35 +39,60 @@ You can use any C++ int-like type, not just `int`. CLI11 understands the followi
31 39 | function | A function that takes an array of strings and returns a string that describes the conversion failure or empty for success. May be the empty function. (`{}`) |
32 40 | streamable | any other type with a `<<` operator will also work |
33 41  
34   -By default, CLI11 will assume that an option is optional, and one value is expected if you do not use a vector. You can change this on a specific option using option modifiers. An option name may start with any character except ('-', ' ', '\n', and '!'). For long options, after the first character all characters are allowed except ('=',':','{',' ', '\n'). Names are given as a comma separated string, with the dash or dashes. An option 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.
  42 +By default, CLI11 will assume that an option is optional, and one value is
  43 +expected if you do not use a vector. You can change this on a specific option
  44 +using option modifiers. An option name may start with any character except ('-',
  45 +' ', '\n', and '!'). For long options, after the first character all characters
  46 +are allowed except ('=',':','{',' ', '\n'). Names are given as a comma separated
  47 +string, with the dash or dashes. An option can have as many names as you want,
  48 +and afterward, using `count`, you can use any of the names, with dashes as
  49 +needed, to count the options. One of the names is allowed to be given without
  50 +proceeding dash(es); if present the option is a positional option, and that name
  51 +will be used on the help line for its positional form.
35 52  
36 53 ## Positional options and aliases
37 54  
38   -When you give an option on the command line without a name, that is a positional option. Positional options are accepted in the same order they are defined. So, for example:
  55 +When you give an option on the command line without a name, that is a positional
  56 +option. Positional options are accepted in the same order they are defined. So,
  57 +for example:
39 58  
40 59 ```term
41 60 gitbook:examples $ ./a.out one --two three four
42 61 ```
43 62  
44   -The string `one` would have to be the first positional option. If `--two` is a flag, then the remaining two strings are positional. If `--two` is a one-argument option, then `four` is the second positional. If `--two` accepts two or more arguments, then there are no more positionals.
  63 +The string `one` would have to be the first positional option. If `--two` is a
  64 +flag, then the remaining two strings are positional. If `--two` is a
  65 +one-argument option, then `four` is the second positional. If `--two` accepts
  66 +two or more arguments, then there are no more positionals.
45 67  
46   -To make a positional option, you simply give CLI11 one name that does not start with a dash. You can have as many (non-overlapping) names as you want for an option, but only one positional name. So the following name string is valid:
  68 +To make a positional option, you simply give CLI11 one name that does not start
  69 +with a dash. You can have as many (non-overlapping) names as you want for an
  70 +option, but only one positional name. So the following name string is valid:
47 71  
48 72 ```cpp
49 73 "-a,-b,--alpha,--beta,mypos"
50 74 ```
51 75  
52   -This would make two short option aliases, two long option alias, and the option would be also be accepted as a positional.
  76 +This would make two short option aliases, two long option alias, and the option
  77 +would be also be accepted as a positional.
53 78  
54 79 ## Containers of options
55 80  
56   -If you use a vector or other container instead of a plain option, you can accept more than one value on the command line. By default, a container accepts as many options as possible, until the next value that could be a valid option name. You can specify a set number using an option modifier `->expected(N)`. (The default unlimited behavior on vectors is restored with `N=-1`) CLI11 does not differentiate between these two methods for unlimited acceptance options.
  81 +If you use a vector or other container instead of a plain option, you can accept
  82 +more than one value on the command line. By default, a container accepts as many
  83 +options as possible, until the next value that could be a valid option name. You
  84 +can specify a set number using an option modifier `->expected(N)`. (The default
  85 +unlimited behavior on vectors is restored with `N=-1`) CLI11 does not
  86 +differentiate between these two methods for unlimited acceptance options.
57 87  
58 88 | Separate names | Combined names |
59 89 | ----------------- | -------------- |
60 90 | `--vec 1 --vec 2` | `--vec 1 2` |
61 91  
62   -It is also possible to specify a minimum and maximum number through `->expected(Min,Max)`. It is also possible to specify a min and max type size for the elements of the container. It most cases these values will be automatically determined but a user can manually restrict them.
  92 +It is also possible to specify a minimum and maximum number through
  93 +`->expected(Min,Max)`. It is also possible to specify a min and max type size
  94 +for the elements of the container. It most cases these values will be
  95 +automatically determined but a user can manually restrict them.
63 96  
64 97 An example of setting up a vector option:
65 98  
... ... @@ -68,13 +101,19 @@ std::vector&lt;int&gt; int_vec;
68 101 app.add_option("--vec", int_vec, "My vector option");
69 102 ```
70 103  
71   -Vectors will be replaced by the parsed content if the option is given on the command line.
  104 +Vectors will be replaced by the parsed content if the option is given on the
  105 +command line.
72 106  
73   -A definition of a container for purposes of CLI11 is a type with a `end()`, `insert(...)`, `clear()` and `value_type` definitions. This includes `vector`, `set`, `deque`, `list`, `forward_iist`, `map`, `unordered_map` and a few others from the standard library, and many other containers from the boost library.
  107 +A definition of a container for purposes of CLI11 is a type with a `end()`,
  108 +`insert(...)`, `clear()` and `value_type` definitions. This includes `vector`,
  109 +`set`, `deque`, `list`, `forward_iist`, `map`, `unordered_map` and a few others
  110 +from the standard library, and many other containers from the boost library.
74 111  
75 112 ### Empty containers
76 113  
77   -By default a container will never return an empty container. If it is desired to allow an empty container to be returned, then the option must be modified with a 0 as the minimum expected value
  114 +By default a container will never return an empty container. If it is desired to
  115 +allow an empty container to be returned, then the option must be modified with a
  116 +0 as the minimum expected value
78 117  
79 118 ```cpp
80 119 std::vector<int> int_vec;
... ... @@ -83,7 +122,8 @@ app.add_option(&quot;--vec&quot;, int_vec, &quot;Empty vector allowed&quot;)-&gt;expected(0,-1);
83 122  
84 123 An empty vector can than be specified on the command line as `--vec {}`
85 124  
86   -To allow an empty vector from config file, the default must be set in addition to the above modification.
  125 +To allow an empty vector from config file, the default must be set in addition
  126 +to the above modification.
87 127  
88 128 ```cpp
89 129 std::vector<int> int_vec;
... ... @@ -113,13 +153,20 @@ std::vector&lt;std::vector&lt;int&gt;&gt; int_vec;
113 153 app.add_option("--vec", int_vec, "My vector of vectors option");
114 154 ```
115 155  
116   -CLI11 inserts a separator sequence at the start of each argument call to separate the vectors. So unless the separators are injected as part of the command line each call of the option on the command line will result in a separate element of the outer vector. This can be manually controlled via `inject_separator(true|false)` but in nearly all cases this should be left to the defaults. To insert of a separator from the command line add a `%%` where the separation should occur.
  156 +CLI11 inserts a separator sequence at the start of each argument call to
  157 +separate the vectors. So unless the separators are injected as part of the
  158 +command line each call of the option on the command line will result in a
  159 +separate element of the outer vector. This can be manually controlled via
  160 +`inject_separator(true|false)` but in nearly all cases this should be left to
  161 +the defaults. To insert of a separator from the command line add a `%%` where
  162 +the separation should occur.
117 163  
118 164 ```bash
119 165 cmd --vec_of_vec 1 2 3 4 %% 1 2
120 166 ```
121 167  
122   -would then result in a container of size 2 with the first element containing 4 values and the second 2.
  168 +would then result in a container of size 2 with the first element containing 4
  169 +values and the second 2.
123 170  
124 171 This separator is also the only way to get values into something like
125 172  
... ... @@ -130,7 +177,8 @@ app.add_option(&quot;--vec&quot;, two_vecs, &quot;pair of vectors&quot;);
130 177  
131 178 without calling the argument twice.
132 179  
133   -Further levels of nesting containers should compile but intermediate layers will only have a single element in the container, so is probably not that useful.
  180 +Further levels of nesting containers should compile but intermediate layers will
  181 +only have a single element in the container, so is probably not that useful.
134 182  
135 183 ### Nested types
136 184  
... ... @@ -141,18 +189,21 @@ std::map&lt;int, std::pair&lt;int,std::string&gt;&gt; map;
141 189 app.add_option("--dict", map, "map of pairs");
142 190 ```
143 191  
144   -will require 3 arguments for each invocation, and multiple sets of 3 arguments can be entered for a single invocation on the command line.
  192 +will require 3 arguments for each invocation, and multiple sets of 3 arguments
  193 +can be entered for a single invocation on the command line.
145 194  
146 195 ```cpp
147 196 std::map<int, std::pair<int,std::vector<std::string>>> map;
148 197 app.add_option("--dict", map, "map of pairs");
149 198 ```
150 199  
151   -will result in a requirement for 2 integers on each invocation and absorb an unlimited number of strings including 0.
  200 +will result in a requirement for 2 integers on each invocation and absorb an
  201 +unlimited number of strings including 0.
152 202  
153 203 ## Option modifiers
154 204  
155   -When you call `add_option`, you get a pointer to the added option. You can use that to add option modifiers. A full listing of the option modifiers:
  205 +When you call `add_option`, you get a pointer to the added option. You can use
  206 +that to add option modifiers. A full listing of the option modifiers:
156 207  
157 208 | Modifier | Description |
158 209 | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
... ... @@ -190,11 +241,19 @@ When you call `add_option`, you get a pointer to the added option. You can use t
190 241 | `->trigger_on_parse()` | Have the option callback be triggered when the value is parsed vs. at the end of all parsing, the option callback can potentially be executed multiple times. Generally only useful if you have a user defined callback or validation check. Or potentially if a vector input is given multiple times as it will clear the results when a repeat option is given via command line. It will trigger the callbacks once per option call on the command line |
191 242 | `->option_text(string)` | Sets the text between the option name and description. |
192 243  
193   -The `->check(...)` and `->transform(...)` modifiers can also take a callback function of the form `bool function(std::string)` that runs on every value that the option receives, and returns a value that tells CLI11 whether the check passed or failed.
  244 +The `->check(...)` and `->transform(...)` modifiers can also take a callback
  245 +function of the form `bool function(std::string)` that runs on every value that
  246 +the option receives, and returns a value that tells CLI11 whether the check
  247 +passed or failed.
194 248  
195 249 ## Using the `CLI::Option` pointer
196 250  
197   -Each of the option creation mechanisms returns a pointer to the internally stored option. If you save that pointer, you can continue to access the option, and change setting on it later. The Option object can also be converted to a bool to see if it was passed, or `->count()` can be used to see how many times the option was passed. Since flags are also options, the same methods work on them.
  251 +Each of the option creation mechanisms returns a pointer to the internally
  252 +stored option. If you save that pointer, you can continue to access the option,
  253 +and change setting on it later. The Option object can also be converted to a
  254 +bool to see if it was passed, or `->count()` can be used to see how many times
  255 +the option was passed. Since flags are also options, the same methods work on
  256 +them.
198 257  
199 258 ```cpp
200 259 CLI::Option* opt = app.add_flag("--opt");
... ... @@ -207,17 +266,33 @@ if(* opt)
207 266  
208 267 ## Inheritance of defaults
209 268  
210   -One of CLI11's systems to allow customizability without high levels of verbosity is the inheritance system. You can set default values on the parent `App`, and all options and subcommands created from it remember the default values at the point of creation. The default value for Options, specifically, are accessible through the `option_defaults()` method. There are a number of settings that can be set and inherited:
  269 +One of CLI11's systems to allow customizability without high levels of verbosity
  270 +is the inheritance system. You can set default values on the parent `App`, and
  271 +all options and subcommands created from it remember the default values at the
  272 +point of creation. The default value for Options, specifically, are accessible
  273 +through the `option_defaults()` method. There are a number of settings that can
  274 +be set and inherited:
211 275  
212 276 - `group`: The group name starts as "Options"
213   -- `required`: If the option must be given. Defaults to `false`. Is ignored for flags.
214   -- `multi_option_policy`: What to do if several copies of an option are passed and one value is expected. Defaults to `CLI::MultiOptionPolicy::Throw`. This is also used for bool flags, but they always are created with the value `CLI::MultiOptionPolicy::TakeLast` or `CLI::MultiOptionPolicy::Sum` regardless of the default, so that multiple bool flags does not cause an error. But you can override that setting by calling the `multi_option_policy` directly.
  277 +- `required`: If the option must be given. Defaults to `false`. Is ignored for
  278 + flags.
  279 +- `multi_option_policy`: What to do if several copies of an option are passed
  280 + and one value is expected. Defaults to `CLI::MultiOptionPolicy::Throw`. This
  281 + is also used for bool flags, but they always are created with the value
  282 + `CLI::MultiOptionPolicy::TakeLast` or `CLI::MultiOptionPolicy::Sum` regardless
  283 + of the default, so that multiple bool flags does not cause an error. But you
  284 + can override that setting by calling the `multi_option_policy` directly.
215 285 - `ignore_case`: Allow any mixture of cases for the option or flag name
216   -- `ignore_underscore`: Allow any number of underscores in the option or flag name
217   -- `configurable`: Specify whether an option can be configured through a config file
218   -- `disable_flag_override`: do not allow flag values to be overridden on the command line
219   -- `always_capture_default`: specify that the default values should be automatically captured.
220   -- `delimiter`: A delimiter to use for capturing multiple values in a single command line string (e.g. --flag="flag,-flag2,flag3")
  286 +- `ignore_underscore`: Allow any number of underscores in the option or flag
  287 + name
  288 +- `configurable`: Specify whether an option can be configured through a config
  289 + file
  290 +- `disable_flag_override`: do not allow flag values to be overridden on the
  291 + command line
  292 +- `always_capture_default`: specify that the default values should be
  293 + automatically captured.
  294 +- `delimiter`: A delimiter to use for capturing multiple values in a single
  295 + command line string (e.g. --flag="flag,-flag2,flag3")
221 296  
222 297 An example of usage:
223 298  
... ... @@ -228,11 +303,13 @@ app.add_flag(&quot;--CaSeLeSs&quot;);
228 303 app.get_group() // is "Required"
229 304 ```
230 305  
231   -Groups are mostly for visual organization, but an empty string for a group name will hide the option.
  306 +Groups are mostly for visual organization, but an empty string for a group name
  307 +will hide the option.
232 308  
233 309 ### Windows style options
234 310  
235   -You can also set the app setting `app->allow_windows_style_options()` to allow windows style options to also be recognized on the command line:
  311 +You can also set the app setting `app->allow_windows_style_options()` to allow
  312 +windows style options to also be recognized on the command line:
236 313  
237 314 - `/a` (flag)
238 315 - `/f filename` (option)
... ... @@ -241,11 +318,23 @@ You can also set the app setting `app-&gt;allow_windows_style_options()` to allow w
241 318 - `/file:filename` (colon)
242 319 - `/long_flag:false` (long flag with : to override the default value)
243 320  
244   -Windows style options do not allow combining short options or values not separated from the short option like with `-` options. You still specify option names in the same manner as on Linux with single and double dashes when you use the `add_*` functions, and the Linux style on the command line will still work. If a long and a short option share the same name, the option will match on the first one defined.
  321 +Windows style options do not allow combining short options or values not
  322 +separated from the short option like with `-` options. You still specify option
  323 +names in the same manner as on Linux with single and double dashes when you use
  324 +the `add_*` functions, and the Linux style on the command line will still work.
  325 +If a long and a short option share the same name, the option will match on the
  326 +first one defined.
245 327  
246 328 ## Parse configuration
247 329  
248   -How an option and its arguments are parsed depends on a set of controls that are part of the option structure. In most circumstances these controls are set automatically based on the type or function used to create the option and the type the arguments are parsed into. The variables define the size of the underlying type (essentially how many strings make up the type), the expected size (how many groups are expected) and a flag indicating if multiple groups are allowed with a single option. And these interact with the `multi_option_policy` when it comes time to parse.
  330 +How an option and its arguments are parsed depends on a set of controls that are
  331 +part of the option structure. In most circumstances these controls are set
  332 +automatically based on the type or function used to create the option and the
  333 +type the arguments are parsed into. The variables define the size of the
  334 +underlying type (essentially how many strings make up the type), the expected
  335 +size (how many groups are expected) and a flag indicating if multiple groups are
  336 +allowed with a single option. And these interact with the `multi_option_policy`
  337 +when it comes time to parse.
249 338  
250 339 ### Examples
251 340  
... ... @@ -256,7 +345,12 @@ std::string val;
256 345 app.add_option("--opt",val,"description");
257 346 ```
258 347  
259   -creates an option that assigns a value to a `std::string` When this option is constructed it sets a type_size min and max of 1. Meaning that the assignment uses a single string. The Expected size is also set to 1 by default, and `allow_extra_args` is set to false. meaning that each time this option is called 1 argument is expected. This would also be the case if val were a `double`, `int` or any other single argument types.
  348 +creates an option that assigns a value to a `std::string` When this option is
  349 +constructed it sets a type_size min and max of 1. Meaning that the assignment
  350 +uses a single string. The Expected size is also set to 1 by default, and
  351 +`allow_extra_args` is set to false. meaning that each time this option is called
  352 +1 argument is expected. This would also be the case if val were a `double`,
  353 +`int` or any other single argument types.
260 354  
261 355 now for example
262 356  
... ... @@ -265,35 +359,49 @@ std::pair&lt;int, std::string&gt; val;
265 359 app.add_option("--opt",val,"description");
266 360 ```
267 361  
268   -In this case the typesize is automatically detected to be 2 instead of 1, so the parsing would expect 2 arguments associated with the option.
  362 +In this case the typesize is automatically detected to be 2 instead of 1, so the
  363 +parsing would expect 2 arguments associated with the option.
269 364  
270 365 ```cpp
271 366 std::vector<int> val;
272 367 app.add_option("--opt",val,"description");
273 368 ```
274 369  
275   -detects a type size of 1, since the underlying element type is a single string, so the minimum number of strings is 1. But since it is a vector the expected number can be very big. The default for a vector is (1<<30), and the allow_extra_args is set to true. This means that at least 1 argument is expected to follow the option, but arbitrary numbers of arguments may follow. These are checked if they have the form of an option but if not they are added to the argument.
  370 +detects a type size of 1, since the underlying element type is a single string,
  371 +so the minimum number of strings is 1. But since it is a vector the expected
  372 +number can be very big. The default for a vector is (1<<30), and the
  373 +allow_extra_args is set to true. This means that at least 1 argument is expected
  374 +to follow the option, but arbitrary numbers of arguments may follow. These are
  375 +checked if they have the form of an option but if not they are added to the
  376 +argument.
276 377  
277 378 ```cpp
278 379 std::vector<std::tuple<int, double, std::string>> val;
279 380 app.add_option("--opt",val,"description");
280 381 ```
281 382  
282   -gets into the complicated cases where the type size is now 3. and the expected max is set to a large number and `allow_extra_args` is set to true. In this case at least 3 arguments are required to follow the option, and subsequent groups must come in groups of three, otherwise an error will result.
  383 +gets into the complicated cases where the type size is now 3. and the expected
  384 +max is set to a large number and `allow_extra_args` is set to true. In this case
  385 +at least 3 arguments are required to follow the option, and subsequent groups
  386 +must come in groups of three, otherwise an error will result.
283 387  
284 388 ```cpp
285 389 bool val{false};
286 390 app.add_flag("--opt",val,"description");
287 391 ```
288 392  
289   -Using the add_flag methods for creating options creates an option with an expected size of 0, implying no arguments can be passed.
  393 +Using the add_flag methods for creating options creates an option with an
  394 +expected size of 0, implying no arguments can be passed.
290 395  
291 396 ```cpp
292 397 std::complex<double> val;
293 398 app.add_option("--opt",val,"description");
294 399 ```
295 400  
296   -triggers the complex number type which has a min of 1 and max of 2, so 1 or 2 strings can be passed. Complex number conversion supports arguments of the form "1+2j" or "1","2", or "1" "2i". The imaginary number symbols `i` and `j` are interchangeable in this context.
  401 +triggers the complex number type which has a min of 1 and max of 2, so 1 or 2
  402 +strings can be passed. Complex number conversion supports arguments of the form
  403 +"1+2j" or "1","2", or "1" "2i". The imaginary number symbols `i` and `j` are
  404 +interchangeable in this context.
297 405  
298 406 ```cpp
299 407 std::vector<std::vector<int>> val;
... ... @@ -304,7 +412,9 @@ has a type size of 1 to (1&lt;&lt;30).
304 412  
305 413 ### Customization
306 414  
307   -The `type_size(N)`, `type_size(Nmin, Nmax)`, `expected(N)`, `expected(Nmin,Nmax)`, and `allow_extra_args()` can be used to customize an option. For example
  415 +The `type_size(N)`, `type_size(Nmin, Nmax)`, `expected(N)`,
  416 +`expected(Nmin,Nmax)`, and `allow_extra_args()` can be used to customize an
  417 +option. For example
308 418  
309 419 ```cpp
310 420 std::string val;
... ... @@ -312,16 +422,38 @@ auto opt=app.add_flag(&quot;--opt{vvv}&quot;,val,&quot;description&quot;);
312 422 opt->expected(0,1);
313 423 ```
314 424  
315   -will create a hybrid option, that can exist on its own in which case the value "vvv" is used or if a value is given that value will be used.
  425 +will create a hybrid option, that can exist on its own in which case the value
  426 +"vvv" is used or if a value is given that value will be used.
316 427  
317   -There are some additional options that can be specified to modify an option for specific cases:
  428 +There are some additional options that can be specified to modify an option for
  429 +specific cases:
318 430  
319   -- `->run_callback_for_default()` will specify that the callback should be executed when a default_val is set. This is set automatically when appropriate though it can be turned on or off and any user specified callback for an option will be executed when the default value for an option is set.
  431 +- `->run_callback_for_default()` will specify that the callback should be
  432 + executed when a default_val is set. This is set automatically when appropriate
  433 + though it can be turned on or off and any user specified callback for an
  434 + option will be executed when the default value for an option is set.
320 435  
321   -- `->force_callback()` will for the callback/value assignment to run at the conclusion of parsing regardless of whether the option was supplied or not. This can be used to force the default or execute some code.
  436 +- `->force_callback()` will for the callback/value assignment to run at the
  437 + conclusion of parsing regardless of whether the option was supplied or not.
  438 + This can be used to force the default or execute some code.
322 439  
323   -- `->trigger_on_parse()` will trigger the callback or value assignment each time the argument is passed. The value is reset if the option is supplied multiple times.
  440 +- `->trigger_on_parse()` will trigger the callback or value assignment each time
  441 + the argument is passed. The value is reset if the option is supplied multiple
  442 + times.
324 443  
325 444 ## Unusual circumstances
326 445  
327   -There are a few cases where some things break down in the type system managing options and definitions. Using the `add_option` method defines a lambda function to extract a default value if required. In most cases this is either straightforward or a failure is detected automatically and handled. But in a few cases a streaming template is available that several layers down may not actually be defined. This results in CLI11 not being able to detect this circumstance automatically and will result in compile error. One specific known case is `boost::optional` if the boost optional_io header is included. This header defines a template for all boost optional values even if they do not actually have a streaming operator. For example `boost::optional<std::vector>` does not have a streaming operator but one is detected since it is part of a template. For these cases a secondary method `app->add_option_no_stream(...)` is provided that bypasses this operation completely and should compile in these cases.
  446 +There are a few cases where some things break down in the type system managing
  447 +options and definitions. Using the `add_option` method defines a lambda function
  448 +to extract a default value if required. In most cases this is either
  449 +straightforward or a failure is detected automatically and handled. But in a few
  450 +cases a streaming template is available that several layers down may not
  451 +actually be defined. This results in CLI11 not being able to detect this
  452 +circumstance automatically and will result in compile error. One specific known
  453 +case is `boost::optional` if the boost optional_io header is included. This
  454 +header defines a template for all boost optional values even if they do not
  455 +actually have a streaming operator. For example `boost::optional<std::vector>`
  456 +does not have a streaming operator but one is detected since it is part of a
  457 +template. For these cases a secondary method `app->add_option_no_stream(...)` is
  458 +provided that bypasses this operation completely and should compile in these
  459 +cases.
... ...
book/chapters/subcommands.md
1 1 # Subcommands and the App
2 2  
3   -Subcommands are keyword that invoke a new set of options and features. For example, the `git`
4   -command has a long series of subcommands, like `add` and `commit`. Each can have its own options
5   -and implementations. This chapter will focus on implementations that are contained in the same
6   -C++ application, though the system git uses to extend the main command by calling other commands
7   -in separate executables is supported too; that's called "Prefix commands" and is included at the
8   -end of this chapter.
  3 +Subcommands are keyword that invoke a new set of options and features. For
  4 +example, the `git` command has a long series of subcommands, like `add` and
  5 +`commit`. Each can have its own options and implementations. This chapter will
  6 +focus on implementations that are contained in the same C++ application, though
  7 +the system git uses to extend the main command by calling other commands in
  8 +separate executables is supported too; that's called "Prefix commands" and is
  9 +included at the end of this chapter.
9 10  
10 11 ## The parent App
11 12  
12   -We'll start by discussing the parent `App`. You've already used it quite a bit, to create
13   -options and set option defaults. There are several other things you can do with an `App`, however.
  13 +We'll start by discussing the parent `App`. You've already used it quite a bit,
  14 +to create options and set option defaults. There are several other things you
  15 +can do with an `App`, however.
14 16  
15   -You are given a lot of control the help output. You can set a footer with `app.footer("My Footer")`.
16   -You can replace the default help print when a `ParseError` is thrown with `app.set_failure_message(CLI::FailureMessage::help)`.
17   -The default is `CLI:::FailureMessage::simple`, and you can easily define a new one. Just make a (lambda) function that takes an App pointer
18   -and a reference to an error code (even if you don't use them), and returns a string.
  17 +You are given a lot of control the help output. You can set a footer with
  18 +`app.footer("My Footer")`. You can replace the default help print when a
  19 +`ParseError` is thrown with
  20 +`app.set_failure_message(CLI::FailureMessage::help)`. The default is
  21 +`CLI:::FailureMessage::simple`, and you can easily define a new one. Just make a
  22 +(lambda) function that takes an App pointer and a reference to an error code
  23 +(even if you don't use them), and returns a string.
19 24  
20 25 ## Adding a subcommand
21 26  
... ... @@ -25,12 +30,14 @@ Subcommands can be added just like an option:
25 30 CLI::App* sub = app.add_subcommand("sub", "This is a subcommand");
26 31 ```
27 32  
28   -The subcommand should have a name as the first argument, and a little description for the
29   -second argument. A pointer to the internally stored subcommand is provided; you usually will
30   -be capturing that pointer and using it later (though you can use callbacks if you prefer). As
31   -always, feel free to use `auto sub = ...` instead of naming the type.
  33 +The subcommand should have a name as the first argument, and a little
  34 +description for the second argument. A pointer to the internally stored
  35 +subcommand is provided; you usually will be capturing that pointer and using it
  36 +later (though you can use callbacks if you prefer). As always, feel free to use
  37 +`auto sub = ...` instead of naming the type.
32 38  
33   -You can check to see if the subcommand was received on the command line several ways:
  39 +You can check to see if the subcommand was received on the command line several
  40 +ways:
34 41  
35 42 ```cpp
36 43 if(*sub) ...
... ... @@ -39,39 +46,53 @@ if(app.got_subcommand(sub)) ...
39 46 if(app.got_subcommand("sub")) ...
40 47 ```
41 48  
42   -You can also get a list of subcommands with `get_subcommands()`, and they will be in parsing order.
  49 +You can also get a list of subcommands with `get_subcommands()`, and they will
  50 +be in parsing order.
43 51  
44 52 There are a lot of options that you can set on a subcommand; in fact,
45   -subcommands have exactly the same options as your main app, since they are actually
46   -the same class of object (as you may have guessed from the type above). This has the
47   -pleasant side affect of making subcommands infinitely nestable.
  53 +subcommands have exactly the same options as your main app, since they are
  54 +actually the same class of object (as you may have guessed from the type above).
  55 +This has the pleasant side affect of making subcommands infinitely nestable.
48 56  
49 57 ## Required subcommands
50 58  
51   -Each App has controls to set the number of subcommands you expect. This is controlled by:
  59 +Each App has controls to set the number of subcommands you expect. This is
  60 +controlled by:
52 61  
53 62 ```cpp
54 63 app.require_subcommand(/* min */ 0, /* max */ 1);
55 64 ```
56 65  
57   -If you set the max to 0, CLI11 will allow an unlimited number of subcommands. After the (non-unlimited) maximum
58   -is reached, CLI11 will stop trying to match subcommands. So the if you pass "`one two`" to a command, and both `one`
59   -and `two` are subcommands, it will depend on the maximum number as to whether the "`two`" is a subcommand or an argument to the
60   -"`one`" subcommand.
  66 +If you set the max to 0, CLI11 will allow an unlimited number of subcommands.
  67 +After the (non-unlimited) maximum is reached, CLI11 will stop trying to match
  68 +subcommands. So the if you pass "`one two`" to a command, and both `one` and
  69 +`two` are subcommands, it will depend on the maximum number as to whether the
  70 +"`two`" is a subcommand or an argument to the "`one`" subcommand.
61 71  
62   -As a shortcut, you can also call the `require_subcommand` method with one argument; that will be the fixed number of subcommands if positive, it
63   -will be the maximum number if negative. Calling it without an argument will set the required subcommands to 1 or more.
  72 +As a shortcut, you can also call the `require_subcommand` method with one
  73 +argument; that will be the fixed number of subcommands if positive, it will be
  74 +the maximum number if negative. Calling it without an argument will set the
  75 +required subcommands to 1 or more.
64 76  
65   -The maximum number of subcommands is inherited by subcommands. This allows you to set the maximum to 1 once at the beginning on the parent app if you only want single subcommands throughout your app. You should keep this in mind, if you are dealing with lots of nested subcommands.
  77 +The maximum number of subcommands is inherited by subcommands. This allows you
  78 +to set the maximum to 1 once at the beginning on the parent app if you only want
  79 +single subcommands throughout your app. You should keep this in mind, if you are
  80 +dealing with lots of nested subcommands.
66 81  
67 82 ## Using callbacks
68 83  
69   -You've already seen how to check to see what subcommands were given. It's often much easier, however, to just define the code you want to run when you are making your parser, and not run a bunch of code after `CLI11_PARSE` to analyse the state (Procedural! Yuck!). You can do that with lambda functions. A `std::function<void()>` callback `.callback()` is provided, and CLI11 ensures that all options are prepared and usable by reference capture before entering the callback. An
70   -example is shown below in the `geet` program.
  84 +You've already seen how to check to see what subcommands were given. It's often
  85 +much easier, however, to just define the code you want to run when you are
  86 +making your parser, and not run a bunch of code after `CLI11_PARSE` to analyse
  87 +the state (Procedural! Yuck!). You can do that with lambda functions. A
  88 +`std::function<void()>` callback `.callback()` is provided, and CLI11 ensures
  89 +that all options are prepared and usable by reference capture before entering
  90 +the callback. An example is shown below in the `geet` program.
71 91  
72 92 ## Inheritance of defaults
73 93  
74   -The following values are inherited when you add a new subcommand. This happens at the point the subcommand is created:
  94 +The following values are inherited when you add a new subcommand. This happens
  95 +at the point the subcommand is created:
75 96  
76 97 - The name and description for the help flag
77 98 - The footer
... ... @@ -94,28 +115,39 @@ There are several special modes for Apps and Subcommands.
94 115  
95 116 ### Allow extras
96 117  
97   -Normally CLI11 throws an error if you don't match all items given on the command line. However, you can enable `allow_extras()`
98   -to instead store the extra values in `.remaining()`. You can get all remaining options including those in contained subcommands recursively in the original order with `.remaining(true)`.
99   -`.remaining_size()` is also provided; this counts the size but ignores the `--` special separator if present.
  118 +Normally CLI11 throws an error if you don't match all items given on the command
  119 +line. However, you can enable `allow_extras()` to instead store the extra values
  120 +in `.remaining()`. You can get all remaining options including those in
  121 +contained subcommands recursively in the original order with `.remaining(true)`.
  122 +`.remaining_size()` is also provided; this counts the size but ignores the `--`
  123 +special separator if present.
100 124  
101 125 ### Fallthrough
102 126  
103   -Fallthrough allows an option that does not match in a subcommand to "fall through" to the parent command; if that parent
104   -allows that option, it matches there instead. This was added to allow CLI11 to represent models:
  127 +Fallthrough allows an option that does not match in a subcommand to "fall
  128 +through" to the parent command; if that parent allows that option, it matches
  129 +there instead. This was added to allow CLI11 to represent models:
105 130  
106 131 ```term
107 132 gitbook:code $ ./my_program my_model_1 --model_flag --shared_flag
108 133 ```
109 134  
110   -Here, `--shared_flag` was set on the main app, and on the command line it "falls through" `my_model_1` to match on the main app.
  135 +Here, `--shared_flag` was set on the main app, and on the command line it "falls
  136 +through" `my_model_1` to match on the main app.
111 137  
112 138 ### Prefix command
113 139  
114   -This is a special mode that allows "prefix" commands, where the parsing completely stops when it gets to an unknown option. Further unknown options are ignored, even if they could match. Git is the traditional example for prefix commands; if you run git with an unknown subcommand, like "`git thing`", it then calls another command called "`git-thing`" with the remaining options intact.
  140 +This is a special mode that allows "prefix" commands, where the parsing
  141 +completely stops when it gets to an unknown option. Further unknown options are
  142 +ignored, even if they could match. Git is the traditional example for prefix
  143 +commands; if you run git with an unknown subcommand, like "`git thing`", it then
  144 +calls another command called "`git-thing`" with the remaining options intact.
115 145  
116 146 ### Silent subcommands
117 147  
118   -Subcommands can be modified by using the `silent` option. This will prevent the subcommand from showing up in the get_subcommands list. This can be used to make subcommands into modifiers. For example, a help subcommand might look like
  148 +Subcommands can be modified by using the `silent` option. This will prevent the
  149 +subcommand from showing up in the get_subcommands list. This can be used to make
  150 +subcommands into modifiers. For example, a help subcommand might look like
119 151  
120 152 ```c++
121 153 auto sub1 = app.add_subcommand("help")->silent();
... ... @@ -131,11 +163,19 @@ This would allow calling help such as:
131 163  
132 164 ### Positional Validation
133 165  
134   -Some arguments supplied on the command line may be legitamately applied to more than 1 positional argument. In this context enabling `positional_validation` on the application or subcommand will check any validators before applying the command line argument to the positional option. It is not an error to fail validation in this context, positional arguments not matching any validators will go into the `extra_args` field which may generate an error depending on settings.
  166 +Some arguments supplied on the command line may be legitamately applied to more
  167 +than 1 positional argument. In this context enabling `positional_validation` on
  168 +the application or subcommand will check any validators before applying the
  169 +command line argument to the positional option. It is not an error to fail
  170 +validation in this context, positional arguments not matching any validators
  171 +will go into the `extra_args` field which may generate an error depending on
  172 +settings.
135 173  
136 174 ### Optional Argument Validation
137 175  
138   -Similar to positional validation, there are occasional contexts in which case it might be ambiguous whether an argument should be applied to an option or a positional option.
  176 +Similar to positional validation, there are occasional contexts in which case it
  177 +might be ambiguous whether an argument should be applied to an option or a
  178 +positional option.
139 179  
140 180 ```c++
141 181 std::vector<std::string> vec;
... ... @@ -145,4 +185,10 @@ Similar to positional validation, there are occasional contexts in which case it
145 185 app.validate_optional_arguments();
146 186 ```
147 187  
148   -In this case a sequence of integers is expected for the argument and remaining strings go to the positional string vector. Without the `validate_optional_arguments()` active it would be impossible get any later arguments into the positional if the `--args` option is used. The validator in this context is used to make sure the optional arguments match with what the argument is expecting and if not the `-args` option is closed, and remaining arguments fall into the positional.
  188 +In this case a sequence of integers is expected for the argument and remaining
  189 +strings go to the positional string vector. Without the
  190 +`validate_optional_arguments()` active it would be impossible get any later
  191 +arguments into the positional if the `--args` option is used. The validator in
  192 +this context is used to make sure the optional arguments match with what the
  193 +argument is expecting and if not the `-args` option is closed, and remaining
  194 +arguments fall into the positional.
... ...
book/chapters/toolkits.md
1 1 # Using CLI11 in a Toolkit
2 2  
3   -CLI11 was designed to be integrate into a toolkit, providing a native experience for users. This was used in GooFit to provide `GooFit::Application`, an class designed to make ROOT users feel at home.
  3 +CLI11 was designed to be integrate into a toolkit, providing a native experience
  4 +for users. This was used in GooFit to provide `GooFit::Application`, an class
  5 +designed to make ROOT users feel at home.
4 6  
5 7 ## Custom namespace
6 8  
7   -If you want to provide CLI11 in a custom namespace, you'll want to at least put `using CLI::App` in your namespace. You can also include Option, some errors, and validators. You can also put `using namespace CLI` inside your namespace to import everything.
  9 +If you want to provide CLI11 in a custom namespace, you'll want to at least put
  10 +`using CLI::App` in your namespace. You can also include Option, some errors,
  11 +and validators. You can also put `using namespace CLI` inside your namespace to
  12 +import everything.
8 13  
9   -You may also want to make your own copy of the `CLI11_PARSE` macro. Something like:
  14 +You may also want to make your own copy of the `CLI11_PARSE` macro. Something
  15 +like:
10 16  
11 17 ```cpp
12 18 #define MYPACKAGE_PARSE(app, argv, argc) \
... ... @@ -19,10 +25,16 @@ You may also want to make your own copy of the `CLI11_PARSE` macro. Something li
19 25  
20 26 ## Subclassing App
21 27  
22   -If you subclass `App`, you'll just need to do a few things. You'll need a constructor; calling the base `App` constructor is a good idea, but not necessary (it just sets a description and adds a help flag.
  28 +If you subclass `App`, you'll just need to do a few things. You'll need a
  29 +constructor; calling the base `App` constructor is a good idea, but not
  30 +necessary (it just sets a description and adds a help flag.
23 31  
24   -You can call anything you would like to configure in the constructor, like `option_defaults()->take_last()` or `fallthrough()`, and it will be set on all user instances. You can add flags and options, as well.
  32 +You can call anything you would like to configure in the constructor, like
  33 +`option_defaults()->take_last()` or `fallthrough()`, and it will be set on all
  34 +user instances. You can add flags and options, as well.
25 35  
26 36 ## Virtual functions provided
27 37  
28   -You are given a few virtual functions that you can change (only on the main App). `pre_callback` runs right before the callbacks run, letting you print out custom messages at the top of your app.
  38 +You are given a few virtual functions that you can change (only on the main
  39 +App). `pre_callback` runs right before the callbacks run, letting you print out
  40 +custom messages at the top of your app.
... ...
book/chapters/validators.md
... ... @@ -3,22 +3,26 @@
3 3 There are two forms of validators:
4 4  
5 5 - `transform` validators: mutating
6   -- `check` validators: non-mutating (recommended unless the parsed string must be mutated)
  6 +- `check` validators: non-mutating (recommended unless the parsed string must be
  7 + mutated)
7 8  
8   -A transform validator comes in one form, a function with the signature `std::string(std::string)`.
9   -The function will take a string and return the modified version of the string. If there is an error,
10   -the function should throw a `CLI::ValidationError` with the appropriate reason as a message.
  9 +A transform validator comes in one form, a function with the signature
  10 +`std::string(std::string)`. The function will take a string and return the
  11 +modified version of the string. If there is an error, the function should throw
  12 +a `CLI::ValidationError` with the appropriate reason as a message.
11 13  
12   -However, `check` validators come in two forms; either a simple function with the const version of the
13   -above signature, `std::string(const std::string &)`, or a subclass of `struct CLI::Validator`. This
14   -structure has two members that a user should set; one (`func_`) is the function to add to the Option
15   -(exactly matching the above function signature, since it will become that function), and the other is
16   -`name_`, and is the type name to set on the Option (unless empty, in which case the typename will be
17   -left unchanged).
  14 +However, `check` validators come in two forms; either a simple function with the
  15 +const version of the above signature, `std::string(const std::string &)`, or a
  16 +subclass of `struct CLI::Validator`. This structure has two members that a user
  17 +should set; one (`func_`) is the function to add to the Option (exactly matching
  18 +the above function signature, since it will become that function), and the other
  19 +is `name_`, and is the type name to set on the Option (unless empty, in which
  20 +case the typename will be left unchanged).
18 21  
19   -Validators can be combined with `&` and `|`, and they have an `operator()` so that you can call them
20   -as if they were a function. In CLI11, const static versions of the validators are provided so that
21   -the user does not have to call a constructor also.
  22 +Validators can be combined with `&` and `|`, and they have an `operator()` so
  23 +that you can call them as if they were a function. In CLI11, const static
  24 +versions of the validators are provided so that the user does not have to call a
  25 +constructor also.
22 26  
23 27 An example of a custom validator:
24 28  
... ... @@ -37,7 +41,8 @@ struct LowerCaseValidator : public Validator {
37 41 const static LowerCaseValidator Lowercase;
38 42 ```
39 43  
40   -If you were not interested in the extra features of Validator, you could simply pass the lambda function above to the `->check()` method of `Option`.
  44 +If you were not interested in the extra features of Validator, you could simply
  45 +pass the lambda function above to the `->check()` method of `Option`.
41 46  
42 47 The built-in validators for CLI11 are:
43 48  
... ...
docs/mainpage.md
1 1 # Introduction {#mainpage}
2 2  
3   -This is the Doxygen API documentation for CLI11 parser. There is a friendly introduction to CLI11 on the [GitHub page](https://github.com/CLIUtils/CLI11), and [a tutorial series](https://cliutils.github.io/CLI11/book/).
  3 +This is the Doxygen API documentation for CLI11 parser. There is a friendly
  4 +introduction to CLI11 on the [GitHub page](https://github.com/CLIUtils/CLI11),
  5 +and [a tutorial series](https://cliutils.github.io/CLI11/book/).
4 6  
5 7 The main classes are:
6 8  
... ...