Skip to content
Snippets Groups Projects
Commit 7d36eefe authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Merge branch 'develop' into feature/mpi

parents a9e6fe77 40bf8161
No related branches found
No related tags found
1 merge request!11Feature/mpi
Showing
with 713 additions and 277 deletions
...@@ -161,7 +161,7 @@ include_directories(src/scheme) ...@@ -161,7 +161,7 @@ include_directories(src/scheme)
# Pastis tests # Pastis tests
set(CATCH_MODULE_PATH "${PASTIS_SOURCE_DIR}/packages/Catch2") set(CATCH_MODULE_PATH "${PASTIS_SOURCE_DIR}/packages/Catch2")
set(CATCH_INCLUDE_PATH "${CATCH_MODULE_PATH}/single_include") set(CATCH_INCLUDE_PATH "${CATCH_MODULE_PATH}/single_include/catch2")
include("${CATCH_MODULE_PATH}/contrib/ParseAndAddCatchTests.cmake") include("${CATCH_MODULE_PATH}/contrib/ParseAndAddCatchTests.cmake")
add_subdirectory("${CATCH_MODULE_PATH}") add_subdirectory("${CATCH_MODULE_PATH}")
......
#!/usr/bin/env bash #!/usr/bin/env bash
echo -en "travis_fold:start:script.build\\r" echo -en "travis_fold:start:script.build\\r"
echo "Building..." echo "Building..."
STD=$1
shift
set -evx set -evx
mkdir -p build mkdir -p build
cd build cd build
cmake .. -DCLI11_CXX_STD=$1 -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake .. -DCLI11_SINGLE_FILE=ON -DCLI11_CXX_STD=$STD -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache $@
cmake --build . -- -j2 cmake --build . -- -j2
set +evx set +evx
......
...@@ -4,3 +4,6 @@ ...@@ -4,3 +4,6 @@
[submodule "extern/sanitizers"] [submodule "extern/sanitizers"]
path = extern/sanitizers path = extern/sanitizers
url = ../../arsenm/sanitizers-cmake url = ../../arsenm/sanitizers-cmake
[submodule "extern/json"]
path = extern/json
url = ../../nlohmann/json.git
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
[subrepo] [subrepo]
remote = git@github.com:CLIUtils/CLI11.git remote = git@github.com:CLIUtils/CLI11.git
branch = master branch = master
commit = 6f41cca9189129fd6df8c82bff532693dcfe52c3 commit = da901cca542612a133efcb04e8e78080186991e4
parent = e7630b332e1d23511b2de021692cf478675a662b parent = 4348958e3bface85aedc9e8a5638f38790834cd5
cmdver = 0.3.1 cmdver = 0.3.1
...@@ -11,7 +11,6 @@ branches: ...@@ -11,7 +11,6 @@ branches:
- /^v\d/ - /^v\d/
cache: cache:
ccache: true
apt: true apt: true
directories: directories:
- "${TRAVIS_BUILD_DIR}/deps/doxygen" - "${TRAVIS_BUILD_DIR}/deps/doxygen"
...@@ -49,6 +48,7 @@ matrix: ...@@ -49,6 +48,7 @@ matrix:
- .ci/make_and_test.sh 11 - .ci/make_and_test.sh 11
after_success: after_success:
- export DOXYFILE=$TRAVIS_BUILD_DIR/docs/Doxyfile - export DOXYFILE=$TRAVIS_BUILD_DIR/docs/Doxyfile
- export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- | - |
if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ] if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]
then then
...@@ -56,7 +56,7 @@ matrix: ...@@ -56,7 +56,7 @@ matrix:
.ci/build_docs.sh .ci/build_docs.sh
fi fi
# GCC 6 and Coverage # GCC 7 and coverage (8 does not support lcov, wait till 9 and new lcov)
- compiler: gcc - compiler: gcc
env: env:
- GCC_VER=7 - GCC_VER=7
...@@ -76,9 +76,9 @@ matrix: ...@@ -76,9 +76,9 @@ matrix:
- ". .ci/build_lcov.sh" - ". .ci/build_lcov.sh"
- ".ci/run_codecov.sh" - ".ci/run_codecov.sh"
script: script:
- .ci/make_and_test.sh 11 - .ci/make_and_test.sh 11 -DCLI11_EXAMPLE_JSON=ON
- .ci/make_and_test.sh 14 - .ci/make_and_test.sh 14 -DCLI11_EXAMPLE_JSON=ON
- .ci/make_and_test.sh 17 - .ci/make_and_test.sh 17 -DCLI11_EXAMPLE_JSON=ON
# GCC 4.7 and Conan # GCC 4.7 and Conan
- compiler: gcc - compiler: gcc
......
## Version 1.6.2: Help-all
This version fixes some formatting bugs with help-all. It also adds fixes for several warnings, including an experimental optional error on Clang 7.
* Fixed help-all formatting [#163]
* Printing help-all on nested command now fixed (App)
* Missing space after help-all restored (Default formatter)
* More detail printed on help all (Default formatter)
* Help-all subcommands get indented with inner blank lines removed (Default formatter)
* `detail::find_and_replace` added to utilities
* Fixed CMake install as subproject with `CLI11_INSTALL` flag. [#156]
* Fixed warning about local variable hiding class member with MSVC [#157]
* Fixed compile error with default settings on Clang 7 and libc++ [#158]
[#156]: https://github.com/CLIUtils/CLI11/issues/156
[#157]: https://github.com/CLIUtils/CLI11/issues/157
[#158]: https://github.com/CLIUtils/CLI11/issues/158
[#163]: https://github.com/CLIUtils/CLI11/pull/163
## Version 1.6.1: Platform fixes
This version provides a few fixes for special cases, such as mixing with `Windows.h` and better defaults
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.
* 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]
* Branding support for single file output [#150]
[#145]: https://github.com/CLIUtils/CLI11/pull/145
[#149]: https://github.com/CLIUtils/CLI11/pull/149
[#150]: https://github.com/CLIUtils/CLI11/pull/150
[#151]: https://github.com/CLIUtils/CLI11/pull/151
## Version 1.6: Formatting help ## Version 1.6: Formatting help
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).
* 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]
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:
...@@ -36,20 +73,29 @@ Validators are now much more powerful [#118], all built in validators upgraded t ...@@ -36,20 +73,29 @@ Validators are now much more powerful [#118], all built in validators upgraded t
Other changes: Other changes:
* Added `->each()` to make adding custom callbacks easier [#126] * Fixing `parse(args)`'s `args` setting and ordering after parse. [#141]
* Added filter argument to `get_subcommands`, `get_options`; use empty filter `{}` to avoid filtering * Replaced `set_custom_option` with `type_name` and `type_size` instead of `set_custom_option`. Methods return `this`. [#136]
* Added `get_groups()` to get groups * Dropped `set_` on Option's `type_name`, `default_str`, and `default_val`. [#136]
* Added getters for the missing parts of options (help no longer uses any private parts) * Removed `set_` from App's `failure_message`, `footer`, `callback`, and `name`. [#136]
* Better support for manual options with `get_option`, `set_results`, and `empty` [#119] * Fixed support `N<-1` for `type_size`. [#140]
* `lname` and `sname` have getters, added `const get_parent` [#120] * Added `->each()` to make adding custom callbacks easier. [#126]
* Using `add_set` will now capture L-values for sets, allowing further modification [#113] * Allow empty options `add_option("-n",{})` to be edited later with `each` [#142]
* Internally, `type_name` is now a lambda function; for sets, this reads the set live [#116] * Added filter argument to `get_subcommands`, `get_options`; use empty filter `{}` to avoid filtering.
* Dropped duplicate way to run `get_type_name` (`get_typeval`) * Added `get_groups()` to get groups.
* Better support for manual options with `get_option`, `set_results`, and `empty`. [#119]
* `lname` and `sname` have getters, added `const get_parent`. [#120]
* Using `add_set` will now capture L-values for sets, allowing further modification. [#113]
* Dropped duplicate way to run `get_type_name` (`get_typeval`).
* Removed `requires` in favor of `needs` (deprecated in last version). [#112]
* Const added to argv. [#126]
Backend and testing changes:
* 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]
* Better CMake policy handling. [#110]
* Includes are properly sorted. [#120]
* Testing (only) now uses submodules. [#111] * Testing (only) now uses submodules. [#111]
* Removed `requires` in favor of `needs` (deprecated in last version) [#112]
* Better CMake policy handling [#110]
* Includes are properly sorted [#120]
* Help flags now use new `short_circuit` property to simplify parsing [#121]
[#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
...@@ -62,6 +108,13 @@ Other changes: ...@@ -62,6 +108,13 @@ Other changes:
[#120]: https://github.com/CLIUtils/CLI11/pull/120 [#120]: https://github.com/CLIUtils/CLI11/pull/120
[#121]: https://github.com/CLIUtils/CLI11/pull/121 [#121]: https://github.com/CLIUtils/CLI11/pull/121
[#126]: https://github.com/CLIUtils/CLI11/pull/126 [#126]: https://github.com/CLIUtils/CLI11/pull/126
[#127]: https://github.com/CLIUtils/CLI11/pull/127
[#138]: https://github.com/CLIUtils/CLI11/pull/138
[#140]: https://github.com/CLIUtils/CLI11/pull/140
[#141]: https://github.com/CLIUtils/CLI11/pull/141
[#142]: https://github.com/CLIUtils/CLI11/pull/142
[nlohmann/json]: https://github.com/nlohmann/json
### Version 1.5.4: Optionals ### Version 1.5.4: Optionals
This version fixes the optional search in the single file version; some macros were not yet defined when it did the search. You can define the `CLI11_*_OPTIONAL` macros to 0 if needed to eliminate the search. This version fixes the optional search in the single file version; some macros were not yet defined when it did the search. You can define the `CLI11_*_OPTIONAL` macros to 0 if needed to eliminate the search.
......
cmake_minimum_required(VERSION 3.4...3.11) cmake_minimum_required(VERSION 3.4)
# Note: this is a header only library. If you have an older CMake than 3.4,
# just add the CLI11/include directory and that's all you need to do.
# Make sure users don't get warnings on a tested (3.4 to 3.12) version
# of CMake. For most of the policies, the new version is better (hence the change).
if(${CMAKE_VERSION} VERSION_LESS 3.12) if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_VERSION}) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.12)
endif() endif()
set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"") set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"")
...@@ -13,10 +19,9 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/Version.hpp" ...@@ -13,10 +19,9 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/Version.hpp"
# Pick out just the version # Pick out just the version
string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}") string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}")
# Add the project
project(CLI11 LANGUAGES CXX VERSION ${VERSION_STRING}) project(CLI11 LANGUAGES CXX VERSION ${VERSION_STRING})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Only if built as the main project # Only if built as the main project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# User settable # User settable
...@@ -31,7 +36,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) ...@@ -31,7 +36,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
if(MSVC) if(MSVC)
add_definitions("/W4") add_definitions("/W4")
else() else()
add_definitions(-Wall -Wextra -pedantic -Wno-deprecated-declarations) add_definitions(-Wall -Wextra -pedantic)
endif() endif()
if(CMAKE_VERSION VERSION_GREATER 3.6) if(CMAKE_VERSION VERSION_GREATER 3.6)
...@@ -74,9 +79,17 @@ target_include_directories(CLI11 INTERFACE ...@@ -74,9 +79,17 @@ target_include_directories(CLI11 INTERFACE
# Make add_subdirectory work like find_package # Make add_subdirectory work like find_package
add_library(CLI11::CLI11 ALIAS CLI11) add_library(CLI11::CLI11 ALIAS CLI11)
option(CLI11_INSTALL "Install the CLI11 folder to include during install process" ${CUR_PROJ})
# This folder should be installed # This folder should be installed
if(CLI11_INSTALL)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/CLI DESTINATION include) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/CLI DESTINATION include)
# Make an export target
install(TARGETS CLI11
EXPORT CLI11Targets)
endif()
# Use find_package on the installed package # Use find_package on the installed package
# Since we have no custom code, we can directly write this # Since we have no custom code, we can directly write this
# to Config.cmake (otherwise we'd have a custom config and would # to Config.cmake (otherwise we'd have a custom config and would
...@@ -90,14 +103,12 @@ write_basic_package_version_file( ...@@ -90,14 +103,12 @@ write_basic_package_version_file(
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
# These installs only make sense for a local project
if(CUR_PROJ)
# Make version available in the install # Make version available in the install
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CLI11ConfigVersion.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CLI11ConfigVersion.cmake"
DESTINATION lib/cmake/CLI11) DESTINATION lib/cmake/CLI11)
# Make an export target
install(TARGETS CLI11
EXPORT CLI11Targets)
# Install the export target as a file # Install the export target as a file
install(EXPORT CLI11Targets install(EXPORT CLI11Targets
FILE CLI11Config.cmake FILE CLI11Config.cmake
...@@ -111,16 +122,23 @@ export(TARGETS CLI11 ...@@ -111,16 +122,23 @@ export(TARGETS CLI11
# Register in the user cmake package registry # Register in the user cmake package registry
export(PACKAGE CLI11) export(PACKAGE CLI11)
endif()
# Single file test option(CLI11_SINGLE_FILE "Generate a single header file" OFF)
find_package(PythonInterp)
cmake_dependent_option(CLI11_SINGLE_FILE "Generate a single header file" ON "CUR_PROJ;PYTHONINTERP_FOUND" OFF)
if(CLI11_SINGLE_FILE) if(CLI11_SINGLE_FILE)
# Single file test
if(CMAKE_VERSION VERSION_LESS 3.12)
find_package(PythonInterp REQUIRED) find_package(PythonInterp REQUIRED)
set(Python_VERSION ${PYTHON_VERSION_STRING})
set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
else()
find_package(Python REQUIRED)
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp" add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp"
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/MakeSingleHeader.py" "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp" COMMAND "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/MakeSingleHeader.py" "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers} DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI11_headers}
) )
add_custom_target(generate_cli_single_file ALL add_custom_target(generate_cli_single_file ALL
......
CLI11 1.5 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry CLI11 1.6 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry
Schreiner under NSF AWARD 1414736. All rights reserved. Schreiner under NSF AWARD 1414736. All rights reserved.
Redistribution and use in source and binary forms of CLI11, with or without Redistribution and use in source and binary forms of CLI11, with or without
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="34.342606mm"
height="15.300875mm"
viewBox="0 0 34.342606 15.300875"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (unknown)"
sodipodi:docname="CLI11.svg"
inkscape:export-filename="/data/CLI11_300.png"
inkscape:export-xdpi="222.62143"
inkscape:export-ydpi="222.62143">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.206433"
inkscape:cx="93.996945"
inkscape:cy="15.843961"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="2560"
inkscape:window-height="1347"
inkscape:window-x="0"
inkscape:window-y="1"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-53.018986,-23.9019)">
<g
id="g4602"
transform="rotate(-0.28559572,70.190289,31.552338)">
<path
inkscape:connector-curvature="0"
id="path3732"
transform="scale(0.26458333)"
d="m 233.33789,90.337891 -32.95117,28.619139 31.94726,28.91406 64.9004,0.29688 32.95117,-28.61914 -31.94727,-28.914064 z"
style="fill:#008080;stroke-width:0.54128456" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#ffffff;stroke-width:0.3148967;stroke-miterlimit:4;stroke-dasharray:none"
d="m 62.120274,24.413292 -8.32335,7.065988 8.069765,7.138804 16.393615,0.0733 8.32335,-7.065988 -8.069768,-7.138806 z"
id="path3774" />
</g>
<g
id="g4609"
transform="translate(-0.43472687)">
<path
inkscape:transform-center-y="0.00020894337"
inkscape:transform-center-x="0.0229185"
inkscape:connector-curvature="0"
id="path3730"
d="m 60.964519,27.804182 c 0.886395,-0.348655 1.859691,-0.390207 2.74248,-0.111952 0.651274,0.210103 1.042699,0.454066 1.576252,0.972044 l -1.506657,0.592635 c -0.744252,-0.446473 -1.423964,-0.497745 -2.270962,-0.164583 -0.738662,0.290549 -1.26082,0.814436 -1.498695,1.510755 -0.203801,0.580557 -0.182185,1.300104 0.05025,1.891033 0.534609,1.359137 2.079298,2.048044 3.418738,1.521183 0.699266,-0.275052 1.11846,-0.713017 1.465328,-1.565931 l 1.585527,-0.623658 c -0.04824,1.554281 -1.023053,2.892949 -2.510224,3.47792 -2.127345,0.836779 -4.497206,-0.187252 -5.322363,-2.28505 -0.809661,-2.058401 0.211919,-4.404734 2.270322,-5.214396 z"
style="fill:#ffffff;stroke-width:0.14321487" />
<path
inkscape:connector-curvature="0"
id="path3728"
transform="scale(0.26458333)"
d="m 253.49609,104.47266 h 5.48047 v 24.32031 h 9.03906 v 5.24023 h -14.51953 z"
style="fill:#ffffff;stroke-width:0.54128456" />
<path
inkscape:connector-curvature="0"
id="path3726"
transform="scale(0.26458333)"
d="m 271.07422,104.47266 h 5.48047 v 29.56054 h -5.48047 z"
style="fill:#ffffff;stroke-width:0.54128456" />
<path
inkscape:connector-curvature="0"
id="path3724"
transform="scale(0.26458333)"
d="m 294.68555,104.47266 v 29.56054 h -5.32032 v -24.56054 h -3.71875 z"
style="fill:#ffffff;stroke-width:0.54128456" />
<path
inkscape:connector-curvature="0"
id="path3705"
transform="scale(0.26458333)"
d="m 305.76758,104.47266 v 29.56054 h -5.32031 v -24.56054 h -3.71875 z"
style="fill:#ffffff;stroke-width:0.54128456" />
</g>
</g>
</svg>
packages/CLI11/docs/CLI11_100.png

3.28 KiB

packages/CLI11/docs/CLI11_300.png

9.72 KiB

...@@ -334,7 +334,7 @@ BUILTIN_STL_SUPPORT = NO ...@@ -334,7 +334,7 @@ BUILTIN_STL_SUPPORT = NO
# enable parsing support. # enable parsing support.
# The default value is: NO. # The default value is: NO.
CPP_CLI11_SUPPORT = NO CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
......
...@@ -14,6 +14,33 @@ function(add_cli_exe T) ...@@ -14,6 +14,33 @@ function(add_cli_exe T)
endif() endif()
endfunction() endfunction()
option(CLI11_EXAMPLE_JSON OFF)
if(CLI11_EXAMPLE_JSON)
if(NOT EXISTS "${CLI11_SOURCE_DIR}/extern/json/single_include/nlohmann/json.hpp")
message(ERROR "You are missing the json package for CLI11_EXAMPLE_JSON. Please update your submodules (git submodule update --init)")
endif()
if(CMAKE_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
message(WARNING "The json example requires GCC 4.9+ (requirement on json library)")
endif()
add_cli_exe(json json.cpp)
target_include_directories(json PUBLIC SYSTEM "${CLI11_SOURCE_DIR}/extern/json/single_include")
add_test(NAME json_config_out COMMAND json --item 2)
set_property(TEST json_config_out PROPERTY PASS_REGULAR_EXPRESSION
"{"
"\"item\": \"2\""
"\"simple\": false"
"}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/input.json" [=[{"item":3,"simple":false}]=])
add_test(NAME json_config_in COMMAND json --config "${CMAKE_CURRENT_BINARY_DIR}/input.json")
set_property(TEST json_config_in PROPERTY PASS_REGULAR_EXPRESSION
"{"
"\"item\": \"3\""
"\"simple\": false"
"}")
endif()
add_cli_exe(simple simple.cpp) add_cli_exe(simple simple.cpp)
add_test(NAME simple_basic COMMAND simple) add_test(NAME simple_basic COMMAND simple)
add_test(NAME simple_all COMMAND simple -f filename.txt -c 12 --flag --flag -d 1.2) add_test(NAME simple_all COMMAND simple -f filename.txt -c 12 --flag --flag -d 1.2)
...@@ -36,6 +63,20 @@ set_property(TEST subcommands_all PROPERTY PASS_REGULAR_EXPRESSION ...@@ -36,6 +63,20 @@ set_property(TEST subcommands_all PROPERTY PASS_REGULAR_EXPRESSION
"Subcommand: start" "Subcommand: start"
"Subcommand: stop") "Subcommand: stop")
add_cli_exe(validators validators.cpp)
add_test(NAME validators_help COMMAND validators --help)
set_property(TEST validators_help PROPERTY PASS_REGULAR_EXPRESSION
" -f,--file FILE File name"
" -v,--value INT in [3 - 6] Value in range")
add_test(NAME validators_file COMMAND validators --file nonex.xxx)
set_property(TEST validators_file PROPERTY PASS_REGULAR_EXPRESSION
"--file: File does not exist: nonex.xxx"
"Run with --help for more information.")
add_test(NAME validators_plain COMMAND validators --value 9)
set_property(TEST validators_plain PROPERTY PASS_REGULAR_EXPRESSION
"--value: Value 9 not in range 3 to 6"
"Run with --help for more information.")
add_cli_exe(groups groups.cpp) add_cli_exe(groups groups.cpp)
add_test(NAME groups_none COMMAND groups) add_test(NAME groups_none COMMAND groups)
set_property(TEST groups_none PROPERTY PASS_REGULAR_EXPRESSION set_property(TEST groups_none PROPERTY PASS_REGULAR_EXPRESSION
...@@ -85,3 +126,5 @@ set_property(TEST subcom_in_files PROPERTY PASS_REGULAR_EXPRESSION ...@@ -85,3 +126,5 @@ set_property(TEST subcom_in_files PROPERTY PASS_REGULAR_EXPRESSION
"Using foo!") "Using foo!")
add_cli_exe(formatter formatter.cpp) add_cli_exe(formatter formatter.cpp)
add_cli_exe(nested nested.cpp)
...@@ -17,7 +17,7 @@ int main(int argc, char **argv) { ...@@ -17,7 +17,7 @@ int main(int argc, char **argv) {
Level level; Level level;
app.add_set("-l,--level", level, {Level::High, Level::Medium, Level::Low}, "Level settings") app.add_set("-l,--level", level, {Level::High, Level::Medium, Level::Low}, "Level settings")
->set_type_name("enum/Level in {High=0, Medium=1, Low=2}"); ->type_name("enum/Level in {High=0, Medium=1, Low=2}");
CLI11_PARSE(app, argc, argv); CLI11_PARSE(app, argc, argv);
......
#include <CLI/CLI.hpp>
#include <nlohmann/json.hpp>
// This example is only built on GCC 7 on Travis due to mismatch in stdlib
// for clang (CLI11 is forgiving about mismatches, json.hpp is not)
using nlohmann::json;
class ConfigJSON : public CLI::Config {
public:
std::string to_config(const CLI::App *app, bool default_also, bool, std::string) const override {
json j;
for(const CLI::Option *opt : app->get_options({})) {
// Only process option with a long-name and configurable
if(!opt->get_lnames().empty() && opt->get_configurable()) {
std::string name = opt->get_lnames()[0];
// Non-flags
if(opt->get_type_size() != 0) {
// If the option was found on command line
if(opt->count() == 1)
j[name] = opt->results().at(0);
else if(opt->count() > 1)
j[name] = opt->results();
// If the option has a default and is requested by optional argument
else if(default_also && !opt->get_defaultval().empty())
j[name] = opt->get_defaultval();
// Flag, one passed
} else if(opt->count() == 1) {
j[name] = true;
// Flag, multiple passed
} else if(opt->count() > 1) {
j[name] = opt->count();
// Flag, not present
} else if(opt->count() == 0 && default_also) {
j[name] = false;
}
}
}
for(const CLI::App *subcom : app->get_subcommands({}))
j[subcom->get_name()] = json(to_config(subcom, default_also, false, ""));
return j.dump(4);
}
std::vector<CLI::ConfigItem> from_config(std::istream &input) const override {
json j;
input >> j;
return _from_config(j);
}
std::vector<CLI::ConfigItem>
_from_config(json j, std::string name = "", std::vector<std::string> prefix = {}) const {
std::vector<CLI::ConfigItem> results;
if(j.is_object()) {
for(json::iterator item = j.begin(); item != j.end(); ++item) {
auto copy_prefix = prefix;
if(!name.empty())
copy_prefix.push_back(name);
auto sub_results = _from_config(*item, item.key(), copy_prefix);
results.insert(results.end(), sub_results.begin(), sub_results.end());
}
} else if(!name.empty()) {
results.emplace_back();
CLI::ConfigItem &res = results.back();
res.name = name;
res.parents = prefix;
if(j.is_boolean()) {
res.inputs = {j.get<bool>() ? "true" : "false"};
} else if(j.is_number()) {
std::stringstream ss;
ss << j.get<double>();
res.inputs = {ss.str()};
} else if(j.is_string()) {
res.inputs = {j.get<std::string>()};
} else if(j.is_array()) {
for(std::string ival : j)
res.inputs.push_back(ival);
} else {
throw CLI::ConversionError("Failed to convert " + name);
}
} else {
throw CLI::ConversionError("You must make all top level values objects in json!");
}
return results;
}
};
int main(int argc, char **argv) {
CLI::App app;
app.config_formatter(std::make_shared<ConfigJSON>());
int item;
app.add_flag("--simple");
app.add_option("--item", item);
app.set_config("--config");
CLI11_PARSE(app, argc, argv);
std::cout << app.config_to_str(true, true) << std::endl;
}
#include <CLI/CLI.hpp>
#include <string>
int main(int argc, char **argv) {
CLI::App app("Vision Application");
app.set_help_all_flag("--help-all", "Expand all help");
app.add_flag("--version", "Get version");
CLI::App *cameraApp = app.add_subcommand("camera", "Configure the app camera");
cameraApp->require_subcommand(0, 1); // 0 (default) or 1 camera
std::string mvcamera_config_file = "mvcamera_config.json";
CLI::App *mvcameraApp = cameraApp->add_subcommand("mvcamera", "MatrixVision Camera Configuration");
mvcameraApp->add_option("-c,--config", mvcamera_config_file, "Config filename", true)->check(CLI::ExistingFile);
std::string mock_camera_path;
CLI::App *mockcameraApp = cameraApp->add_subcommand("mock", "Mock Camera Configuration");
mockcameraApp->add_option("-p,--path", mock_camera_path, "Path")->required()->check(CLI::ExistingPath);
CLI11_PARSE(app, argc, argv);
}
...@@ -18,7 +18,7 @@ void setup_subcommand_a(CLI::App &app) { ...@@ -18,7 +18,7 @@ void setup_subcommand_a(CLI::App &app) {
sub->add_flag("--with-foo", opt->with_foo, "Counter"); sub->add_flag("--with-foo", opt->with_foo, "Counter");
// Set the run function as callback to be called when this subcommand is issued. // Set the run function as callback to be called when this subcommand is issued.
sub->set_callback([opt]() { run_subcommand_a(*opt); }); sub->callback([opt]() { run_subcommand_a(*opt); });
} }
/// The function that runs our code. /// The function that runs our code.
......
#include "CLI/CLI.hpp"
int main(int argc, char **argv) {
CLI::App app("Validator checker");
std::string file;
app.add_option("-f,--file,file", file, "File name")->check(CLI::ExistingFile);
int count;
app.add_option("-v,--value", count, "Value in range")->check(CLI::Range(3, 6));
CLI11_PARSE(app, argc, argv);
std::cout << "Try printing help or failing the validator" << std::endl;
return 0;
}
json @ d2dd27dc
Subproject commit d2dd27dc3b8472dbaa7d66f83619b3ebcd9185fe
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment