mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 20:23:55 +00:00
style: run prettier
This commit is contained in:
parent
3c44bb9fdc
commit
0038ad4658
@ -1,10 +1,9 @@
|
|||||||
steps:
|
steps:
|
||||||
|
|
||||||
- task: CMake@1
|
- task: CMake@1
|
||||||
inputs:
|
inputs:
|
||||||
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)
|
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)
|
||||||
displayName: 'Configure'
|
displayName: "Configure"
|
||||||
|
|
||||||
- script: cmake --build .
|
- script: cmake --build .
|
||||||
displayName: 'Build'
|
displayName: "Build"
|
||||||
workingDirectory: build
|
workingDirectory: build
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
steps:
|
steps:
|
||||||
|
|
||||||
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
|
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
|
||||||
- bash: |
|
- bash: |
|
||||||
wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz"
|
wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz"
|
||||||
@ -8,8 +7,8 @@ steps:
|
|||||||
|
|
||||||
- task: ExtractFiles@1
|
- task: ExtractFiles@1
|
||||||
inputs:
|
inputs:
|
||||||
archiveFilePatterns: 'cmake*.tar.gz'
|
archiveFilePatterns: "cmake*.tar.gz"
|
||||||
destinationFolder: 'cmake_program'
|
destinationFolder: "cmake_program"
|
||||||
displayName: Extract CMake
|
displayName: Extract CMake
|
||||||
|
|
||||||
- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
|
- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
steps:
|
steps:
|
||||||
|
|
||||||
- script: ctest --output-on-failure -C $(cli11.build_type) -T test
|
- script: ctest --output-on-failure -C $(cli11.build_type) -T test
|
||||||
displayName: 'Test'
|
displayName: "Test"
|
||||||
workingDirectory: build
|
workingDirectory: build
|
||||||
|
|
||||||
- task: PublishTestResults@2
|
- task: PublishTestResults@2
|
||||||
inputs:
|
inputs:
|
||||||
testResultsFormat: 'cTest'
|
testResultsFormat: "cTest"
|
||||||
testResultsFiles: '**/Test.xml'
|
testResultsFiles: "**/Test.xml"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
FormatStyle: file
|
FormatStyle: file
|
||||||
|
|
||||||
Checks: '
|
Checks: >
|
||||||
-*,
|
-*,
|
||||||
google-*,
|
google-*,
|
||||||
-google-runtime-references,
|
-google-runtime-references,
|
||||||
@ -13,12 +13,11 @@ misc-throw-by-value-catch-by-reference,
|
|||||||
modernize*,
|
modernize*,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
readability-container-size-empty,
|
readability-container-size-empty,
|
||||||
'
|
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: "*"
|
||||||
|
|
||||||
HeaderFilterRegex: '.*hpp'
|
HeaderFilterRegex: ".*hpp"
|
||||||
|
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: google-readability-braces-around-statements.ShortStatementLines
|
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||||
value: '3'
|
value: "3"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
ignore:
|
ignore:
|
||||||
- "tests"
|
- "tests"
|
||||||
- "examples"
|
- "examples"
|
||||||
|
32
.github/CONTRIBUTING.md
vendored
32
.github/CONTRIBUTING.md
vendored
@ -8,20 +8,20 @@ Make sure you are comfortable with the license; all contributions are licensed u
|
|||||||
|
|
||||||
Make sure any new functions you add are are:
|
Make sure any new functions you add are are:
|
||||||
|
|
||||||
* Documented by `///` documentation for Doxygen
|
- Documented by `///` documentation for Doxygen
|
||||||
* Mentioned in the instructions in the README, though brief mentions are okay
|
- Mentioned in the instructions in the README, though brief mentions are okay
|
||||||
* Explained in your PR (or previously explained in an Issue mentioned in the PR)
|
- Explained in your PR (or previously explained in an Issue mentioned in the PR)
|
||||||
* Completely covered by tests
|
- Completely covered by tests
|
||||||
|
|
||||||
In general, make sure the addition is well thought out and does not increase the complexity of CLI11 needlessly.
|
In general, make sure the addition is well thought out and does not increase the complexity of CLI11 needlessly.
|
||||||
|
|
||||||
## Things you should know
|
## Things you should know
|
||||||
|
|
||||||
* Once you make the PR, tests will run to make sure your code works on all supported platforms
|
- Once you make the PR, tests will run to make sure your code works on all supported platforms
|
||||||
* The test coverage is also measured, and that should remain 100%
|
- The test coverage is also measured, and that should remain 100%
|
||||||
* 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.
|
- 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.
|
||||||
* 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).
|
- 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).
|
||||||
* 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).
|
- 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).
|
||||||
|
|
||||||
## Pre-commit
|
## Pre-commit
|
||||||
|
|
||||||
@ -74,10 +74,10 @@ Remember to replace the emoji in the readme, being careful not to replace the on
|
|||||||
|
|
||||||
Steps:
|
Steps:
|
||||||
|
|
||||||
* Update changelog if needed
|
- Update changelog if needed
|
||||||
* Update the version in `.appveyor.yml` and `include/CLI/Version.hpp`.
|
- Update the version in `.appveyor.yml` and `include/CLI/Version.hpp`.
|
||||||
* Find and replace in README (new minor/major release only):
|
- Find and replace in README (new minor/major release only):
|
||||||
* Replace " 🆕" and "🆕 " with "" (ignores the description line)
|
- Replace " 🆕" and "🆕 " with "" (ignores the description line)
|
||||||
* Check for `\/\/$` (vi syntax) to catch leftover `// 🆕`
|
- Check for `\/\/$` (vi syntax) to catch leftover `// 🆕`
|
||||||
* Replace "🚧" with "🆕" (manually ignore the description line)
|
- Replace "🚧" with "🆕" (manually ignore the description line)
|
||||||
* Make a release in the GitHub UI, use a name such as "Version X.Y(.Z): Title"
|
- Make a release in the GitHub UI, use a name such as "Version X.Y(.Z): Title"
|
||||||
|
8
.github/actions/quick_cmake/action.yml
vendored
8
.github/actions/quick_cmake/action.yml
vendored
@ -1,12 +1,12 @@
|
|||||||
name: Quick CMake config
|
name: Quick CMake config
|
||||||
description: 'Runs CMake 3.4+ (if already setup)'
|
description: "Runs CMake 3.4+ (if already setup)"
|
||||||
inputs:
|
inputs:
|
||||||
args:
|
args:
|
||||||
description: 'Other arguments'
|
description: "Other arguments"
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ""
|
||||||
cmake-version:
|
cmake-version:
|
||||||
description: 'The CMake version to run'
|
description: "The CMake version to run"
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
|
4
.github/labeler_merged.yml
vendored
4
.github/labeler_merged.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
needs changelog:
|
needs changelog:
|
||||||
- all: ['!CHANGELOG.md']
|
- all: ["!CHANGELOG.md"]
|
||||||
needs README:
|
needs README:
|
||||||
- all: ['!README.md']
|
- all: ["!README.md"]
|
||||||
|
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -13,7 +13,6 @@ jobs:
|
|||||||
name: Single header
|
name: Single header
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -24,7 +24,6 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build -j2
|
run: cmake --build build -j2
|
||||||
|
|
||||||
|
|
||||||
boost-build:
|
boost-build:
|
||||||
name: Boost build
|
name: Boost build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -62,7 +61,6 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: meson compile -C build-meson
|
run: meson compile -C build-meson
|
||||||
|
|
||||||
|
|
||||||
cmake-config:
|
cmake-config:
|
||||||
name: CMake config check
|
name: CMake config check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
672
CHANGELOG.md
672
CHANGELOG.md
@ -6,25 +6,25 @@ New features include support for output of an empty vector, a summing option pol
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Add `MultiOptionPolicy::Sum` and refactor the `add_flag` to fix a bug when using `std::optional<bool>` as type. [#709][]
|
- Add `MultiOptionPolicy::Sum` and refactor the `add_flag` to fix a bug when using `std::optional<bool>` as type. [#709][]
|
||||||
* Add support for an empty vector result in TOML and as a default string. [#660][]
|
- Add support for an empty vector result in TOML and as a default string. [#660][]
|
||||||
* Add `.validate_optional_arguments()` to support discriminating positional arguments from vector option arguments. [#668][]
|
- Add `.validate_optional_arguments()` to support discriminating positional arguments from vector option arguments. [#668][]
|
||||||
* Add `CLI::FileOnDefaultPath` to check for files on a specified default path. [#698][]
|
- Add `CLI::FileOnDefaultPath` to check for files on a specified default path. [#698][]
|
||||||
* Change default value display in help messages from `=XXXX` to `[XXXXX]` to make it clearer. [#666][]
|
- Change default value display in help messages from `=XXXX` to `[XXXXX]` to make it clearer. [#666][]
|
||||||
* Modify the Range Validator to support additional types and clean up the error output. [#690][]
|
- Modify the Range Validator to support additional types and clean up the error output. [#690][]
|
||||||
* Bugfix: The trigger on parse modifier did not work on positional argument.s [#713][]
|
- Bugfix: The trigger on parse modifier did not work on positional argument.s [#713][]
|
||||||
* Bugfix: The single header file generation was missing custom namespace generation. [#707][]
|
- Bugfix: The single header file generation was missing custom namespace generation. [#707][]
|
||||||
* Bugfix: Clean up File Error handling in the argument processing. [#678][]
|
- Bugfix: Clean up File Error handling in the argument processing. [#678][]
|
||||||
* Bugfix: Fix a stack overflow error if nameless commands had fallthrough. [#665][]
|
- Bugfix: Fix a stack overflow error if nameless commands had fallthrough. [#665][]
|
||||||
* Bugfix: A subcommand callback could be executed multiple times if it was a member of an option group. [#666][]
|
- Bugfix: A subcommand callback could be executed multiple times if it was a member of an option group. [#666][]
|
||||||
* Bugfix: Fix an issue with vectors of multi argument types where partial argument sets did not result in an error. [#661][]
|
- Bugfix: Fix an issue with vectors of multi argument types where partial argument sets did not result in an error. [#661][]
|
||||||
* Bugfix: Fix an issue with type the template matching on C++20 and add some CI builds for C++20. [#663][]
|
- Bugfix: Fix an issue with type the template matching on C++20 and add some CI builds for C++20. [#663][]
|
||||||
* Bugfix: Fix typo in C++20 detection on MSVC. [#706][]
|
- Bugfix: Fix typo in C++20 detection on MSVC. [#706][]
|
||||||
* Bugfix: An issue where the detection of RTTI being disabled on certain MSVC platforms did not disable the use of dynamic cast calls. [#666][]
|
- Bugfix: An issue where the detection of RTTI being disabled on certain MSVC platforms did not disable the use of dynamic cast calls. [#666][]
|
||||||
* Bugfix: Resolve strict-overflow warning on some GCC compilers. [#666][]
|
- Bugfix: Resolve strict-overflow warning on some GCC compilers. [#666][]
|
||||||
* Backend: Add additional tests concerning the use of aliases for option groups in config files. [#666][]
|
- Backend: Add additional tests concerning the use of aliases for option groups in config files. [#666][]
|
||||||
* Build: Add support for testing in meson and cleanup symbolic link generation. [#701][], [#697][]
|
- Build: Add support for testing in meson and cleanup symbolic link generation. [#701][], [#697][]
|
||||||
* Build: Support building in WebAssembly. [#679][]
|
- Build: Support building in WebAssembly. [#679][]
|
||||||
|
|
||||||
[#660]: https://github.com/CLIUtils/CLI11/pull/660
|
[#660]: https://github.com/CLIUtils/CLI11/pull/660
|
||||||
[#661]: https://github.com/CLIUtils/CLI11/pull/661
|
[#661]: https://github.com/CLIUtils/CLI11/pull/661
|
||||||
@ -52,12 +52,12 @@ improved, allowing your configuration to sit in a larger file. And option
|
|||||||
callbacks have a few new settings, allowing them to be run even if the option
|
callbacks have a few new settings, allowing them to be run even if the option
|
||||||
is not passed, or every time the option is parsed.
|
is not passed, or every time the option is parsed.
|
||||||
|
|
||||||
* Option/subcommand name restrictions have been relaxed. Most characters are now allowed. [#627][]
|
- Option/subcommand name restrictions have been relaxed. Most characters are now allowed. [#627][]
|
||||||
* The config parser can accept streams, specify a specific section, and inline comment characters are supported [#630][]
|
- The config parser can accept streams, specify a specific section, and inline comment characters are supported [#630][]
|
||||||
* `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][]
|
- `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][]
|
||||||
* Bugfix(cmake): Only add `CONFIGURE_DEPENDS` if CLI11 is the main project [#633][]
|
- Bugfix(cmake): Only add `CONFIGURE_DEPENDS` if CLI11 is the main project [#633][]
|
||||||
* Bugfix(cmake): Ensure the cmake/pkg-config files install to a arch independent path [#635][]
|
- Bugfix(cmake): Ensure the cmake/pkg-config files install to a arch independent path [#635][]
|
||||||
* Bugfix: The single header file generation was missing the include guard. [#620][]
|
- Bugfix: The single header file generation was missing the include guard. [#620][]
|
||||||
|
|
||||||
[#620]: https://github.com/CLIUtils/CLI11/pull/620
|
[#620]: https://github.com/CLIUtils/CLI11/pull/620
|
||||||
[#627]: https://github.com/CLIUtils/CLI11/pull/627
|
[#627]: https://github.com/CLIUtils/CLI11/pull/627
|
||||||
@ -68,9 +68,9 @@ is not passed, or every time the option is parsed.
|
|||||||
|
|
||||||
### Version 2.1.1: Quick Windows fix
|
### Version 2.1.1: Quick Windows fix
|
||||||
|
|
||||||
* A collision with `min`/`max` macros on Windows has been fixed. [#642][]
|
- A collision with `min`/`max` macros on Windows has been fixed. [#642][]
|
||||||
* Tests pass with Boost again [#646][]
|
- Tests pass with Boost again [#646][]
|
||||||
* Running the pre-commit hooks in development no longer requires docker for clang-format [#647][]
|
- Running the pre-commit hooks in development no longer requires docker for clang-format [#647][]
|
||||||
|
|
||||||
[#642]: https://github.com/CLIUtils/CLI11/pull/642
|
[#642]: https://github.com/CLIUtils/CLI11/pull/642
|
||||||
[#646]: https://github.com/CLIUtils/CLI11/pull/646
|
[#646]: https://github.com/CLIUtils/CLI11/pull/646
|
||||||
@ -78,11 +78,11 @@ is not passed, or every time the option is parsed.
|
|||||||
|
|
||||||
## Version 2.1.2: Better subproject builds
|
## Version 2.1.2: Better subproject builds
|
||||||
|
|
||||||
* Use `main` for the main branch of the repository [#657][]
|
- Use `main` for the main branch of the repository [#657][]
|
||||||
* Bugfix(cmake): Enforce at least C++11 when using CMake target [#656][]
|
- Bugfix(cmake): Enforce at least C++11 when using CMake target [#656][]
|
||||||
* Build: Don't run doxygen and CTest includes if a submodule [#656][]
|
- Build: Don't run doxygen and CTest includes if a submodule [#656][]
|
||||||
* Build: Avoid a warning on CMake 3.22 [#656][]
|
- Build: Avoid a warning on CMake 3.22 [#656][]
|
||||||
* Build: Support compiling the tests with an external copy of Catch2 [#653][]
|
- Build: Support compiling the tests with an external copy of Catch2 [#653][]
|
||||||
|
|
||||||
[#653]: https://github.com/CLIUtils/CLI11/pull/653
|
[#653]: https://github.com/CLIUtils/CLI11/pull/653
|
||||||
[#656]: https://github.com/CLIUtils/CLI11/pull/656
|
[#656]: https://github.com/CLIUtils/CLI11/pull/656
|
||||||
@ -98,34 +98,34 @@ significantly improved with new features and bugfixes for corner cases. This
|
|||||||
release contains a lot of backend cleanup, including a complete overhaul of the
|
release contains a lot of backend cleanup, including a complete overhaul of the
|
||||||
testing system and single file generation system.
|
testing system and single file generation system.
|
||||||
|
|
||||||
* Built-in config format is TOML compliant now [#435][]
|
- Built-in config format is TOML compliant now [#435][]
|
||||||
* Support multiline TOML [#528][]
|
- Support multiline TOML [#528][]
|
||||||
* Support for configurable quotes [#599][]
|
- Support for configurable quotes [#599][]
|
||||||
* Support short/positional options in config mode [#443][]
|
- Support short/positional options in config mode [#443][]
|
||||||
* More powerful containers, support for `%%` separator [#423][]
|
- More powerful containers, support for `%%` separator [#423][]
|
||||||
* Support atomic types [#520][] and complex types natively [#423][]
|
- Support atomic types [#520][] and complex types natively [#423][]
|
||||||
* Add a type validator `CLI::TypeValidator<TYPE>` [#526][]
|
- Add a type validator `CLI::TypeValidator<TYPE>` [#526][]
|
||||||
* Add a version flag easily [#452][], with help message [#601][]
|
- Add a version flag easily [#452][], with help message [#601][]
|
||||||
* Support `->silent()` on subcommands. [#529][]
|
- Support `->silent()` on subcommands. [#529][]
|
||||||
* Add alias section to help for subcommands [#545][]
|
- Add alias section to help for subcommands [#545][]
|
||||||
* Allow quotes to specify a program name [#605][]
|
- Allow quotes to specify a program name [#605][]
|
||||||
* Backend: redesigned MakeSingleFiles to have a higher level of manual control, to support future features. [#546][]
|
- Backend: redesigned MakeSingleFiles to have a higher level of manual control, to support future features. [#546][]
|
||||||
* Backend: moved testing from GTest to Catch2 [#574][]
|
- Backend: moved testing from GTest to Catch2 [#574][]
|
||||||
* Bugfix: avoid duplicated and missed calls to the final callback [#584][]
|
- Bugfix: avoid duplicated and missed calls to the final callback [#584][]
|
||||||
* Bugfix: support embedded newlines in more places [#592][]
|
- Bugfix: support embedded newlines in more places [#592][]
|
||||||
* Bugfix: avoid listing helpall as a required flag [#530][]
|
- Bugfix: avoid listing helpall as a required flag [#530][]
|
||||||
* Bugfix: avoid a clash with WINDOWS define [#563][]
|
- Bugfix: avoid a clash with WINDOWS define [#563][]
|
||||||
* Bugfix: the help flag didn't get processed when a config file was required [#606][]
|
- Bugfix: the help flag didn't get processed when a config file was required [#606][]
|
||||||
* Bugfix: fix description of non-configurable subcommands in config [#604][]
|
- Bugfix: fix description of non-configurable subcommands in config [#604][]
|
||||||
* Build: support pkg-config [#523][]
|
- Build: support pkg-config [#523][]
|
||||||
|
|
||||||
> ### Converting from CLI11 1.9
|
> ### Converting from CLI11 1.9
|
||||||
>
|
>
|
||||||
> * Removed deprecated set commands, use validators instead. [#565][]
|
> - Removed deprecated set commands, use validators instead. [#565][]
|
||||||
> * The final "defaulted" bool has been removed, use `->capture_default_str()`
|
> - The final "defaulted" bool has been removed, use `->capture_default_str()`
|
||||||
> instead. Use `app.option_defaults()->always_capture_default()` to set this for
|
> instead. Use `app.option_defaults()->always_capture_default()` to set this for
|
||||||
> all future options. [#597][]
|
> all future options. [#597][]
|
||||||
> * Use `add_option` on a complex number instead of `add_complex`, which has been removed.
|
> - Use `add_option` on a complex number instead of `add_complex`, which has been removed.
|
||||||
|
|
||||||
[#423]: https://github.com/CLIUtils/CLI11/pull/423
|
[#423]: https://github.com/CLIUtils/CLI11/pull/423
|
||||||
[#435]: https://github.com/CLIUtils/CLI11/pull/435
|
[#435]: https://github.com/CLIUtils/CLI11/pull/435
|
||||||
@ -160,41 +160,41 @@ Adding options is significantly more powerful with support for things like
|
|||||||
configuration options were added to facilitate a wider variety of apps. GCC
|
configuration options were added to facilitate a wider variety of apps. GCC
|
||||||
4.7 is no longer supported.
|
4.7 is no longer supported.
|
||||||
|
|
||||||
* Config files refactored, supports TOML (may become default output in 2.0) [#362][]
|
- Config files refactored, supports TOML (may become default output in 2.0) [#362][]
|
||||||
* Added two template parameter form of `add_option`, allowing `std::optional` to be supported without a special import [#285][]
|
- Added two template parameter form of `add_option`, allowing `std::optional` to be supported without a special import [#285][]
|
||||||
* `string_view` now supported in reasonable places [#300][], [#285][]
|
- `string_view` now supported in reasonable places [#300][], [#285][]
|
||||||
* `immediate_callback`, `final_callback`, and `parse_complete_callback` added to support controlling the App callback order [#292][], [#313][]
|
- `immediate_callback`, `final_callback`, and `parse_complete_callback` added to support controlling the App callback order [#292][], [#313][]
|
||||||
* Multiple positional arguments maintain order if `positionals_at_end` is set. [#306][]
|
- Multiple positional arguments maintain order if `positionals_at_end` is set. [#306][]
|
||||||
* Pair/tuple/array now supported, and validators indexed to specific components in the objects [#307][], [#310][]
|
- Pair/tuple/array now supported, and validators indexed to specific components in the objects [#307][], [#310][]
|
||||||
* Footer callbacks supported [#309][]
|
- Footer callbacks supported [#309][]
|
||||||
* Subcommands now support needs (including nameless subcommands) [#317][]
|
- Subcommands now support needs (including nameless subcommands) [#317][]
|
||||||
* More flexible type size, more useful `add_complex` [#325][], [#370][]
|
- More flexible type size, more useful `add_complex` [#325][], [#370][]
|
||||||
* Added new validators `CLI::NonNegativeNumber` and `CLI::PositiveNumber` [#342][]
|
- Added new validators `CLI::NonNegativeNumber` and `CLI::PositiveNumber` [#342][]
|
||||||
* Transform now supports arrays [#349][]
|
- Transform now supports arrays [#349][]
|
||||||
* Option groups can be hidden [#356][]
|
- Option groups can be hidden [#356][]
|
||||||
* Add `CLI::deprecate_option` and `CLI::retire_option` functions [#358][]
|
- Add `CLI::deprecate_option` and `CLI::retire_option` functions [#358][]
|
||||||
* More flexible and safer Option `default_val` [#387][]
|
- More flexible and safer Option `default_val` [#387][]
|
||||||
* Backend: Cleaner type traits [#286][]
|
- Backend: Cleaner type traits [#286][]
|
||||||
* Backend: File checking updates [#341][]
|
- Backend: File checking updates [#341][]
|
||||||
* Backend: Using pre-commit to format, checked in GitHub Actions [#336][]
|
- Backend: Using pre-commit to format, checked in GitHub Actions [#336][]
|
||||||
* Backend: Clang-tidy checked again, CMake option now `CL11_CLANG_TIDY` [#390][]
|
- Backend: Clang-tidy checked again, CMake option now `CL11_CLANG_TIDY` [#390][]
|
||||||
* 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][]
|
- 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][]
|
||||||
* Docs: CLI11 Tutorial now hosted in the same repository [#304][], [#318][], [#374][]
|
- Docs: CLI11 Tutorial now hosted in the same repository [#304][], [#318][], [#374][]
|
||||||
* Bugfix: Fixed undefined behavior in `checked_multiply` [#290][]
|
- Bugfix: Fixed undefined behavior in `checked_multiply` [#290][]
|
||||||
* Bugfix: `->check()` was adding the name to the wrong validator [#320][]
|
- Bugfix: `->check()` was adding the name to the wrong validator [#320][]
|
||||||
* Bugfix: Resetting config option works properly [#301][]
|
- Bugfix: Resetting config option works properly [#301][]
|
||||||
* Bugfix: Hidden flags were showing up in error printout [#333][]
|
- Bugfix: Hidden flags were showing up in error printout [#333][]
|
||||||
* Bugfix: Enum conversion no longer broken if stream operator added [#348][]
|
- Bugfix: Enum conversion no longer broken if stream operator added [#348][]
|
||||||
* Build: The meson build system supported [#299][]
|
- Build: The meson build system supported [#299][]
|
||||||
* Build: GCC 4.7 is no longer supported, due mostly to GoogleTest. GCC 4.8+ is now required. [#160][]
|
- Build: GCC 4.7 is no longer supported, due mostly to GoogleTest. GCC 4.8+ is now required. [#160][]
|
||||||
* Build: Restructured significant portions of CMake build system [#394][]
|
- Build: Restructured significant portions of CMake build system [#394][]
|
||||||
|
|
||||||
> ### Converting from CLI11 1.8
|
> ### Converting from CLI11 1.8
|
||||||
>
|
>
|
||||||
> * Some deprecated methods dropped
|
> - Some deprecated methods dropped
|
||||||
> * `add_set*` should be replaced with `->check`/`->transform` and `CLI::IsMember` since 1.8
|
> - `add_set*` should be replaced with `->check`/`->transform` and `CLI::IsMember` since 1.8
|
||||||
> * `get_defaultval` was replaced by `get_default_str` in 1.8
|
> - `get_defaultval` was replaced by `get_default_str` in 1.8
|
||||||
> * The true/false 4th argument to `add_option` is expected to be removed in 2.0, use `->capture_default_str()` since 1.8
|
> - The true/false 4th argument to `add_option` is expected to be removed in 2.0, use `->capture_default_str()` since 1.8
|
||||||
|
|
||||||
[#160]: https://github.com/CLIUtils/CLI11/pull/160
|
[#160]: https://github.com/CLIUtils/CLI11/pull/160
|
||||||
[#285]: https://github.com/CLIUtils/CLI11/pull/285
|
[#285]: https://github.com/CLIUtils/CLI11/pull/285
|
||||||
@ -240,13 +240,13 @@ configuration options were added to facilitate a wider variety of apps. GCC
|
|||||||
|
|
||||||
This is a patch version that backports fixes from the development of 2.0.
|
This is a patch version that backports fixes from the development of 2.0.
|
||||||
|
|
||||||
* Support relative inclusion [#475][]
|
- Support relative inclusion [#475][]
|
||||||
* Fix cases where spaces in paths could break CMake support [#471][]
|
- Fix cases where spaces in paths could break CMake support [#471][]
|
||||||
* Fix an issue with string conversion [#421][]
|
- Fix an issue with string conversion [#421][]
|
||||||
* Cross-compiling improvement for Conan.io [#430][]
|
- Cross-compiling improvement for Conan.io [#430][]
|
||||||
* Fix option group default propagation [#450][]
|
- Fix option group default propagation [#450][]
|
||||||
* Fix for C++20 [#459][]
|
- Fix for C++20 [#459][]
|
||||||
* Support compiling with RTTI off [#461][]
|
- Support compiling with RTTI off [#461][]
|
||||||
|
|
||||||
[#421]: https://github.com/CLIUtils/CLI11/pull/421
|
[#421]: https://github.com/CLIUtils/CLI11/pull/421
|
||||||
[#430]: https://github.com/CLIUtils/CLI11/pull/430
|
[#430]: https://github.com/CLIUtils/CLI11/pull/430
|
||||||
@ -260,39 +260,39 @@ This is a patch version that backports fixes from the development of 2.0.
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Replaced default help capture: `.add_option("name", value, "", True)` becomes `.add_option("name", value)->capture_default_str()` [#242][]
|
- Replaced default help capture: `.add_option("name", value, "", True)` becomes `.add_option("name", value)->capture_default_str()` [#242][]
|
||||||
* Added `.always_capture_default()` [#242][]
|
- Added `.always_capture_default()` [#242][]
|
||||||
* New `CLI::IsMember` validator replaces set validation [#222][]
|
- New `CLI::IsMember` validator replaces set validation [#222][]
|
||||||
* `IsMember` also supports container of pairs, transform allows modification of result [#228][]
|
- `IsMember` also supports container of pairs, transform allows modification of result [#228][]
|
||||||
* Added new Transformers, `CLI::AsNumberWithUnit` and `CLI::AsSizeValue` [#253][]
|
- Added new Transformers, `CLI::AsNumberWithUnit` and `CLI::AsSizeValue` [#253][]
|
||||||
* Much more powerful flags with different values [#211][], general types [#235][]
|
- Much more powerful flags with different values [#211][], general types [#235][]
|
||||||
* `add_option` now supports bool due to unified bool handling [#211][]
|
- `add_option` now supports bool due to unified bool handling [#211][]
|
||||||
* Support for composable unnamed subcommands [#216][]
|
- Support for composable unnamed subcommands [#216][]
|
||||||
* Reparsing is better supported with `.remaining_for_passthrough()` [#265][]
|
- Reparsing is better supported with `.remaining_for_passthrough()` [#265][]
|
||||||
* Custom vector separator using `->delimiter(char)` [#209][], [#221][], [#240][]
|
- Custom vector separator using `->delimiter(char)` [#209][], [#221][], [#240][]
|
||||||
* Validators added for IP4 addresses and positive numbers [#210][] and numbers [#262][]
|
- Validators added for IP4 addresses and positive numbers [#210][] and numbers [#262][]
|
||||||
* Minimum required Boost for optional Optionals has been corrected to 1.61 [#226][]
|
- Minimum required Boost for optional Optionals has been corrected to 1.61 [#226][]
|
||||||
* Positionals can stop options from being parsed with `app.positionals_at_end()` [#223][]
|
- Positionals can stop options from being parsed with `app.positionals_at_end()` [#223][]
|
||||||
* Added `validate_positionals` [#262][]
|
- Added `validate_positionals` [#262][]
|
||||||
* Positional parsing is much more powerful [#251][], duplicates supported [#247][]
|
- Positional parsing is much more powerful [#251][], duplicates supported [#247][]
|
||||||
* Validators can be negated with `!` [#230][], and now handle tname functions [#228][]
|
- Validators can be negated with `!` [#230][], and now handle tname functions [#228][]
|
||||||
* Better enum support and streaming helper [#233][] and [#228][]
|
- Better enum support and streaming helper [#233][] and [#228][]
|
||||||
* Cleanup for shadow warnings [#232][]
|
- Cleanup for shadow warnings [#232][]
|
||||||
* Better alignment on multiline descriptions [#269][]
|
- Better alignment on multiline descriptions [#269][]
|
||||||
* Better support for aarch64 [#266][]
|
- Better support for aarch64 [#266][]
|
||||||
* Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise, `CLI11_TESTING` must be used [#277][]
|
- Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise, `CLI11_TESTING` must be used [#277][]
|
||||||
* Drop auto-detection of experimental optional and boost::optional; must be enabled explicitly (too fragile) [#277][] [#279][]
|
- Drop auto-detection of experimental optional and boost::optional; must be enabled explicitly (too fragile) [#277][] [#279][]
|
||||||
|
|
||||||
> ### Converting from CLI11 1.7
|
> ### Converting from CLI11 1.7
|
||||||
>
|
>
|
||||||
> * `.add_option(..., true)` should be replaced by `.add_option(...)->capture_default_str()` or `app.option_defaults()->always_capture_default()` can be used
|
> - `.add_option(..., true)` should be replaced by `.add_option(...)->capture_default_str()` or `app.option_defaults()->always_capture_default()` can be used
|
||||||
> * `app.add_set("--name", value, {"choice1", "choice2"})` should become `app.add_option("--name", value)->check(CLI::IsMember({"choice1", "choice2"}))`
|
> - `app.add_set("--name", value, {"choice1", "choice2"})` should become `app.add_option("--name", value)->check(CLI::IsMember({"choice1", "choice2"}))`
|
||||||
> * The `_ignore_case` version of this can be replaced by adding `CLI::ignore_case` to the argument list in `IsMember`
|
> - The `_ignore_case` version of this can be replaced by adding `CLI::ignore_case` to the argument list in `IsMember`
|
||||||
> * The `_ignore_underscore` version of this can be replaced by adding `CLI::ignore_underscore` to the argument list in `IsMember`
|
> - The `_ignore_underscore` version of this can be replaced by adding `CLI::ignore_underscore` to the argument list in `IsMember`
|
||||||
> * The `_ignore_case_underscore` version of this can be replaced by adding both functions listed above to the argument list in `IsMember`
|
> - The `_ignore_case_underscore` version of this can be replaced by adding both functions listed above to the argument list in `IsMember`
|
||||||
> * If you want an exact match to the original choice after one of the modifier functions matches, use `->transform` instead of `->check`
|
> - If you want an exact match to the original choice after one of the modifier functions matches, use `->transform` instead of `->check`
|
||||||
> * The `_mutable` versions of this can be replaced by passing a pointer or shared pointer into `IsMember`
|
> - The `_mutable` versions of this can be replaced by passing a pointer or shared pointer into `IsMember`
|
||||||
> * An error with sets now produces a `ValidationError` instead of a `ConversionError`
|
> - An error with sets now produces a `ValidationError` instead of a `ConversionError`
|
||||||
|
|
||||||
[#209]: https://github.com/CLIUtils/CLI11/pull/209
|
[#209]: https://github.com/CLIUtils/CLI11/pull/209
|
||||||
[#210]: https://github.com/CLIUtils/CLI11/pull/210
|
[#210]: https://github.com/CLIUtils/CLI11/pull/210
|
||||||
@ -324,26 +324,26 @@ Set handling has been completely replaced by a new backend that works as a Valid
|
|||||||
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.
|
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.
|
||||||
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`.
|
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`.
|
||||||
|
|
||||||
* Support Windows style options with `->allow_windows_style_options`. [#187][] On by default on Windows. [#190][]
|
- Support Windows style options with `->allow_windows_style_options`. [#187][] On by default on Windows. [#190][]
|
||||||
* Added `parse(string)` to split up and parse a command-line style string directly. [#186][]
|
- Added `parse(string)` to split up and parse a command-line style string directly. [#186][]
|
||||||
* Added `ignore_underscore` and related functions, to ignore underscores when matching names. [#185][]
|
- Added `ignore_underscore` and related functions, to ignore underscores when matching names. [#185][]
|
||||||
* The default INI Config will now add quotes to strings with spaces [#195][]
|
- The default INI Config will now add quotes to strings with spaces [#195][]
|
||||||
* The default message now will mention the help-all flag also if present [#197][]
|
- The default message now will mention the help-all flag also if present [#197][]
|
||||||
* Added `->description` to set Option descriptions [#199][]
|
- Added `->description` to set Option descriptions [#199][]
|
||||||
* Mutating sets (introduced in Version 1.6) now have a clear add method, `add_mutable_set*`, since the set reference should not expire [#200][]
|
- Mutating sets (introduced in Version 1.6) now have a clear add method, `add_mutable_set*`, since the set reference should not expire [#200][]
|
||||||
* 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][]
|
- 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][]
|
||||||
* Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#178][]
|
- Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#178][]
|
||||||
* Calling parse multiple times is now officially supported without `clear` (automatic). [#178][]
|
- Calling parse multiple times is now officially supported without `clear` (automatic). [#178][]
|
||||||
* 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][]
|
- 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][]
|
||||||
* Use the standard `BUILD_TESTING` over `CLI11_TESTING` if defined [#183][]
|
- Use the standard `BUILD_TESTING` over `CLI11_TESTING` if defined [#183][]
|
||||||
* Cleanup warnings [#191][]
|
- Cleanup warnings [#191][]
|
||||||
* Remove deprecated names: `set_footer`, `set_name`, `set_callback`, and `set_type_name`. Use without the `set_` instead. [#192][]
|
- Remove deprecated names: `set_footer`, `set_name`, `set_callback`, and `set_type_name`. Use without the `set_` instead. [#192][]
|
||||||
|
|
||||||
> ### Converting from CLI11 1.6
|
> ### Converting from CLI11 1.6
|
||||||
>
|
>
|
||||||
> * `->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.
|
> - `->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.
|
||||||
> * `->add_set*` becomes `->add_mutable_set*` if you were using the editable set feature
|
> - `->add_set*` becomes `->add_mutable_set*` if you were using the editable set feature
|
||||||
> * `footer`, `name`, `callback`, and `type_name` must be used instead of the `set_*` versions (deprecated previously).
|
> - `footer`, `name`, `callback`, and `type_name` must be used instead of the `set_*` versions (deprecated previously).
|
||||||
|
|
||||||
[#178]: https://github.com/CLIUtils/CLI11/pull/178
|
[#178]: https://github.com/CLIUtils/CLI11/pull/178
|
||||||
[#183]: https://github.com/CLIUtils/CLI11/pull/183
|
[#183]: https://github.com/CLIUtils/CLI11/pull/183
|
||||||
@ -362,9 +362,9 @@ Passing the same subcommand multiple times is better supported. Several new feat
|
|||||||
|
|
||||||
This version provides a quick patch for a (correct) warning from GCC 8 for the windows options code.
|
This version provides a quick patch for a (correct) warning from GCC 8 for the windows options code.
|
||||||
|
|
||||||
* Fix for Windows style option parsing [#201][]
|
- Fix for Windows style option parsing [#201][]
|
||||||
* Improve `add_subcommand` when throwing an exception [#204][]
|
- Improve `add_subcommand` when throwing an exception [#204][]
|
||||||
* Better metadata for Conan package [#202][]
|
- Better metadata for Conan package [#202][]
|
||||||
|
|
||||||
[#201]: https://github.com/CLIUtils/CLI11/pull/201
|
[#201]: https://github.com/CLIUtils/CLI11/pull/201
|
||||||
[#202]: https://github.com/CLIUtils/CLI11/pull/202
|
[#202]: https://github.com/CLIUtils/CLI11/pull/202
|
||||||
@ -374,64 +374,64 @@ This version provides a quick patch for a (correct) warning from GCC 8 for the w
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Added `CLI::Formatter` and `formatter` slot for apps, inherited.
|
- Added `CLI::Formatter` and `formatter` slot for apps, inherited.
|
||||||
* `FormatterBase` is the minimum required.
|
- `FormatterBase` is the minimum required.
|
||||||
* `FormatterLambda` provides for the easy addition of an arbitrary function.
|
- `FormatterLambda` provides for the easy addition of an arbitrary function.
|
||||||
* Added `help_all` support (not added by default).
|
- Added `help_all` support (not added by default).
|
||||||
|
|
||||||
Changes to the help system (most normal users will not notice this):
|
Changes to the help system (most normal users will not notice this):
|
||||||
|
|
||||||
* Renamed `single_name` to `get_name(false, false)` (the default).
|
- Renamed `single_name` to `get_name(false, false)` (the default).
|
||||||
* The old `get_name()` is now `get_name(false, true)`.
|
- The old `get_name()` is now `get_name(false, true)`.
|
||||||
* The old `get_pname()` is now `get_name(true, false)`.
|
- The old `get_pname()` is now `get_name(true, false)`.
|
||||||
* Removed `help_*` functions.
|
- Removed `help_*` functions.
|
||||||
* Protected function `_has_help_positional` removed.
|
- Protected function `_has_help_positional` removed.
|
||||||
* `format_help` can now be chained.
|
- `format_help` can now be chained.
|
||||||
* Added getters for the missing parts of options (help no longer uses any private parts).
|
- Added getters for the missing parts of options (help no longer uses any private parts).
|
||||||
* Help flags now use new `short_circuit` property to simplify parsing. [#121][]
|
- Help flags now use new `short_circuit` property to simplify parsing. [#121][]
|
||||||
|
|
||||||
New for Config file reading and writing [#121][]:
|
New for Config file reading and writing [#121][]:
|
||||||
|
|
||||||
* Overridable, bidirectional Config.
|
- Overridable, bidirectional Config.
|
||||||
* ConfigINI provided and used by default.
|
- ConfigINI provided and used by default.
|
||||||
* Renamed ini to config in many places.
|
- Renamed ini to config in many places.
|
||||||
* Has `config_formatter()` and `get_config_formatter()`.
|
- Has `config_formatter()` and `get_config_formatter()`.
|
||||||
* Dropped prefix argument from `config_to_str`.
|
- Dropped prefix argument from `config_to_str`.
|
||||||
* Added `ConfigItem`.
|
- Added `ConfigItem`.
|
||||||
* Added an example of a custom config format using [nlohmann/json][]. [#138][]
|
- Added an example of a custom config format using [nlohmann/json][]. [#138][]
|
||||||
|
|
||||||
Validators are now much more powerful [#118][], all built in validators upgraded to the new form:
|
Validators are now much more powerful [#118][], all built in validators upgraded to the new form:
|
||||||
|
|
||||||
* A subclass of `CLI::Validator` is now also accepted.
|
- A subclass of `CLI::Validator` is now also accepted.
|
||||||
* They now can set the type name to things like `PATH` and `INT in [1-4]`.
|
- They now can set the type name to things like `PATH` and `INT in [1-4]`.
|
||||||
* Validators can be combined with `&` and `|`.
|
- Validators can be combined with `&` and `|`.
|
||||||
* Old form simple validators are still accepted.
|
- Old form simple validators are still accepted.
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
* Fixing `parse(args)`'s `args` setting and ordering after parse. [#141][]
|
- Fixing `parse(args)`'s `args` setting and ordering after parse. [#141][]
|
||||||
* Replaced `set_custom_option` with `type_name` and `type_size` instead of `set_custom_option`. Methods return `this`. [#136][]
|
- Replaced `set_custom_option` with `type_name` and `type_size` instead of `set_custom_option`. Methods return `this`. [#136][]
|
||||||
* Dropped `set_` on Option's `type_name`, `default_str`, and `default_val`. [#136][]
|
- Dropped `set_` on Option's `type_name`, `default_str`, and `default_val`. [#136][]
|
||||||
* Removed `set_` from App's `failure_message`, `footer`, `callback`, and `name`. [#136][]
|
- Removed `set_` from App's `failure_message`, `footer`, `callback`, and `name`. [#136][]
|
||||||
* Fixed support `N<-1` for `type_size`. [#140][]
|
- Fixed support `N<-1` for `type_size`. [#140][]
|
||||||
* Added `->each()` to make adding custom callbacks easier. [#126][]
|
- Added `->each()` to make adding custom callbacks easier. [#126][]
|
||||||
* Allow empty options `add_option("-n",{})` to be edited later with `each` [#142][]
|
- Allow empty options `add_option("-n",{})` to be edited later with `each` [#142][]
|
||||||
* Added filter argument to `get_subcommands`, `get_options`; use empty filter `{}` to avoid filtering.
|
- Added filter argument to `get_subcommands`, `get_options`; use empty filter `{}` to avoid filtering.
|
||||||
* Added `get_groups()` to get groups.
|
- Added `get_groups()` to get groups.
|
||||||
* Better support for manual options with `get_option`, `set_results`, and `empty`. [#119][]
|
- Better support for manual options with `get_option`, `set_results`, and `empty`. [#119][]
|
||||||
* `lname` and `sname` have getters, added `const get_parent`. [#120][]
|
- `lname` and `sname` have getters, added `const get_parent`. [#120][]
|
||||||
* Using `add_set` will now capture L-values for sets, allowing further modification. [#113][]
|
- Using `add_set` will now capture L-values for sets, allowing further modification. [#113][]
|
||||||
* Dropped duplicate way to run `get_type_name` (`get_typeval`).
|
- Dropped duplicate way to run `get_type_name` (`get_typeval`).
|
||||||
* Removed `requires` in favor of `needs` (deprecated in last version). [#112][]
|
- Removed `requires` in favor of `needs` (deprecated in last version). [#112][]
|
||||||
* Const added to argv. [#126][]
|
- Const added to argv. [#126][]
|
||||||
|
|
||||||
Backend and testing changes:
|
Backend and testing changes:
|
||||||
|
|
||||||
* Internally, `type_name` is now a lambda function; for sets, this reads the set live. [#116][]
|
- Internally, `type_name` is now a lambda function; for sets, this reads the set live. [#116][]
|
||||||
* Cleaner tests without `app.reset()` (and `reset` is now `clear`). [#141][]
|
- Cleaner tests without `app.reset()` (and `reset` is now `clear`). [#141][]
|
||||||
* Better CMake policy handling. [#110][]
|
- Better CMake policy handling. [#110][]
|
||||||
* Includes are properly sorted. [#120][]
|
- Includes are properly sorted. [#120][]
|
||||||
* Testing (only) now uses submodules. [#111][]
|
- Testing (only) now uses submodules. [#111][]
|
||||||
|
|
||||||
[#109]: https://github.com/CLIUtils/CLI11/pull/109
|
[#109]: https://github.com/CLIUtils/CLI11/pull/109
|
||||||
[#110]: https://github.com/CLIUtils/CLI11/pull/110
|
[#110]: https://github.com/CLIUtils/CLI11/pull/110
|
||||||
@ -449,7 +449,6 @@ Backend and testing changes:
|
|||||||
[#140]: https://github.com/CLIUtils/CLI11/pull/140
|
[#140]: https://github.com/CLIUtils/CLI11/pull/140
|
||||||
[#141]: https://github.com/CLIUtils/CLI11/pull/141
|
[#141]: https://github.com/CLIUtils/CLI11/pull/141
|
||||||
[#142]: https://github.com/CLIUtils/CLI11/pull/142
|
[#142]: https://github.com/CLIUtils/CLI11/pull/142
|
||||||
|
|
||||||
[nlohmann/json]: https://github.com/nlohmann/json
|
[nlohmann/json]: https://github.com/nlohmann/json
|
||||||
|
|
||||||
### Version 1.6.1: Platform fixes
|
### Version 1.6.1: Platform fixes
|
||||||
@ -458,9 +457,9 @@ This version provides a few fixes for special cases, such as mixing with `Window
|
|||||||
for systems like Hunter. The one new feature is the ability to produce "branded" single file output for
|
for systems like Hunter. The one new feature is the ability to produce "branded" single file output for
|
||||||
providing custom namespaces or custom macro names.
|
providing custom namespaces or custom macro names.
|
||||||
|
|
||||||
* Added fix and test for including Windows.h [#145][]
|
- Added fix and test for including Windows.h [#145][]
|
||||||
* No longer build single file by default if main project, supports systems stuck on Python 2.6 [#149][], [#151][]
|
- No longer build single file by default if main project, supports systems stuck on Python 2.6 [#149][], [#151][]
|
||||||
* Branding support for single file output [#150][]
|
- Branding support for single file output [#150][]
|
||||||
|
|
||||||
[#145]: https://github.com/CLIUtils/CLI11/pull/145
|
[#145]: https://github.com/CLIUtils/CLI11/pull/145
|
||||||
[#149]: https://github.com/CLIUtils/CLI11/pull/149
|
[#149]: https://github.com/CLIUtils/CLI11/pull/149
|
||||||
@ -471,17 +470,17 @@ providing custom namespaces or custom macro names.
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Fixed help-all formatting [#163][]
|
- Fixed help-all formatting [#163][]
|
||||||
* Printing help-all on nested command now fixed (App)
|
- Printing help-all on nested command now fixed (App)
|
||||||
* Missing space after help-all restored (Default formatter)
|
- Missing space after help-all restored (Default formatter)
|
||||||
* More detail printed on help all (Default formatter)
|
- More detail printed on help all (Default formatter)
|
||||||
* Help-all subcommands get indented with inner blank lines removed (Default formatter)
|
- Help-all subcommands get indented with inner blank lines removed (Default formatter)
|
||||||
* `detail::find_and_replace` added to utilities
|
- `detail::find_and_replace` added to utilities
|
||||||
* Fixed CMake install as subproject with `CLI11_INSTALL` flag. [#156][]
|
- Fixed CMake install as subproject with `CLI11_INSTALL` flag. [#156][]
|
||||||
* Fixed warning about local variable hiding class member with MSVC [#157][]
|
- Fixed warning about local variable hiding class member with MSVC [#157][]
|
||||||
* Fixed compile error with default settings on Clang 7 and libc++ [#158][]
|
- Fixed compile error with default settings on Clang 7 and libc++ [#158][]
|
||||||
* Fixed special case of `--help` on subcommands (general fix planned for 1.7) [#168][]
|
- Fixed special case of `--help` on subcommands (general fix planned for 1.7) [#168][]
|
||||||
* Removing an option with links [#179][]
|
- Removing an option with links [#179][]
|
||||||
|
|
||||||
[#156]: https://github.com/CLIUtils/CLI11/issues/156
|
[#156]: https://github.com/CLIUtils/CLI11/issues/156
|
||||||
[#157]: https://github.com/CLIUtils/CLI11/issues/157
|
[#157]: https://github.com/CLIUtils/CLI11/issues/157
|
||||||
@ -496,24 +495,24 @@ This version introduced support for optionals, along with clarification and exam
|
|||||||
|
|
||||||
Note: This is the final release with `requires`, please switch to `needs`.
|
Note: This is the final release with `requires`, please switch to `needs`.
|
||||||
|
|
||||||
* Fix unlimited short options eating two values before checking for positionals when no space present [#90][]
|
- Fix unlimited short options eating two values before checking for positionals when no space present [#90][]
|
||||||
* Symmetric exclude text when excluding options, exclude can be called multiple times [#64][]
|
- Symmetric exclude text when excluding options, exclude can be called multiple times [#64][]
|
||||||
* Support for `std::optional`, `std::experimental::optional`, and `boost::optional` added if `__has_include` is supported [#95][]
|
- Support for `std::optional`, `std::experimental::optional`, and `boost::optional` added if `__has_include` is supported [#95][]
|
||||||
* All macros/CMake variables now start with `CLI11_` instead of just `CLI_` [#95][]
|
- All macros/CMake variables now start with `CLI11_` instead of just `CLI_` [#95][]
|
||||||
* The internal stream was not being cleared before use in some cases. Fixed. [#95][]
|
- The internal stream was not being cleared before use in some cases. Fixed. [#95][]
|
||||||
* Using an enum now requires explicit conversion overload [#97][]
|
- Using an enum now requires explicit conversion overload [#97][]
|
||||||
* The separator `--` now is removed when it ends unlimited arguments [#100][]
|
- The separator `--` now is removed when it ends unlimited arguments [#100][]
|
||||||
|
|
||||||
Other, non-user facing changes:
|
Other, non-user facing changes:
|
||||||
|
|
||||||
* Added `Macros.hpp` with better C++ mode discovery [#95][]
|
- Added `Macros.hpp` with better C++ mode discovery [#95][]
|
||||||
* Deprecated macros added for all platforms
|
- Deprecated macros added for all platforms
|
||||||
* C++17 is now tested on supported platforms [#95][]
|
- C++17 is now tested on supported platforms [#95][]
|
||||||
* Informational printout now added to CTest [#95][]
|
- Informational printout now added to CTest [#95][]
|
||||||
* Better single file generation [#95][]
|
- Better single file generation [#95][]
|
||||||
* Added support for GTest on MSVC 2017 (but not in C++17 mode, will need next version of GTest)
|
- Added support for GTest on MSVC 2017 (but not in C++17 mode, will need next version of GTest)
|
||||||
* Types now have a specific size, separate from the expected number - cleaner and more powerful internally [#92][]
|
- Types now have a specific size, separate from the expected number - cleaner and more powerful internally [#92][]
|
||||||
* Examples now run as part of testing [#99][]
|
- Examples now run as part of testing [#99][]
|
||||||
|
|
||||||
[#64]: https://github.com/CLIUtils/CLI11/issues/64
|
[#64]: https://github.com/CLIUtils/CLI11/issues/64
|
||||||
[#90]: https://github.com/CLIUtils/CLI11/issues/90
|
[#90]: https://github.com/CLIUtils/CLI11/issues/90
|
||||||
@ -527,13 +526,13 @@ Other, non-user facing changes:
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Make mixing unlimited positionals and options more intuitive [#102][]
|
- Make mixing unlimited positionals and options more intuitive [#102][]
|
||||||
* Add missing getters `get_options` and `get_description` to App [#105][]
|
- Add missing getters `get_options` and `get_description` to App [#105][]
|
||||||
* The app name now can be set, and will override the auto name if present [#105][]
|
- The app name now can be set, and will override the auto name if present [#105][]
|
||||||
* Add `(REQUIRED)` for required options [#104][]
|
- Add `(REQUIRED)` for required options [#104][]
|
||||||
* Print simple name for Needs/Excludes [#104][]
|
- Print simple name for Needs/Excludes [#104][]
|
||||||
* Use Needs instead of Requires in help print [#104][]
|
- Use Needs instead of Requires in help print [#104][]
|
||||||
* Groups now are listed in the original definition order [#106][]
|
- Groups now are listed in the original definition order [#106][]
|
||||||
|
|
||||||
[#102]: https://github.com/CLIUtils/CLI11/issues/102
|
[#102]: https://github.com/CLIUtils/CLI11/issues/102
|
||||||
[#104]: https://github.com/CLIUtils/CLI11/pull/104
|
[#104]: https://github.com/CLIUtils/CLI11/pull/104
|
||||||
@ -556,21 +555,20 @@ This version fixes the optional search in the single file version; some macros w
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Lexical cast is now more strict than before [#68][] and fails on overflow [#84][]
|
- Lexical cast is now more strict than before [#68][] and fails on overflow [#84][]
|
||||||
* Added `get_parent()` to access the parent from a subcommand
|
- Added `get_parent()` to access the parent from a subcommand
|
||||||
* Added `ExistingPath` validator [#73][]
|
- Added `ExistingPath` validator [#73][]
|
||||||
* `app.allow_ini_extras()` added to allow extras in INI files [#70][]
|
- `app.allow_ini_extras()` added to allow extras in INI files [#70][]
|
||||||
* Multiline INI comments now supported
|
- Multiline INI comments now supported
|
||||||
* Descriptions can now be written with `config_to_str` [#66][]
|
- Descriptions can now be written with `config_to_str` [#66][]
|
||||||
* Double printing of error message fixed [#77][]
|
- Double printing of error message fixed [#77][]
|
||||||
* Renamed `requires` to `needs` to avoid C++20 keyword [#75][], [#82][]
|
- Renamed `requires` to `needs` to avoid C++20 keyword [#75][], [#82][]
|
||||||
* MakeSingleHeader now works if outside of git [#78][]
|
- MakeSingleHeader now works if outside of git [#78][]
|
||||||
* Adding install support for CMake [#79][], improved support for `find_package` [#83][], [#84][]
|
- Adding install support for CMake [#79][], improved support for `find_package` [#83][], [#84][]
|
||||||
* Added support for Conan.io [#83][]
|
- Added support for Conan.io [#83][]
|
||||||
|
|
||||||
[#70]: https://github.com/CLIUtils/CLI11/issues/70
|
[#70]: https://github.com/CLIUtils/CLI11/issues/70
|
||||||
[#75]: https://github.com/CLIUtils/CLI11/issues/75
|
[#75]: https://github.com/CLIUtils/CLI11/issues/75
|
||||||
|
|
||||||
[#84]: https://github.com/CLIUtils/CLI11/pull/84
|
[#84]: https://github.com/CLIUtils/CLI11/pull/84
|
||||||
[#83]: https://github.com/CLIUtils/CLI11/pull/83
|
[#83]: https://github.com/CLIUtils/CLI11/pull/83
|
||||||
[#82]: https://github.com/CLIUtils/CLI11/pull/82
|
[#82]: https://github.com/CLIUtils/CLI11/pull/82
|
||||||
@ -588,156 +586,156 @@ features only working on the main App have been addressed, and extra arguments h
|
|||||||
of defaults makes configuring CLI11 much easier without having to subclass. Policies add new ways to handle multiple arguments to match your
|
of defaults makes configuring CLI11 much easier without having to subclass. Policies add new ways to handle multiple arguments to match your
|
||||||
favorite CLI programs. Error messages and help messages are better and more flexible. Several bugs and odd behaviors in the parser have been fixed.
|
favorite CLI programs. Error messages and help messages are better and more flexible. Several bugs and odd behaviors in the parser have been fixed.
|
||||||
|
|
||||||
* Added a version macro, `CLI11_VERSION`, along with `*_MAJOR`, `*_MINOR`, and `*_PATCH`, for programmatic access to the version.
|
- Added a version macro, `CLI11_VERSION`, along with `*_MAJOR`, `*_MINOR`, and `*_PATCH`, for programmatic access to the version.
|
||||||
* Reworked the way defaults are set and inherited; explicit control given to user with `->option_defaults()` [#48](https://github.com/CLIUtils/CLI11/pull/48)
|
- Reworked the way defaults are set and inherited; explicit control given to user with `->option_defaults()` [#48](https://github.com/CLIUtils/CLI11/pull/48)
|
||||||
* Hidden options now are based on an empty group name, instead of special "hidden" keyword [#48](https://github.com/CLIUtils/CLI11/pull/48)
|
- Hidden options now are based on an empty group name, instead of special "hidden" keyword [#48](https://github.com/CLIUtils/CLI11/pull/48)
|
||||||
* `parse` no longer returns (so `CLI11_PARSE` is always usable) [#37](https://github.com/CLIUtils/CLI11/pull/37)
|
- `parse` no longer returns (so `CLI11_PARSE` is always usable) [#37](https://github.com/CLIUtils/CLI11/pull/37)
|
||||||
* Added `remaining()` and `remaining_size()` [#37](https://github.com/CLIUtils/CLI11/pull/37)
|
- Added `remaining()` and `remaining_size()` [#37](https://github.com/CLIUtils/CLI11/pull/37)
|
||||||
* `allow_extras` and `prefix_command` are now valid on subcommands [#37](https://github.com/CLIUtils/CLI11/pull/37)
|
- `allow_extras` and `prefix_command` are now valid on subcommands [#37](https://github.com/CLIUtils/CLI11/pull/37)
|
||||||
* Added `take_last` to only take last value passed [#40](https://github.com/CLIUtils/CLI11/pull/40)
|
- Added `take_last` to only take last value passed [#40](https://github.com/CLIUtils/CLI11/pull/40)
|
||||||
* Added `multi_option_policy` and shortcuts to provide more control than just a take last policy [#59](https://github.com/CLIUtils/CLI11/pull/59)
|
- Added `multi_option_policy` and shortcuts to provide more control than just a take last policy [#59](https://github.com/CLIUtils/CLI11/pull/59)
|
||||||
* More detailed error messages in a few cases [#41](https://github.com/CLIUtils/CLI11/pull/41)
|
- More detailed error messages in a few cases [#41](https://github.com/CLIUtils/CLI11/pull/41)
|
||||||
* Footers can be added to help [#42](https://github.com/CLIUtils/CLI11/pull/42)
|
- Footers can be added to help [#42](https://github.com/CLIUtils/CLI11/pull/42)
|
||||||
* Help flags are easier to customize [#43](https://github.com/CLIUtils/CLI11/pull/43)
|
- Help flags are easier to customize [#43](https://github.com/CLIUtils/CLI11/pull/43)
|
||||||
* Subcommand now support groups [#46](https://github.com/CLIUtils/CLI11/pull/46)
|
- Subcommand now support groups [#46](https://github.com/CLIUtils/CLI11/pull/46)
|
||||||
* `CLI::RuntimeError` added, for easy exit with error codes [#45](https://github.com/CLIUtils/CLI11/pull/45)
|
- `CLI::RuntimeError` added, for easy exit with error codes [#45](https://github.com/CLIUtils/CLI11/pull/45)
|
||||||
* The clang-format script is now no longer "hidden" [#48](https://github.com/CLIUtils/CLI11/pull/48)
|
- The clang-format script is now no longer "hidden" [#48](https://github.com/CLIUtils/CLI11/pull/48)
|
||||||
* The order is now preserved for subcommands (list and callbacks) [#49](https://github.com/CLIUtils/CLI11/pull/49)
|
- The order is now preserved for subcommands (list and callbacks) [#49](https://github.com/CLIUtils/CLI11/pull/49)
|
||||||
* Tests now run individually, utilizing CMake 3.10 additions if possible [#50](https://github.com/CLIUtils/CLI11/pull/50)
|
- Tests now run individually, utilizing CMake 3.10 additions if possible [#50](https://github.com/CLIUtils/CLI11/pull/50)
|
||||||
* Failure messages are now customizable, with a shorter default [#52](https://github.com/CLIUtils/CLI11/pull/52)
|
- Failure messages are now customizable, with a shorter default [#52](https://github.com/CLIUtils/CLI11/pull/52)
|
||||||
* Some improvements to error codes [#53](https://github.com/CLIUtils/CLI11/pull/53)
|
- Some improvements to error codes [#53](https://github.com/CLIUtils/CLI11/pull/53)
|
||||||
* `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)
|
- `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)
|
||||||
* Subcommands no longer match after the max required number is obtained [#51](https://github.com/CLIUtils/CLI11/pull/51)
|
- Subcommands no longer match after the max required number is obtained [#51](https://github.com/CLIUtils/CLI11/pull/51)
|
||||||
* Unlimited options no longer prioritize over remaining/unlimited positionals [#51](https://github.com/CLIUtils/CLI11/pull/51)
|
- Unlimited options no longer prioritize over remaining/unlimited positionals [#51](https://github.com/CLIUtils/CLI11/pull/51)
|
||||||
* Added `->transform` which modifies the string parsed [#54](https://github.com/CLIUtils/CLI11/pull/54)
|
- Added `->transform` which modifies the string parsed [#54](https://github.com/CLIUtils/CLI11/pull/54)
|
||||||
* Changed of API in validators to `void(std::string &)` (const for users), throwing providing nicer errors [#54](https://github.com/CLIUtils/CLI11/pull/54)
|
- Changed of API in validators to `void(std::string &)` (const for users), throwing providing nicer errors [#54](https://github.com/CLIUtils/CLI11/pull/54)
|
||||||
* 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)
|
- 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)
|
||||||
* Support for minimum unlimited expected arguments [#56](https://github.com/CLIUtils/CLI11/pull/56)
|
- Support for minimum unlimited expected arguments [#56](https://github.com/CLIUtils/CLI11/pull/56)
|
||||||
* Single internal arg parse function [#56](https://github.com/CLIUtils/CLI11/pull/56)
|
- Single internal arg parse function [#56](https://github.com/CLIUtils/CLI11/pull/56)
|
||||||
* Allow options to be disabled from INI file, rename `add_config` to `set_config` [#60](https://github.com/CLIUtils/CLI11/pull/60)
|
- Allow options to be disabled from INI file, rename `add_config` to `set_config` [#60](https://github.com/CLIUtils/CLI11/pull/60)
|
||||||
|
|
||||||
> ### Converting from CLI11 1.2
|
> ### Converting from CLI11 1.2
|
||||||
>
|
>
|
||||||
> * `app.parse` no longer returns a vector. Instead, use `app.remaining(true)`.
|
> - `app.parse` no longer returns a vector. Instead, use `app.remaining(true)`.
|
||||||
> * `"hidden"` is no longer a special group name, instead use `""`
|
> - `"hidden"` is no longer a special group name, instead use `""`
|
||||||
> * Validators API has changed to return an error string; use `.empty()` to get the old bool back
|
> - Validators API has changed to return an error string; use `.empty()` to get the old bool back
|
||||||
> * Use `.set_help_flag` instead of accessing the help pointer directly (discouraged, but not removed yet)
|
> - Use `.set_help_flag` instead of accessing the help pointer directly (discouraged, but not removed yet)
|
||||||
> * `add_config` has been renamed to `set_config`
|
> - `add_config` has been renamed to `set_config`
|
||||||
> * Errors thrown in some cases are slightly more specific
|
> - Errors thrown in some cases are slightly more specific
|
||||||
|
|
||||||
## Version 1.2: Stability
|
## Version 1.2: Stability
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Added functional form of flag [#33](https://github.com/CLIUtils/CLI11/pull/33), automatic on C++14
|
- Added functional form of flag [#33](https://github.com/CLIUtils/CLI11/pull/33), automatic on C++14
|
||||||
* Fixed Config file search if passed on command line [#30](https://github.com/CLIUtils/CLI11/issues/30)
|
- Fixed Config file search if passed on command line [#30](https://github.com/CLIUtils/CLI11/issues/30)
|
||||||
* Added `CLI11_PARSE(app, argc, argv)` macro for simple parse commands (does not support returning arg)
|
- Added `CLI11_PARSE(app, argc, argv)` macro for simple parse commands (does not support returning arg)
|
||||||
* The name string can now contain spaces around commas [#29](https://github.com/CLIUtils/CLI11/pull/29)
|
- The name string can now contain spaces around commas [#29](https://github.com/CLIUtils/CLI11/pull/29)
|
||||||
* `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)
|
- `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)
|
||||||
* Required positionals now take priority over subcommands [#23](https://github.com/CLIUtils/CLI11/issues/23)
|
- Required positionals now take priority over subcommands [#23](https://github.com/CLIUtils/CLI11/issues/23)
|
||||||
* Extra requirements enforced by Travis
|
- Extra requirements enforced by Travis
|
||||||
|
|
||||||
## Version 1.1: Feedback
|
## Version 1.1: Feedback
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Added simple support for enumerations, allow non-printable objects [#12](https://github.com/CLIUtils/CLI11/issues/12)
|
- Added simple support for enumerations, allow non-printable objects [#12](https://github.com/CLIUtils/CLI11/issues/12)
|
||||||
* Added `app.parse_order()` with original parse order ([#13](https://github.com/CLIUtils/CLI11/issues/13), [#16](https://github.com/CLIUtils/CLI11/pull/16))
|
- Added `app.parse_order()` with original parse order ([#13](https://github.com/CLIUtils/CLI11/issues/13), [#16](https://github.com/CLIUtils/CLI11/pull/16))
|
||||||
* 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))
|
- 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))
|
||||||
* Removed Windows warning ([#10](https://github.com/CLIUtils/CLI11/issues/10), [#20](https://github.com/CLIUtils/CLI11/pull/20))
|
- Removed Windows warning ([#10](https://github.com/CLIUtils/CLI11/issues/10), [#20](https://github.com/CLIUtils/CLI11/pull/20))
|
||||||
* 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))
|
- 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))
|
||||||
|
|
||||||
## Version 1.0: Official release
|
## Version 1.0: Official release
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
* Cleanup using `clang-tidy` and `clang-format`
|
- Cleanup using `clang-tidy` and `clang-format`
|
||||||
* Small improvements to Timers, easier to subclass Error
|
- Small improvements to Timers, easier to subclass Error
|
||||||
* Move to 3-Clause BSD license
|
- Move to 3-Clause BSD license
|
||||||
|
|
||||||
## Version 0.9: Polish
|
## Version 0.9: Polish
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Better CMake named target (CLI11)
|
- Better CMake named target (CLI11)
|
||||||
* More warnings added, fixed
|
- More warnings added, fixed
|
||||||
* Ini output now includes `=false` when `default_also` is true
|
- Ini output now includes `=false` when `default_also` is true
|
||||||
* Ini no longer lists the help pointer
|
- Ini no longer lists the help pointer
|
||||||
* Added test for inclusion in multiple files and linking, fixed issues (rarely needed for CLI, but nice for tools)
|
- Added test for inclusion in multiple files and linking, fixed issues (rarely needed for CLI, but nice for tools)
|
||||||
* Support for complex numbers
|
- Support for complex numbers
|
||||||
* Subcommands now test true/false directly or with `->parsed()`, cleaner parse
|
- Subcommands now test true/false directly or with `->parsed()`, cleaner parse
|
||||||
|
|
||||||
## Version 0.8: CLIUtils
|
## Version 0.8: CLIUtils
|
||||||
|
|
||||||
This release moved the repository to the CLIUtils main organization.
|
This release moved the repository to the CLIUtils main organization.
|
||||||
|
|
||||||
* Moved to CLIUtils on GitHub
|
- Moved to CLIUtils on GitHub
|
||||||
* Fixed docs build and a few links
|
- Fixed docs build and a few links
|
||||||
|
|
||||||
## Version 0.7: Code coverage 100%
|
## Version 0.7: Code coverage 100%
|
||||||
|
|
||||||
Lots of small bugs fixed when adding code coverage, better in edge cases. Much more powerful ini support.
|
Lots of small bugs fixed when adding code coverage, better in edge cases. Much more powerful ini support.
|
||||||
|
|
||||||
* Allow comments in ini files (lines starting with `;`)
|
- Allow comments in ini files (lines starting with `;`)
|
||||||
* Ini files support flags, vectors, subcommands
|
- Ini files support flags, vectors, subcommands
|
||||||
* Added CodeCov code coverage reports
|
- Added CodeCov code coverage reports
|
||||||
* Lots of small bugfixes related to adding tests to increase coverage to 100%
|
- Lots of small bugfixes related to adding tests to increase coverage to 100%
|
||||||
* Error handling now uses scoped enum in errors
|
- Error handling now uses scoped enum in errors
|
||||||
* Reparsing rules changed a little to accommodate Ini files. Callbacks are now called when parsing INI, and reset any time results are added.
|
- Reparsing rules changed a little to accommodate Ini files. Callbacks are now called when parsing INI, and reset any time results are added.
|
||||||
* Adding extra utilities in full version only, `Timer` (not needed for parsing, but useful for general CLI applications).
|
- Adding extra utilities in full version only, `Timer` (not needed for parsing, but useful for general CLI applications).
|
||||||
* Better support for custom `add_options` like functions.
|
- Better support for custom `add_options` like functions.
|
||||||
|
|
||||||
## Version 0.6: Cleanup
|
## Version 0.6: Cleanup
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* Simplified parsing to use `vector<string>` only
|
- Simplified parsing to use `vector<string>` only
|
||||||
* Fixed fallthrough, made it optional as well (default: off): `.fallthrough()`.
|
- Fixed fallthrough, made it optional as well (default: off): `.fallthrough()`.
|
||||||
* Added string versions of `->requires()` and `->excludes()` for consistency.
|
- Added string versions of `->requires()` and `->excludes()` for consistency.
|
||||||
* Renamed protected members for internal consistency, grouped docs.
|
- Renamed protected members for internal consistency, grouped docs.
|
||||||
* Added the ability to add a number to `.require_subcommand()`.
|
- Added the ability to add a number to `.require_subcommand()`.
|
||||||
|
|
||||||
## Version 0.5: Windows support
|
## Version 0.5: Windows support
|
||||||
|
|
||||||
* Allow `Hidden` options.
|
- Allow `Hidden` options.
|
||||||
* Throw `OptionAlreadyAdded` errors for matching subcommands or options, with ignore-case included, tests
|
- Throw `OptionAlreadyAdded` errors for matching subcommands or options, with ignore-case included, tests
|
||||||
* `->ignore_case()` added to subcommands, options, and `add_set_ignore_case`. Subcommands inherit setting from parent App on creation.
|
- `->ignore_case()` added to subcommands, options, and `add_set_ignore_case`. Subcommands inherit setting from parent App on creation.
|
||||||
* 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.
|
- 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.
|
||||||
* 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.
|
- 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.
|
||||||
* 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`.
|
- 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`.
|
||||||
* Added printout of ini file text given parsed options, skips flags.
|
- Added printout of ini file text given parsed options, skips flags.
|
||||||
* Support for quotes and spaces in ini files
|
- Support for quotes and spaces in ini files
|
||||||
* Fixes to allow support for Windows (added Appveyor) (Uses `-`, not `/` syntax)
|
- Fixes to allow support for Windows (added Appveyor) (Uses `-`, not `/` syntax)
|
||||||
|
|
||||||
## Version 0.4: Ini support
|
## Version 0.4: Ini support
|
||||||
|
|
||||||
* Updates to help print
|
- Updates to help print
|
||||||
* Removed `run`, please use `parse` unless you subclass and add it
|
- Removed `run`, please use `parse` unless you subclass and add it
|
||||||
* Supports ini files mixed with command line, tested
|
- Supports ini files mixed with command line, tested
|
||||||
* Added Range for further Plumbum compatibility
|
- Added Range for further Plumbum compatibility
|
||||||
* Added function to print out ini file
|
- Added function to print out ini file
|
||||||
|
|
||||||
## Version 0.3: Plumbum compatibility
|
## Version 0.3: Plumbum compatibility
|
||||||
|
|
||||||
* Added `->requires`, `->excludes`, and `->envname` from [Plumbum](http://plumbum.readthedocs.io/en/latest/)
|
- Added `->requires`, `->excludes`, and `->envname` from [Plumbum](http://plumbum.readthedocs.io/en/latest/)
|
||||||
* Supports `->mandatory` from Plumbum
|
- Supports `->mandatory` from Plumbum
|
||||||
* More tests for help strings, improvements in formatting
|
- More tests for help strings, improvements in formatting
|
||||||
* Support type and set syntax in positionals help strings
|
- Support type and set syntax in positionals help strings
|
||||||
* Added help groups, with `->group("name")` syntax
|
- Added help groups, with `->group("name")` syntax
|
||||||
* Added initial support for ini file reading with `add_config` option.
|
- Added initial support for ini file reading with `add_config` option.
|
||||||
* Supports GCC 4.7 again
|
- Supports GCC 4.7 again
|
||||||
* Clang 3.5 now required for tests due to googlemock usage, 3.4 should still work otherwise
|
- Clang 3.5 now required for tests due to googlemock usage, 3.4 should still work otherwise
|
||||||
* Changes `setup` for an explicit help bool in constructor/`add_subcommand`
|
- Changes `setup` for an explicit help bool in constructor/`add_subcommand`
|
||||||
|
|
||||||
## Version 0.2: Leaner and meaner
|
## Version 0.2: Leaner and meaner
|
||||||
|
|
||||||
* Moved to simpler syntax, where `Option` pointers are returned and operated on
|
- Moved to simpler syntax, where `Option` pointers are returned and operated on
|
||||||
* Removed `make_` style options
|
- Removed `make_` style options
|
||||||
* Simplified Validators, now only requires `->check(function)`
|
- Simplified Validators, now only requires `->check(function)`
|
||||||
* Removed Combiners
|
- Removed Combiners
|
||||||
* Fixed pointers to Options, stored in `unique_ptr` now
|
- Fixed pointers to Options, stored in `unique_ptr` now
|
||||||
* Added `Option_p` and `App_p`, mostly for internal use
|
- Added `Option_p` and `App_p`, mostly for internal use
|
||||||
* Startup sequence, including help flag, can be modified by subclasses
|
- Startup sequence, including help flag, can be modified by subclasses
|
||||||
|
|
||||||
## Version 0.1: First release
|
## Version 0.1: First release
|
||||||
|
|
||||||
|
466
README.md
466
README.md
@ -25,38 +25,38 @@ CLI11 is a command line parser for C++11 and beyond that provides a rich feature
|
|||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
* [Background](#background)
|
- [Background](#background)
|
||||||
* [Introduction](#introduction)
|
- [Introduction](#introduction)
|
||||||
* [Why write another CLI parser?](#why-write-another-cli-parser)
|
- [Why write another CLI parser?](#why-write-another-cli-parser)
|
||||||
* [Other parsers](#other-parsers)
|
- [Other parsers](#other-parsers)
|
||||||
* [Features not supported by this library](#features-not-supported-by-this-library)
|
- [Features not supported by this library](#features-not-supported-by-this-library)
|
||||||
* [Install](#install)
|
- [Install](#install)
|
||||||
* [Usage](#usage)
|
- [Usage](#usage)
|
||||||
* [Adding options](#adding-options)
|
- [Adding options](#adding-options)
|
||||||
* [Option types](#option-types)
|
- [Option types](#option-types)
|
||||||
* [Example](#example)
|
- [Example](#example)
|
||||||
* [Option options](#option-options)
|
- [Option options](#option-options)
|
||||||
* [Validators](#validators)
|
- [Validators](#validators)
|
||||||
* [Transforming Validators](#transforming-validators)
|
- [Transforming Validators](#transforming-validators)
|
||||||
* [Validator operations](#validator-operations)
|
- [Validator operations](#validator-operations)
|
||||||
* [Custom Validators](#custom-validators)
|
- [Custom Validators](#custom-validators)
|
||||||
* [Querying Validators](#querying-validators)
|
- [Querying Validators](#querying-validators)
|
||||||
* [Getting Results](#getting-results)
|
- [Getting Results](#getting-results)
|
||||||
* [Subcommands](#subcommands)
|
- [Subcommands](#subcommands)
|
||||||
* [Subcommand options](#subcommand-options)
|
- [Subcommand options](#subcommand-options)
|
||||||
* [Option groups](#option-groups)
|
- [Option groups](#option-groups)
|
||||||
* [Callbacks](#callbacks)
|
- [Callbacks](#callbacks)
|
||||||
* [Configuration file](#configuration-file)
|
- [Configuration file](#configuration-file)
|
||||||
* [Inheriting defaults](#inheriting-defaults)
|
- [Inheriting defaults](#inheriting-defaults)
|
||||||
* [Formatting](#formatting)
|
- [Formatting](#formatting)
|
||||||
* [Subclassing](#subclassing)
|
- [Subclassing](#subclassing)
|
||||||
* [How it works](#how-it-works)
|
- [How it works](#how-it-works)
|
||||||
* [Utilities](#utilities)
|
- [Utilities](#utilities)
|
||||||
* [Other libraries](#other-libraries)
|
- [Other libraries](#other-libraries)
|
||||||
* [API](#api)
|
- [API](#api)
|
||||||
* [Examples](#Examples)
|
- [Examples](#Examples)
|
||||||
* [Contribute](#contribute)
|
- [Contribute](#contribute)
|
||||||
* [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
Features that were added in the last released minor version are marked with "🆕". Features only available in main are marked with "🚧".
|
Features that were added in the last released minor version are marked with "🆕". Features only available in main are marked with "🚧".
|
||||||
|
|
||||||
@ -74,21 +74,21 @@ You can be notified when new releases are made by subscribing to <https://github
|
|||||||
|
|
||||||
An acceptable CLI parser library should be all of the following:
|
An acceptable CLI parser library should be all of the following:
|
||||||
|
|
||||||
* Easy to include (i.e., header only, one file if possible, **no external requirements**).
|
- Easy to include (i.e., header only, one file if possible, **no external requirements**).
|
||||||
* 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.
|
- 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.
|
||||||
* 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+.
|
- 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+.
|
||||||
* Work on Linux, macOS, and Windows.
|
- Work on Linux, macOS, and Windows.
|
||||||
* Well tested on all common platforms and compilers. "Well" is defined as having good coverage measured by [CodeCov][].
|
- Well tested on all common platforms and compilers. "Well" is defined as having good coverage measured by [CodeCov][].
|
||||||
* Clear help printing.
|
- Clear help printing.
|
||||||
* Nice error messages.
|
- Nice error messages.
|
||||||
* Standard shell idioms supported naturally, like grouping flags, a positional separator, etc.
|
- Standard shell idioms supported naturally, like grouping flags, a positional separator, etc.
|
||||||
* Easy to execute, with help, parse errors, etc. providing correct exit and details.
|
- Easy to execute, with help, parse errors, etc. providing correct exit and details.
|
||||||
* Easy to extend as part of a framework that provides "applications" to users.
|
- Easy to extend as part of a framework that provides "applications" to users.
|
||||||
* Usable subcommand syntax, with support for multiple subcommands, nested subcommands, option groups, and optional fallthrough (explained later).
|
- Usable subcommand syntax, with support for multiple subcommands, nested subcommands, option groups, and optional fallthrough (explained later).
|
||||||
* Ability to add a configuration file (`TOML`, `INI`, or custom format), and produce it as well.
|
- Ability to add a configuration file (`TOML`, `INI`, or custom format), and produce it as well.
|
||||||
* Produce real values that can be used directly in code, not something you have pay compute time to look up, for HPC applications.
|
- Produce real values that can be used directly in code, not something you have pay compute time to look up, for HPC applications.
|
||||||
* Work with common types, simple custom types, and extensible to exotic types.
|
- Work with common types, simple custom types, and extensible to exotic types.
|
||||||
* Permissively licensed.
|
- Permissively licensed.
|
||||||
|
|
||||||
### Other parsers
|
### Other parsers
|
||||||
|
|
||||||
@ -129,19 +129,19 @@ So, this library was designed to provide a great syntax, good compiler compatibi
|
|||||||
|
|
||||||
There are some other possible "features" that are intentionally not supported by this library:
|
There are some other possible "features" that are intentionally not supported by this library:
|
||||||
|
|
||||||
* Non-standard variations on syntax, like `-long` options. This is non-standard and should be avoided, so that is enforced by this library.
|
- Non-standard variations on syntax, like `-long` options. This is non-standard and should be avoided, so that is enforced by this library.
|
||||||
* 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).
|
- 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).
|
||||||
* Autocomplete: This might eventually be added to both Plumbum and CLI11, but it is not supported yet.
|
- Autocomplete: This might eventually be added to both Plumbum and CLI11, but it is not supported yet.
|
||||||
* 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.
|
- 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.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
To use, there are several methods:
|
To use, there are several methods:
|
||||||
|
|
||||||
* 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.
|
- 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.
|
||||||
* 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)`
|
- 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)`
|
||||||
* 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`.
|
- 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`.
|
||||||
* 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:
|
- 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:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
if(NOT DEFINED CLI11_DIR)
|
if(NOT DEFINED CLI11_DIR)
|
||||||
@ -158,10 +158,10 @@ And then in the source code (adding several headers might be needed to prevent l
|
|||||||
#include "CLI/Config.hpp"
|
#include "CLI/Config.hpp"
|
||||||
```
|
```
|
||||||
|
|
||||||
* 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][].
|
- 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][].
|
||||||
(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
|
(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
|
||||||
using C++11 is all you really need.)
|
using C++11 is all you really need.)
|
||||||
* 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:
|
- 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:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@ -337,9 +337,9 @@ On a `C++14` compiler, you can pass a callback function directly to `.add_flag`,
|
|||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
* `"one,-o,--one"`: Valid as long as not a flag, would create an option that can be specified positionally, or with `-o` or `--one`
|
- `"one,-o,--one"`: Valid as long as not a flag, would create an option that can be specified positionally, or with `-o` or `--one`
|
||||||
* `"this"` Can only be passed positionally
|
- `"this"` Can only be passed positionally
|
||||||
* `"-a,-b,-c"` No limit to the number of non-positional option names
|
- `"-a,-b,-c"` No limit to the number of non-positional option names
|
||||||
|
|
||||||
The add commands return a pointer to an internally stored `Option`.
|
The add commands return a pointer to an internally stored `Option`.
|
||||||
This option can be used directly to check for the count (`->count()`) after parsing to avoid a string based lookup.
|
This option can be used directly to check for the count (`->count()`) after parsing to avoid a string based lookup.
|
||||||
@ -348,62 +348,62 @@ This option can be used directly to check for the count (`->count()`) after pars
|
|||||||
|
|
||||||
Before parsing, you can set the following options:
|
Before parsing, you can set the following options:
|
||||||
|
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->expected(MIN,MAX)`: Set a range of expected values to accompany an option. `expected(0,1)` is the equivalent of making a flag.
|
- `->expected(MIN,MAX)`: Set a range of expected values to accompany an option. `expected(0,1)` is the equivalent of making a flag.
|
||||||
* `->type_name(typename)`: Set the name of an Option's type (`type_name_fn` allows a function instead)
|
- `->type_name(typename)`: Set the name of an Option's type (`type_name_fn` allows a function instead)
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->type_size(MIN,MAX)`: Set the intrinsic size of an option to a range.
|
- `->type_size(MIN,MAX)`: Set the intrinsic size of an option to a range.
|
||||||
* `->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
|
- `->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
|
||||||
* `->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)`
|
- `->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)`
|
||||||
* `->envname(name)`: Gets the value from the environment if present and not passed on the command line.
|
- `->envname(name)`: Gets the value from the environment if present and not passed on the command line.
|
||||||
* `->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).
|
- `->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).
|
||||||
* `->ignore_case()`: Ignore the case on the command line (also works on subcommands, does not affect arguments).
|
- `->ignore_case()`: Ignore the case on the command line (also works on subcommands, does not affect arguments).
|
||||||
* `->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
|
- `->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
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->description(str)`: Set/change the description.
|
- `->description(str)`: Set/change the description.
|
||||||
* `->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` 🚧.
|
- `->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` 🚧.
|
||||||
* `->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
|
- `->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
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->transform(std::string(std::string &), validator_name="",validator_description=")`: Converts the input string into the output string, in-place in the parsed options.
|
- `->transform(std::string(std::string &), validator_name="",validator_description=")`: Converts the input string into the output string, in-place in the parsed options.
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->configurable(false)`: Disable this option from being in a configuration file.
|
- `->configurable(false)`: Disable this option from being in a configuration file.
|
||||||
* `->capture_default_str()`: Store the current value attached and display it in the help string.
|
- `->capture_default_str()`: Store the current value attached and display it in the help string.
|
||||||
* `->default_function(std::string())`: Advanced: Change the function that `capture_default_str()` uses.
|
- `->default_function(std::string())`: Advanced: Change the function that `capture_default_str()` uses.
|
||||||
* `->always_capture_default()`: Always run `capture_default_str()` when creating new options. Only useful on an App's `option_defaults`.
|
- `->always_capture_default()`: Always run `capture_default_str()` when creating new options. Only useful on an App's `option_defaults`.
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->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.
|
- `->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.
|
||||||
* `->run_callback_for_default()`: This will force the option callback to be executed or the variable set when the `default_val` is set.
|
- `->run_callback_for_default()`: This will force the option callback to be executed or the variable set when the `default_val` is set.
|
||||||
* `->option_text(string)`: Sets the text between the option name and description.
|
- `->option_text(string)`: Sets the text between the option name and description.
|
||||||
* `->force_callback()`: Causes the option callback or value set to be triggered even if the option was not present in parsing.
|
- `->force_callback()`: Causes the option callback or value set to be triggered even if the option was not present in parsing.
|
||||||
* `->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 🆕.
|
- `->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 🆕.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
On the command line, options can be given as:
|
On the command line, options can be given as:
|
||||||
|
|
||||||
* `-a` (flag)
|
- `-a` (flag)
|
||||||
* `-abc` (flags can be combined)
|
- `-abc` (flags can be combined)
|
||||||
* `-f filename` (option)
|
- `-f filename` (option)
|
||||||
* `-ffilename` (no space required)
|
- `-ffilename` (no space required)
|
||||||
* `-abcf filename` (flags and option can be combined)
|
- `-abcf filename` (flags and option can be combined)
|
||||||
* `--long` (long flag)
|
- `--long` (long flag)
|
||||||
* `--long_flag=true` (long flag with equals to override default value)
|
- `--long_flag=true` (long flag with equals to override default value)
|
||||||
* `--file filename` (space)
|
- `--file filename` (space)
|
||||||
* `--file=filename` (equals)
|
- `--file=filename` (equals)
|
||||||
|
|
||||||
If `allow_windows_style_options()` is specified in the application or subcommand options can also be given as:
|
If `allow_windows_style_options()` is specified in the application or subcommand options can also be given as:
|
||||||
|
|
||||||
* `/a` (flag)
|
- `/a` (flag)
|
||||||
* `/f filename` (option)
|
- `/f filename` (option)
|
||||||
* `/long` (long flag)
|
- `/long` (long flag)
|
||||||
* `/file filename` (space)
|
- `/file filename` (space)
|
||||||
* `/file:filename` (colon)
|
- `/file:filename` (colon)
|
||||||
* `/long_flag:false` (long flag with : to override the default value)
|
- `/long_flag:false` (long flag with : to override the default value)
|
||||||
* Windows style options do not allow combining short options or values not separated from the short option like with `-` options
|
- Windows style options do not allow combining short options or values not separated from the short option like with `-` options
|
||||||
|
|
||||||
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()`.
|
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()`.
|
||||||
|
|
||||||
@ -416,27 +416,28 @@ If `--` is present in the command line that does not end an unlimited option, th
|
|||||||
everything after that is positional only.
|
everything after that is positional only.
|
||||||
|
|
||||||
#### Validators
|
#### Validators
|
||||||
|
|
||||||
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`.
|
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`.
|
||||||
|
|
||||||
CLI11 has several Validators built-in that perform some common checks
|
CLI11 has several Validators built-in that perform some common checks
|
||||||
|
|
||||||
* `CLI::IsMember(...)`: Require an option be a member of a given set. See [Transforming Validators](#transforming-validators) for more details.
|
- `CLI::IsMember(...)`: Require an option be a member of a given set. See [Transforming Validators](#transforming-validators) for more details.
|
||||||
* `CLI::Transformer(...)`: Modify the input using a map. See [Transforming Validators](#transforming-validators) for more details.
|
- `CLI::Transformer(...)`: Modify the input using a map. See [Transforming Validators](#transforming-validators) for more details.
|
||||||
* `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.
|
- `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.
|
||||||
* `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`).
|
- `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`).
|
||||||
* `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.
|
- `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.
|
||||||
* `CLI::ExistingFile`: Requires that the file exists if given.
|
- `CLI::ExistingFile`: Requires that the file exists if given.
|
||||||
* `CLI::ExistingDirectory`: Requires that the directory exists.
|
- `CLI::ExistingDirectory`: Requires that the directory exists.
|
||||||
* `CLI::ExistingPath`: Requires that the path (file or directory) exists.
|
- `CLI::ExistingPath`: Requires that the path (file or directory) exists.
|
||||||
* `CLI::NonexistentPath`: Requires that the path does not exist.
|
- `CLI::NonexistentPath`: Requires that the path does not exist.
|
||||||
* `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
|
- `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
|
||||||
* `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.
|
- `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.
|
||||||
* `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.
|
- `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.
|
||||||
* `CLI::PositiveNumber`: Requires the number be greater than 0
|
- `CLI::PositiveNumber`: Requires the number be greater than 0
|
||||||
* `CLI::NonNegativeNumber`: Requires the number be greater or equal to 0
|
- `CLI::NonNegativeNumber`: Requires the number be greater or equal to 0
|
||||||
* `CLI::Number`: Requires the input be a number.
|
- `CLI::Number`: Requires the input be a number.
|
||||||
* `CLI::ValidIPV4`: Requires that the option be a valid IPv4 string e.g. `'255.255.255.255'`, `'10.1.1.7'`.
|
- `CLI::ValidIPV4`: Requires that the option be a valid IPv4 string e.g. `'255.255.255.255'`, `'10.1.1.7'`.
|
||||||
* `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.
|
- `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.
|
||||||
|
|
||||||
These Validators can be used by simply passing the name into the `check` or `transform` methods on an option
|
These Validators can be used by simply passing the name into the `check` or `transform` methods on an option
|
||||||
|
|
||||||
@ -463,30 +464,30 @@ will produce a check for a number less than or equal to 0.
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* `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`
|
- `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`
|
||||||
* 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.
|
- 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.
|
||||||
|
|
||||||
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`:
|
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`:
|
||||||
|
|
||||||
* `CLI::IsMember({"choice1", "choice2"})`: Select from exact match to choices.
|
- `CLI::IsMember({"choice1", "choice2"})`: Select from exact match to choices.
|
||||||
* `CLI::IsMember({"choice1", "choice2"}, CLI::ignore_case, CLI::ignore_underscore)`: Match things like `Choice_1`, too.
|
- `CLI::IsMember({"choice1", "choice2"}, CLI::ignore_case, CLI::ignore_underscore)`: Match things like `Choice_1`, too.
|
||||||
* `CLI::IsMember(std::set<int>({2,3,4}))`: Most containers and types work; you just need `std::begin`, `std::end`, and `::value_type`.
|
- `CLI::IsMember(std::set<int>({2,3,4}))`: Most containers and types work; you just need `std::begin`, `std::end`, and `::value_type`.
|
||||||
* `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.
|
- `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.
|
||||||
* `auto p = std::make_shared<std::vector<std::string>>(std::initializer_list<std::string>("one", "two")); CLI::IsMember(p)`: You can modify `p` later.
|
- `auto p = std::make_shared<std::vector<std::string>>(std::initializer_list<std::string>("one", "two")); CLI::IsMember(p)`: You can modify `p` later.
|
||||||
* 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.
|
- 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.
|
||||||
|
|
||||||
After specifying a map of options, you can also specify "filter" just like in `CLI::IsMember`.
|
After specifying a map of options, you can also specify "filter" just like in `CLI::IsMember`.
|
||||||
Here are some examples (`Transformer` and `CheckedTransformer` are interchangeable in the examples)
|
Here are some examples (`Transformer` and `CheckedTransformer` are interchangeable in the examples)
|
||||||
of `Transformer`:
|
of `Transformer`:
|
||||||
|
|
||||||
* `CLI::Transformer({{"key1", "map1"},{"key2","map2"}})`: Select from key values and produce map values.
|
- `CLI::Transformer({{"key1", "map1"},{"key2","map2"}})`: Select from key values and produce map values.
|
||||||
* `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.
|
- `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.
|
||||||
* `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.
|
- `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.
|
||||||
* `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>>`
|
- `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>>`
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
* `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.
|
- `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.
|
||||||
|
|
||||||
##### Validator operations
|
##### Validator operations
|
||||||
|
|
||||||
@ -548,19 +549,19 @@ opt->get_validator(index);
|
|||||||
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.
|
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.
|
||||||
Validators have a few functions to query the current values:
|
Validators have a few functions to query the current values:
|
||||||
|
|
||||||
* `get_description()`: Will return a description string
|
- `get_description()`: Will return a description string
|
||||||
* `get_name()`: Will return the Validator name
|
- `get_name()`: Will return the Validator name
|
||||||
* `get_active()`: Will return the current active state, true if the Validator is active.
|
- `get_active()`: Will return the current active state, true if the Validator is active.
|
||||||
* `get_application_index()`: Will return the current application index.
|
- `get_application_index()`: Will return the current application index.
|
||||||
* `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.
|
- `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.
|
||||||
|
|
||||||
#### Getting results
|
#### Getting results
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
* `->results()`: Retrieves a vector of strings with all the results in the order they were given.
|
- `->results()`: Retrieves a vector of strings with all the results in the order they were given.
|
||||||
* `->results(variable_to_bind_to)`: Gets the results according to the MultiOptionPolicy and converts them just like the `add_option_function` with a variable.
|
- `->results(variable_to_bind_to)`: Gets the results according to the MultiOptionPolicy and converts them just like the `add_option_function` with a variable.
|
||||||
* `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.
|
- `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.
|
||||||
|
|
||||||
### Subcommands
|
### Subcommands
|
||||||
|
|
||||||
@ -585,61 +586,61 @@ Nameless subcommands function a similarly to groups in the main `App`. See [Opti
|
|||||||
|
|
||||||
There are several options that are supported on the main app and subcommands and option_groups. These are:
|
There are several options that are supported on the main app and subcommands and option_groups. These are:
|
||||||
|
|
||||||
* `.ignore_case()`: Ignore the case of this subcommand. Inherited by added subcommands, so is usually used on the main `App`.
|
- `.ignore_case()`: Ignore the case of this subcommand. Inherited by added subcommands, so is usually used on the main `App`.
|
||||||
* `.ignore_underscore()`: Ignore any underscores in the subcommand name. Inherited by added subcommands, so is usually used on the main `App`.
|
- `.ignore_underscore()`: Ignore any underscores in the subcommand name. Inherited by added subcommands, so is usually used on the main `App`.
|
||||||
* `.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`.
|
- `.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`.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.disable()`: Specify that the subcommand is disabled, if given with a bool value it will enable or disable the subcommand or option group.
|
- `.disable()`: Specify that the subcommand is disabled, if given with a bool value it will enable or disable the subcommand or option group.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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
|
- `.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
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.require_option()`: Require 1 or more options or option groups be used.
|
- `.require_option()`: Require 1 or more options or option groups be used.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.require_option(min, max)`: Explicitly set min and max allowed options or option groups. Setting `max` to 0 implies unlimited options.
|
- `.require_option(min, max)`: Explicitly set min and max allowed options or option groups. Setting `max` to 0 implies unlimited options.
|
||||||
* `.require_subcommand()`: Require 1 or more subcommands.
|
- `.require_subcommand()`: Require 1 or more subcommands.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.require_subcommand(min, max)`: Explicitly set min and max allowed subcommands. Setting `max` to 0 is unlimited.
|
- `.require_subcommand(min, max)`: Explicitly set min and max allowed subcommands. Setting `max` to 0 is unlimited.
|
||||||
* `.add_subcommand(name="", description="")`: Add a subcommand, returns a pointer to the internally stored subcommand.
|
- `.add_subcommand(name="", description="")`: Add a subcommand, returns a pointer to the internally stored subcommand.
|
||||||
* `.add_subcommand(shared_ptr<App>)`: Add a subcommand by shared_ptr, returns a pointer to the internally stored subcommand.
|
- `.add_subcommand(shared_ptr<App>)`: Add a subcommand by shared_ptr, returns a pointer to the internally stored subcommand.
|
||||||
* `.remove_subcommand(App)`: Remove a subcommand from the app or subcommand.
|
- `.remove_subcommand(App)`: Remove a subcommand from the app or subcommand.
|
||||||
* `.got_subcommand(App_or_name)`: Check to see if a subcommand was received on the command line.
|
- `.got_subcommand(App_or_name)`: Check to see if a subcommand was received on the command line.
|
||||||
* `.get_subcommands(filter)`: The list of subcommands that match a particular filter function.
|
- `.get_subcommands(filter)`: The list of subcommands that match a particular filter function.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.get_parent()`: Get the parent App or `nullptr` if called on main App.
|
- `.get_parent()`: Get the parent App or `nullptr` if called on main App.
|
||||||
* `.get_option(name)`: Get an option pointer by option name will throw if the specified option is not available, nameless subcommands are also searched
|
- `.get_option(name)`: Get an option pointer by option name will throw if the specified option is not available, nameless subcommands are also searched
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.get_options(filter)`: Get the list of all defined option pointers (useful for processing the app for custom output formats).
|
- `.get_options(filter)`: Get the list of all defined option pointers (useful for processing the app for custom output formats).
|
||||||
* `.parse_order()`: Get the list of option pointers in the order they were parsed (including duplicates).
|
- `.parse_order()`: Get the list of option pointers in the order they were parsed (including duplicates).
|
||||||
* `.formatter(fmt)`: Set a formatter, with signature `std::string(const App*, std::string, AppFormatMode)`. See Formatting for more details.
|
- `.formatter(fmt)`: Set a formatter, with signature `std::string(const App*, std::string, AppFormatMode)`. See Formatting for more details.
|
||||||
* `.description(str)`: Set/change the description.
|
- `.description(str)`: Set/change the description.
|
||||||
* `.get_description()`: Access the description.
|
- `.get_description()`: Access the description.
|
||||||
* `.alias(str)`: set an alias for the subcommand, this allows subcommands to be called by more than one name.
|
- `.alias(str)`: set an alias for the subcommand, this allows subcommands to be called by more than one name.
|
||||||
* `.parsed()`: True if this subcommand was given on the command line.
|
- `.parsed()`: True if this subcommand was given on the command line.
|
||||||
* `.count()`: Returns the number of times the subcommand was called.
|
- `.count()`: Returns the number of times the subcommand was called.
|
||||||
* `.count(option_name)`: Returns the number of times a particular option was called.
|
- `.count(option_name)`: Returns the number of times a particular option was called.
|
||||||
* `.count_all()`: Returns the total number of arguments a particular subcommand processed, on the main App it returns the total number of processed commands.
|
- `.count_all()`: Returns the total number of arguments a particular subcommand processed, on the main App it returns the total number of processed commands.
|
||||||
* `.name(name)`: Add or change the name.
|
- `.name(name)`: Add or change the name.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.allow_extras()`: Do not throw an error if extra arguments are left over.
|
- `.allow_extras()`: Do not throw an error if extra arguments are left over.
|
||||||
* `.positionals_at_end()`: Specify that positional arguments occur as the last arguments and throw an error if an unexpected positional is encountered.
|
- `.positionals_at_end()`: Specify that positional arguments occur as the last arguments and throw an error if an unexpected positional is encountered.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.footer(message)`: Set text to appear at the bottom of the help string.
|
- `.footer(message)`: Set text to appear at the bottom of the help string.
|
||||||
* `.footer(std::string())`: Set a callback to generate a string that will appear at the end of the help string.
|
- `.footer(std::string())`: Set a callback to generate a string that will appear at the end of the help string.
|
||||||
* `.set_help_flag(name, message)`: Set the help flag name and message, returns a pointer to the created option.
|
- `.set_help_flag(name, message)`: Set the help flag name and message, returns a pointer to the created option.
|
||||||
* `.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.
|
- `.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.
|
||||||
* `.set_help_all_flag(name, message)`: Set the help all flag name and message, returns a pointer to the created option. Expands subcommands.
|
- `.set_help_all_flag(name, message)`: Set the help all flag name and message, returns a pointer to the created option. Expands subcommands.
|
||||||
* `.failure_message(func)`: Set the failure message function. Two provided: `CLI::FailureMessage::help` and `CLI::FailureMessage::simple` (the default).
|
- `.failure_message(func)`: Set the failure message function. Two provided: `CLI::FailureMessage::help` and `CLI::FailureMessage::simple` (the default).
|
||||||
* `.group(name)`: Set a group name, defaults to `"Subcommands"`. Setting `""` will be hide the subcommand.
|
- `.group(name)`: Set a group name, defaults to `"Subcommands"`. Setting `""` will be hide the subcommand.
|
||||||
* `[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.
|
- `[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.
|
||||||
|
|
||||||
> 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.
|
> 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.
|
||||||
|
|
||||||
@ -665,14 +666,14 @@ Then the command line is given as
|
|||||||
program --opt1 opt1_val sub1 --sub1opt --sub1optb val sub2 --sub2opt sub1 --sub1opt2 sub2 --sub2opt2 val
|
program --opt1 opt1_val sub1 --sub1opt --sub1optb val sub2 --sub2opt sub1 --sub1opt2 sub2 --sub2opt2 val
|
||||||
```
|
```
|
||||||
|
|
||||||
* `pa` will be called prior to parsing any values with an argument of 13.
|
- `pa` will be called prior to parsing any values with an argument of 13.
|
||||||
* `pc1` will be called immediately after processing the `sub1` command with a value of 10.
|
- `pc1` will be called immediately after processing the `sub1` command with a value of 10.
|
||||||
* `c1` will be called when the `sub2` command is encountered.
|
- `c1` will be called when the `sub2` command is encountered.
|
||||||
* `pc2` will be called with value of 6 after the `sub2` command is encountered.
|
- `pc2` will be called with value of 6 after the `sub2` command is encountered.
|
||||||
* `c1` will be called again after the second `sub2` command is encountered.
|
- `c1` will be called again after the second `sub2` command is encountered.
|
||||||
* `ac1` will be called after processing of all arguments
|
- `ac1` will be called after processing of all arguments
|
||||||
* `c2` will be called once after processing all arguments.
|
- `c2` will be called once after processing all arguments.
|
||||||
* `ac2` will be called last after completing all lower level callbacks have been executed.
|
- `ac2` will be called last after completing all lower level callbacks have been executed.
|
||||||
|
|
||||||
A subcommand is considered terminated when one of the following conditions are met.
|
A subcommand is considered terminated when one of the following conditions are met.
|
||||||
|
|
||||||
@ -920,28 +921,28 @@ The API is [documented here][api-docs]. Also see the [CLI11 tutorial GitBook][gi
|
|||||||
|
|
||||||
Several short examples of different features are included in the repository. A brief description of each is included here
|
Several short examples of different features are included in the repository. A brief description of each is included here
|
||||||
|
|
||||||
* [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.
|
- [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.
|
||||||
* [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
|
- [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
|
||||||
* [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
|
- [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
|
||||||
* [enum](https://github.com/CLIUtils/CLI11/blob/main/examples/enum.cpp): Using enumerations in an option, and the use of [CheckedTransformer](#transforming-validators)
|
- [enum](https://github.com/CLIUtils/CLI11/blob/main/examples/enum.cpp): Using enumerations in an option, and the use of [CheckedTransformer](#transforming-validators)
|
||||||
* [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.
|
- [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.
|
||||||
* [formatter](https://github.com/CLIUtils/CLI11/blob/main/examples/formatter.cpp): Illustrating usage of a custom formatter
|
- [formatter](https://github.com/CLIUtils/CLI11/blob/main/examples/formatter.cpp): Illustrating usage of a custom formatter
|
||||||
* [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
|
- [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
|
||||||
* [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.
|
- [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.
|
||||||
* [json](https://github.com/CLIUtils/CLI11/blob/main/examples/json.cpp): Using JSON as a config file parser
|
- [json](https://github.com/CLIUtils/CLI11/blob/main/examples/json.cpp): Using JSON as a config file parser
|
||||||
* [modhelp](https://github.com/CLIUtils/CLI11/blob/main/examples/modhelp.cpp): How to modify the help flag to do something other than default
|
- [modhelp](https://github.com/CLIUtils/CLI11/blob/main/examples/modhelp.cpp): How to modify the help flag to do something other than default
|
||||||
* [nested](https://github.com/CLIUtils/CLI11/blob/main/examples/nested.cpp): Nested subcommands
|
- [nested](https://github.com/CLIUtils/CLI11/blob/main/examples/nested.cpp): Nested subcommands
|
||||||
* [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
|
- [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
|
||||||
* [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)
|
- [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)
|
||||||
* [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)
|
- [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)
|
||||||
* [prefix_command](https://github.com/CLIUtils/CLI11/blob/main/examples/prefix_command.cpp): Illustrating use of the `prefix_command` flag.
|
- [prefix_command](https://github.com/CLIUtils/CLI11/blob/main/examples/prefix_command.cpp): Illustrating use of the `prefix_command` flag.
|
||||||
* [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)
|
- [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)
|
||||||
* [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)
|
- [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)
|
||||||
* [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
|
- [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
|
||||||
* [subcom_help](https://github.com/CLIUtils/CLI11/blob/main/examples/subcom_help.cpp): Configuring help for subcommands
|
- [subcom_help](https://github.com/CLIUtils/CLI11/blob/main/examples/subcom_help.cpp): Configuring help for subcommands
|
||||||
* [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.
|
- [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.
|
||||||
* [subcommands](https://github.com/CLIUtils/CLI11/blob/main/examples/subcommands.cpp): Short example of subcommands
|
- [subcommands](https://github.com/CLIUtils/CLI11/blob/main/examples/subcommands.cpp): Short example of subcommands
|
||||||
* [validators](https://github.com/CLIUtils/CLI11/blob/main/examples/validators.cpp): Example illustrating use of validators
|
- [validators](https://github.com/CLIUtils/CLI11/blob/main/examples/validators.cpp): Example illustrating use of validators
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -1024,6 +1025,7 @@ This project was created by [Henry Schreiner](https://github.com/henryiii) and m
|
|||||||
|
|
||||||
<!-- markdownlint-enable -->
|
<!-- markdownlint-enable -->
|
||||||
<!-- prettier-ignore-end -->
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||||
|
|
||||||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
||||||
@ -1093,7 +1095,7 @@ CLI11 was developed at the [University of Cincinnati][] to support of the [GooFi
|
|||||||
[cli]: https://codesynthesis.com/projects/cli/
|
[cli]: https://codesynthesis.com/projects/cli/
|
||||||
[single file libs]: https://github.com/nothings/single_file_libs/blob/master/README.md
|
[single file libs]: https://github.com/nothings/single_file_libs/blob/master/README.md
|
||||||
[codacy-badge]: https://app.codacy.com/project/badge/Grade/2796b969c1b54321a02ad08affec0800
|
[codacy-badge]: https://app.codacy.com/project/badge/Grade/2796b969c1b54321a02ad08affec0800
|
||||||
[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
|
[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
|
||||||
[hunter]: https://docs.hunter.sh/en/latest/packages/pkg/CLI11.html
|
[hunter]: https://docs.hunter.sh/en/latest/packages/pkg/CLI11.html
|
||||||
[standard readme style]: https://github.com/RichardLitt/standard-readme
|
[standard readme style]: https://github.com/RichardLitt/standard-readme
|
||||||
[argparse]: https://github.com/p-ranav/argparse
|
[argparse]: https://github.com/p-ranav/argparse
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- main
|
- main
|
||||||
- 'v*'
|
- "v*"
|
||||||
|
|
||||||
pr:
|
pr:
|
||||||
- main
|
- main
|
||||||
- 'v*'
|
- "v*"
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
cli11.single: ON
|
cli11.single: ON
|
||||||
@ -19,7 +19,6 @@ variables:
|
|||||||
CMAKE_BUILD_PARALLEL_LEVEL: 4
|
CMAKE_BUILD_PARALLEL_LEVEL: 4
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
- job: ClangTidy
|
- job: ClangTidy
|
||||||
variables:
|
variables:
|
||||||
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"
|
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"
|
||||||
@ -28,7 +27,7 @@ jobs:
|
|||||||
cli11.single: OFF
|
cli11.single: OFF
|
||||||
CMAKE_BUILD_PARALLEL_LEVEL: 1
|
CMAKE_BUILD_PARALLEL_LEVEL: 1
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: "ubuntu-latest"
|
||||||
container: silkeh/clang:8
|
container: silkeh/clang:8
|
||||||
steps:
|
steps:
|
||||||
- template: .ci/azure-cmake.yml
|
- template: .ci/azure-cmake.yml
|
||||||
@ -38,7 +37,7 @@ jobs:
|
|||||||
|
|
||||||
- job: CppLint
|
- job: CppLint
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: "ubuntu-latest"
|
||||||
container: sharaku/cpplint:latest
|
container: sharaku/cpplint:latest
|
||||||
steps:
|
steps:
|
||||||
- bash: cpplint --counting=detailed --recursive examples include/CLI tests
|
- bash: cpplint --counting=detailed --recursive examples include/CLI tests
|
||||||
@ -49,25 +48,25 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
Linux14:
|
Linux14:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: "ubuntu-latest"
|
||||||
macOS17:
|
macOS17:
|
||||||
vmImage: 'macOS-latest'
|
vmImage: "macOS-latest"
|
||||||
cli11.std: 17
|
cli11.std: 17
|
||||||
macOS11:
|
macOS11:
|
||||||
vmImage: 'macOS-latest'
|
vmImage: "macOS-latest"
|
||||||
cli11.std: 11
|
cli11.std: 11
|
||||||
Windows17:
|
Windows17:
|
||||||
vmImage: 'vs2017-win2016'
|
vmImage: "vs2017-win2016"
|
||||||
cli11.std: 17
|
cli11.std: 17
|
||||||
Windows11:
|
Windows11:
|
||||||
vmImage: 'vs2017-win2016'
|
vmImage: "vs2017-win2016"
|
||||||
cli11.std: 11
|
cli11.std: 11
|
||||||
Windowslatest:
|
Windowslatest:
|
||||||
vmImage: 'windows-2019'
|
vmImage: "windows-2019"
|
||||||
cli11.std: 20
|
cli11.std: 20
|
||||||
cli11.options: -DCMAKE_CXX_FLAGS="/std:c++latest /EHsc"
|
cli11.options: -DCMAKE_CXX_FLAGS="/std:c++latest /EHsc"
|
||||||
Linux17nortti:
|
Linux17nortti:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: "ubuntu-latest"
|
||||||
cli11.std: 17
|
cli11.std: 17
|
||||||
cli11.options: -DCMAKE_CXX_FLAGS="-fno-rtti"
|
cli11.options: -DCMAKE_CXX_FLAGS="-fno-rtti"
|
||||||
pool:
|
pool:
|
||||||
@ -78,11 +77,11 @@ jobs:
|
|||||||
|
|
||||||
- job: Meson
|
- job: Meson
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: '3.7'
|
versionSpec: "3.7"
|
||||||
- script: python3 -m pip install meson ninja
|
- script: python3 -m pip install meson ninja
|
||||||
displayName: install meson
|
displayName: install meson
|
||||||
- script: mkdir tests/mesonTest/subprojects
|
- script: mkdir tests/mesonTest/subprojects
|
||||||
@ -101,7 +100,7 @@ jobs:
|
|||||||
variables:
|
variables:
|
||||||
cli11.single: OFF
|
cli11.single: OFF
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: "ubuntu-latest"
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
gcc9:
|
gcc9:
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
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][].
|
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][].
|
||||||
|
|
||||||
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][].
|
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][].
|
||||||
|
|
||||||
> Feel free to contribute to [this documentation here][CLI11Tutorial] if something can be improved!
|
> Feel free to contribute to [this documentation here][cli11tutorial] if something can be improved!
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ You can use subcommands, as well. Subcommands support callback lambda functions
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
[goofit]: https://github.com/GooFit/GooFit
|
[goofit]: https://github.com/GooFit/GooFit
|
||||||
[diana/hep]: https://diana-hep.org
|
[diana/hep]: https://diana-hep.org
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
# Summary
|
# Summary
|
||||||
|
|
||||||
* [Introduction](/README.md)
|
- [Introduction](/README.md)
|
||||||
* [Installation](/chapters/installation.md)
|
- [Installation](/chapters/installation.md)
|
||||||
* [Basics](/chapters/basics.md)
|
- [Basics](/chapters/basics.md)
|
||||||
* [Flags](/chapters/flags.md)
|
- [Flags](/chapters/flags.md)
|
||||||
* [Options](/chapters/options.md)
|
- [Options](/chapters/options.md)
|
||||||
* [Validators](/chapters/validators.md)
|
- [Validators](/chapters/validators.md)
|
||||||
* [Subcommands and the App](/chapters/subcommands.md)
|
- [Subcommands and the App](/chapters/subcommands.md)
|
||||||
* [An advanced example](/chapters/an-advanced-example.md)
|
- [An advanced example](/chapters/an-advanced-example.md)
|
||||||
* [Configuration files](/chapters/config.md)
|
- [Configuration files](/chapters/config.md)
|
||||||
* [Formatting help output](/chapters/formatting.md)
|
- [Formatting help output](/chapters/formatting.md)
|
||||||
* [Toolkits](/chapters/toolkits.md)
|
- [Toolkits](/chapters/toolkits.md)
|
||||||
* [Advanced topics](/chapters/advanced-topics.md)
|
- [Advanced topics](/chapters/advanced-topics.md)
|
||||||
* [Internals](/chapters/internals.md)
|
- [Internals](/chapters/internals.md)
|
||||||
|
@ -2,11 +2,7 @@
|
|||||||
"title": "CLI11 Tutorial",
|
"title": "CLI11 Tutorial",
|
||||||
"description": "A set of examples and detailed information about CLI11",
|
"description": "A set of examples and detailed information about CLI11",
|
||||||
"author": "Henry Schreiner",
|
"author": "Henry Schreiner",
|
||||||
"plugins": [
|
"plugins": ["include-codeblock", "term", "hints"],
|
||||||
"include-codeblock",
|
|
||||||
"term",
|
|
||||||
"hints"
|
|
||||||
],
|
|
||||||
"pluginsConfig": {
|
"pluginsConfig": {
|
||||||
"include-codeblock": {
|
"include-codeblock": {
|
||||||
"unindent": true,
|
"unindent": true,
|
||||||
|
@ -176,15 +176,15 @@ std::string configSection;
|
|||||||
|
|
||||||
These can be modified via setter functions
|
These can be modified via setter functions
|
||||||
|
|
||||||
* `ConfigBase *comment(char cchar)`: Specify the character to start a comment block
|
- `ConfigBase *comment(char cchar)`: Specify the character to start a comment block
|
||||||
* `ConfigBase *arrayBounds(char aStart, char aEnd)`: Specify the start and end characters for an array
|
- `ConfigBase *arrayBounds(char aStart, char aEnd)`: Specify the start and end characters for an array
|
||||||
* `ConfigBase *arrayDelimiter(char aSep)`: Specify the delimiter character for an array
|
- `ConfigBase *arrayDelimiter(char aSep)`: Specify the delimiter character for an array
|
||||||
* `ConfigBase *valueSeparator(char vSep)`: Specify the delimiter between a name and value
|
- `ConfigBase *valueSeparator(char vSep)`: Specify the delimiter between a name and value
|
||||||
* `ConfigBase *quoteCharacter(char qString, char qChar)` :specify the characters to use around strings and single characters
|
- `ConfigBase *quoteCharacter(char qString, char qChar)` :specify the characters to use around strings and single characters
|
||||||
* `ConfigBase *maxLayers(uint8_t layers)` : specify the maximum number of parent layers to process. This is useful to limit processing for larger config files
|
- `ConfigBase *maxLayers(uint8_t layers)` : specify the maximum number of parent layers to process. This is useful to limit processing for larger config files
|
||||||
* `ConfigBase *parentSeparator(char sep)` : specify the character to separate parent layers from options
|
- `ConfigBase *parentSeparator(char sep)` : specify the character to separate parent layers from options
|
||||||
* `ConfigBase *section(const std::string §ionName)` : specify the section name to use to get the option values, only this section will be processed
|
- `ConfigBase *section(const std::string §ionName)` : specify the section name to use to get the option values, only this section will be processed
|
||||||
* `ConfigBase *index(uint16_t sectionIndex)` : specify an index section to use for processing if multiple TOML sections of the same name are present `[[section]]`
|
- `ConfigBase *index(uint16_t sectionIndex)` : specify an index section to use for processing if multiple TOML sections of the same name are present `[[section]]`
|
||||||
|
|
||||||
For example, to specify reading a configure file that used `:` to separate name and values:
|
For example, to specify reading a configure file that used `:` to separate name and values:
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ In CLI11, you can control the output of the help printout in full or in part. Th
|
|||||||
There are several configuration options that you can set:
|
There are several configuration options that you can set:
|
||||||
|
|
||||||
| Set method | Description | Availability |
|
| Set method | Description | Availability |
|
||||||
|------------|-------------|--------------|
|
| --------------------- | -------------------------------- | ------------ |
|
||||||
| `column_width(width)` | The width of the columns | Both |
|
| `column_width(width)` | The width of the columns | Both |
|
||||||
| `label(key, value)` | Set a label to a different value | Both |
|
| `label(key, value)` | Set a label to a different value | Both |
|
||||||
|
|
||||||
@ -69,5 +69,5 @@ make_option_name(o,p) make_option_desc(o)
|
|||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
* `*1`: This signature depends on whether the call is from a positional or optional.
|
- `*1`: This signature depends on whether the call is from a positional or optional.
|
||||||
* `o` is opt pointer, `p` is true if positional.
|
- `o` is opt pointer, `p` is true if positional.
|
||||||
|
@ -81,7 +81,7 @@ Total Test time (real) = 0.34 sec
|
|||||||
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.
|
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.
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
|--------|-------------|
|
| ----------------------------- | ----------------------------------------------------------------------------------------------- |
|
||||||
| `CLI11_SINGLE_FILE=ON` | Build the `CLI11.hpp` file from the sources. Requires Python (version 3 or 2.7). |
|
| `CLI11_SINGLE_FILE=ON` | Build the `CLI11.hpp` file from the sources. Requires Python (version 3 or 2.7). |
|
||||||
| `CLI11_SINGLE_FILE_TESTS=OFF` | Run the tests on the generated single file version as well |
|
| `CLI11_SINGLE_FILE_TESTS=OFF` | Run the tests on the generated single file version as well |
|
||||||
| `CLI11_EXAMPLES=ON` | Build the example programs. |
|
| `CLI11_EXAMPLES=ON` | Build the example programs. |
|
||||||
|
@ -19,7 +19,7 @@ app.add_option("-i", int_option, "Optional description")->capture_default_str();
|
|||||||
You can use any C++ int-like type, not just `int`. CLI11 understands the following categories of types:
|
You can use any C++ int-like type, not just `int`. CLI11 understands the following categories of types:
|
||||||
|
|
||||||
| Type | CLI11 |
|
| Type | CLI11 |
|
||||||
|-------------|-------|
|
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| number like | Integers, floats, bools, or any type that can be constructed from an integer or floating point number. Accepts common numerical strings like `0xFF` as well as octal, and decimal |
|
| number like | Integers, floats, bools, or any type that can be constructed from an integer or floating point number. Accepts common numerical strings like `0xFF` as well as octal, and decimal |
|
||||||
| string-like | std::string, or anything that can be constructed from or assigned a std::string |
|
| string-like | std::string, or anything that can be constructed from or assigned a std::string |
|
||||||
| char | For a single char, single string values are accepted, otherwise longer strings are treated as integral values and a conversion is attempted |
|
| char | For a single char, single string values are accepted, otherwise longer strings are treated as integral values and a conversion is attempted |
|
||||||
@ -56,7 +56,7 @@ This would make two short option aliases, two long option alias, and the option
|
|||||||
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.
|
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.
|
||||||
|
|
||||||
| Separate names | Combined names |
|
| Separate names | Combined names |
|
||||||
|-------------------|-----------------|
|
| ----------------- | -------------- |
|
||||||
| `--vec 1 --vec 2` | `--vec 1 2` |
|
| `--vec 1 --vec 2` | `--vec 1 2` |
|
||||||
|
|
||||||
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.
|
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.
|
||||||
@ -155,7 +155,7 @@ will result in a requirement for 2 integers on each invocation and absorb an unl
|
|||||||
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:
|
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:
|
||||||
|
|
||||||
| Modifier | Description |
|
| Modifier | Description |
|
||||||
|----------|-------------|
|
| ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `->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. |
|
| `->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. |
|
||||||
| `->expected(N)` | Take `N` values instead of as many as possible, mainly for vector args. |
|
| `->expected(N)` | Take `N` values instead of as many as possible, mainly for vector args. |
|
||||||
| `->expected(Nmin,Nmax)` | Take between `Nmin` and `Nmax` values. |
|
| `->expected(Nmin,Nmax)` | Take between `Nmin` and `Nmax` values. |
|
||||||
@ -179,7 +179,7 @@ When you call `add_option`, you get a pointer to the added option. You can use t
|
|||||||
| `->join(delim)` | sets `->multi_option_policy(CLI::MultiOptionPolicy::Join)`, which uses `delim` to join all arguments into a single string output. this also sets the delimiter |
|
| `->join(delim)` | sets `->multi_option_policy(CLI::MultiOptionPolicy::Join)`, which uses `delim` to join all arguments into a single string output. this also sets the delimiter |
|
||||||
| `->check(Validator)` | perform a check on the returned results to verify they meet some criteria. See [Validators](./validators.md) for more info |
|
| `->check(Validator)` | perform a check on the returned results to verify they meet some criteria. See [Validators](./validators.md) for more info |
|
||||||
| `->transform(Validator)` | Run a transforming validator on each value passed. See [Validators](./validators.md) for more info |
|
| `->transform(Validator)` | Run a transforming validator on each value passed. See [Validators](./validators.md) for more info |
|
||||||
| `->each(void(std::string))` | Run a function on each parsed value, *in order*. |
|
| `->each(void(std::string))` | Run a function on each parsed value, _in order_. |
|
||||||
| `->default_str(string)` | set a default string for use in the help and as a default value if no arguments are passed and a value is requested |
|
| `->default_str(string)` | set a default string for use in the help and as a default value if no arguments are passed and a value is requested |
|
||||||
| `->default_function(std::string())` | Advanced: Change the function that `capture_default_str()` uses. |
|
| `->default_function(std::string())` | Advanced: Change the function that `capture_default_str()` uses. |
|
||||||
| `->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). |
|
| `->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). |
|
||||||
@ -209,15 +209,15 @@ if(* opt)
|
|||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
* `group`: The group name starts as "Options"
|
- `group`: The group name starts as "Options"
|
||||||
* `required`: If the option must be given. Defaults to `false`. Is ignored for flags.
|
- `required`: If the option must be given. Defaults to `false`. Is ignored for flags.
|
||||||
* `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.
|
- `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.
|
||||||
* `ignore_case`: Allow any mixture of cases for the option or flag name
|
- `ignore_case`: Allow any mixture of cases for the option or flag name
|
||||||
* `ignore_underscore`: Allow any number of underscores in the option or flag name
|
- `ignore_underscore`: Allow any number of underscores in the option or flag name
|
||||||
* `configurable`: Specify whether an option can be configured through a config file
|
- `configurable`: Specify whether an option can be configured through a config file
|
||||||
* `disable_flag_override`: do not allow flag values to be overridden on the command line
|
- `disable_flag_override`: do not allow flag values to be overridden on the command line
|
||||||
* `always_capture_default`: specify that the default values should be automatically captured.
|
- `always_capture_default`: specify that the default values should be automatically captured.
|
||||||
* `delimiter`: A delimiter to use for capturing multiple values in a single command line string (e.g. --flag="flag,-flag2,flag3")
|
- `delimiter`: A delimiter to use for capturing multiple values in a single command line string (e.g. --flag="flag,-flag2,flag3")
|
||||||
|
|
||||||
An example of usage:
|
An example of usage:
|
||||||
|
|
||||||
@ -234,12 +234,12 @@ Groups are mostly for visual organization, but an empty string for a group name
|
|||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
* `/a` (flag)
|
- `/a` (flag)
|
||||||
* `/f filename` (option)
|
- `/f filename` (option)
|
||||||
* `/long` (long flag)
|
- `/long` (long flag)
|
||||||
* `/file filename` (space)
|
- `/file filename` (space)
|
||||||
* `/file:filename` (colon)
|
- `/file:filename` (colon)
|
||||||
* `/long_flag:false` (long flag with : to override the default value)
|
- `/long_flag:false` (long flag with : to override the default value)
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@ -316,11 +316,11 @@ will create a hybrid option, that can exist on its own in which case the value "
|
|||||||
|
|
||||||
There are some additional options that can be specified to modify an option for specific cases:
|
There are some additional options that can be specified to modify an option for specific cases:
|
||||||
|
|
||||||
* `->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.
|
- `->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.
|
||||||
|
|
||||||
* `->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.
|
- `->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.
|
||||||
|
|
||||||
* `->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.
|
- `->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.
|
||||||
|
|
||||||
## Unusual circumstances
|
## Unusual circumstances
|
||||||
|
|
||||||
|
@ -73,20 +73,20 @@ example is shown below in the `geet` program.
|
|||||||
|
|
||||||
The following values are inherited when you add a new subcommand. This happens at the point the subcommand is created:
|
The following values are inherited when you add a new subcommand. This happens at the point the subcommand is created:
|
||||||
|
|
||||||
* The name and description for the help flag
|
- The name and description for the help flag
|
||||||
* The footer
|
- The footer
|
||||||
* The failure message printer function
|
- The failure message printer function
|
||||||
* Option defaults
|
- Option defaults
|
||||||
* Allow extras
|
- Allow extras
|
||||||
* Prefix command
|
- Prefix command
|
||||||
* Ignore case
|
- Ignore case
|
||||||
* Ignore underscore
|
- Ignore underscore
|
||||||
* Allow Windows style options
|
- Allow Windows style options
|
||||||
* Fallthrough
|
- Fallthrough
|
||||||
* Group name
|
- Group name
|
||||||
* Max required subcommands
|
- Max required subcommands
|
||||||
* validate positional arguments
|
- validate positional arguments
|
||||||
* validate optional arguments
|
- validate optional arguments
|
||||||
|
|
||||||
## Special modes
|
## Special modes
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
There are two forms of validators:
|
There are two forms of validators:
|
||||||
|
|
||||||
* `transform` validators: mutating
|
- `transform` validators: mutating
|
||||||
* `check` validators: non-mutating (recommended unless the parsed string must be mutated)
|
- `check` validators: non-mutating (recommended unless the parsed string must be mutated)
|
||||||
|
|
||||||
A transform validator comes in one form, a function with the signature `std::string(std::string)`.
|
A transform validator comes in one form, a function with the signature `std::string(std::string)`.
|
||||||
The function will take a string and return the modified version of the string. If there is an error,
|
The function will take a string and return the modified version of the string. If there is an error,
|
||||||
@ -42,7 +42,7 @@ If you were not interested in the extra features of Validator, you could simply
|
|||||||
The built-in validators for CLI11 are:
|
The built-in validators for CLI11 are:
|
||||||
|
|
||||||
| Validator | Description |
|
| Validator | Description |
|
||||||
|---------------------|-------------|
|
| ------------------- | ---------------------------------------------------------------------- |
|
||||||
| `ExistingFile` | Check for existing file (returns error message if check fails) |
|
| `ExistingFile` | Check for existing file (returns error message if check fails) |
|
||||||
| `ExistingDirectory` | Check for an existing directory (returns error message if check fails) |
|
| `ExistingDirectory` | Check for an existing directory (returns error message if check fails) |
|
||||||
| `ExistingPath` | Check for an existing path |
|
| `ExistingPath` | Check for an existing path |
|
||||||
@ -52,7 +52,7 @@ The built-in validators for CLI11 are:
|
|||||||
And, the protected members that you can set when you make your own are:
|
And, the protected members that you can set when you make your own are:
|
||||||
|
|
||||||
| Type | Member | Description |
|
| Type | Member | Description |
|
||||||
|------|--------|-------------|
|
| ------------------------------------------- | -------------------- | ---------------------------------------------------------------------- |
|
||||||
| `std::function<std::string(std::string &)>` | `func_` | Core validation function - modifies input and returns "" if successful |
|
| `std::function<std::string(std::string &)>` | `func_` | Core validation function - modifies input and returns "" if successful |
|
||||||
| `std::function<std::string()>` | `desc_function` | Optional description function (uses `description_` instead if not set) |
|
| `std::function<std::string()>` | `desc_function` | Optional description function (uses `description_` instead if not set) |
|
||||||
| `std::string` | `name_` | The name for search purposes |
|
| `std::string` | `name_` | The name for search purposes |
|
||||||
|
@ -5,7 +5,7 @@ This is the Doxygen API documentation for CLI11 parser. There is a friendly intr
|
|||||||
The main classes are:
|
The main classes are:
|
||||||
|
|
||||||
| Name | Where used |
|
| Name | Where used |
|
||||||
|---------------|-------------------------------------|
|
| -------------- | --------------------------------------------------------- |
|
||||||
| CLI::Option | Options, stored in the app |
|
| CLI::Option | Options, stored in the app |
|
||||||
| CLI::App | The main application or subcommands |
|
| CLI::App | The main application or subcommands |
|
||||||
| CLI::Validator | A check that can affect the type name |
|
| CLI::Validator | A check that can affect the type name |
|
||||||
@ -17,6 +17,6 @@ The main classes are:
|
|||||||
Groups of related topics:
|
Groups of related topics:
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|----------------------|------------------------------------------------|
|
| -------------------- | ---------------------------------------------- |
|
||||||
| @ref error_group | Errors that can be thrown |
|
| @ref error_group | Errors that can be thrown |
|
||||||
| @ref validator_group | Common validators used in CLI::Option::check() |
|
| @ref validator_group | Common validators used in CLI::Option::check() |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user