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

Merge branch 'develop' into feature/language

parents 1cc7b80a 31a6ee59
No related branches found
No related tags found
1 merge request!37Feature/language
Showing
with 594 additions and 359 deletions
version: 1.8.0.{build}
branches: branches:
only: only:
- master - master
...@@ -13,7 +15,7 @@ install: ...@@ -13,7 +15,7 @@ install:
build_script: build_script:
- mkdir build - mkdir build
- cd build - cd build
- ps: cmake .. -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015" - ps: cmake .. -DCLI11_WARNINGS_AS_ERRORS=ON -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR="Visual Studio 14 2015"
- ps: cmake --build . - ps: cmake --build .
- cd .. - cd ..
- conan create . CLIUtils/CLI11 - conan create . CLIUtils/CLI11
......
steps:
- task: CMake@1
inputs:
cmakeArgs: .. -DCLI11_WARNINGS_AS_ERRORS=ON -DCLI11_SINGLE_FILE=$(cli11.single) -DCLI11_CXX_STD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) $(cli11.options)
displayName: 'Configure'
- script: cmake --build .
displayName: 'Build'
workingDirectory: build
steps:
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
- bash: |
wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz"
echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256
displayName: Download CMake
- task: ExtractFiles@1
inputs:
archiveFilePatterns: 'cmake*.tar.gz'
destinationFolder: 'cmake_program'
displayName: Extract CMake
- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
displayName: Add CMake to PATH
steps:
- checkout: self
fetchDepth: 50
submodules: true
- task: CMake@1
inputs:
cmakeArgs: .. -DCLI12_SINGLE_FILE=ON -DCLI11_CXX_STD=14 -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
displayName: 'Configure'
- script: cmake --build . -j
displayName: 'Build'
workingDirectory: build
- script: ctest --output-on-failure -C Debug
displayName: 'Test'
workingDirectory: build
steps:
- script: ctest --output-on-failure -C $(cli11.build_type) -T test
displayName: 'Test'
workingDirectory: build
- task: PublishTestResults@2
inputs:
testResultsFormat: 'cTest'
testResultsFiles: '**/Test.xml'
#!/bin/sh
################################################################################
# Title : generateDocumentationAndDeploy.sh
# Date created : 2016/02/22
# Notes :
# Author : Jeroen de Bruijn
# Preconditions:
# - Packages doxygen doxygen-doc doxygen-latex doxygen-gui graphviz
# must be installed.
# - Doxygen configuration file must have the destination directory empty and
# source code directory with a $(TRAVIS_BUILD_DIR) prefix.
# - An gh-pages branch should already exist. See below for mor info on hoe to
# create a gh-pages branch.
#
# Required global variables:
# - TRAVIS_BUILD_NUMBER : The number of the current build.
# - TRAVIS_COMMIT : The commit that the current build is testing.
# - DOXYFILE : The Doxygen configuration file.
# - TRAVIS_REPO_SLUG : The username / reponame for the repository.
# - GH_REPO_TOKEN : Secure token to the github repository.
#
# For information on how to encrypt variables for Travis CI please go to
# https://docs.travis-ci.com/user/environment-variables/#Encrypted-Variables
# or https://gist.github.com/vidavidorra/7ed6166a46c537d3cbd2
# For information on how to create a clean gh-pages branch from the master
# branch, please go to https://gist.github.com/vidavidorra/846a2fc7dd51f4fe56a0
#
# This script will generate Doxygen documentation and push the documentation to
# the gh-pages branch of a repository specified by GH_REPO_REF.
# Before this script is used there should already be a gh-pages branch in the
# repository.
#
################################################################################
################################################################################
##### Setup this script and get the current gh-pages branch. #####
echo 'Setting up the script...'
# Exit with nonzero exit code if anything fails
set -e
GH_REPO_ORG=$(echo $TRAVIS_REPO_SLUG | cut -d "/" -f 1)
GH_REPO_NAME=$(echo $TRAVIS_REPO_SLUG | cut -d "/" -f 2)
GH_REPO_REF="github.com/$GH_REPO_ORG/$GH_REPO_NAME.git"
# Create a clean working directory for this script.
# Get the current gh-pages branch
cd docs
git clone -b gh-pages https://git@$GH_REPO_REF html
cd html
##### Configure git.
# Set the push default to simple i.e. push only the current branch.
git config --global push.default simple
# Pretend to be an user called Travis CI.
git config user.name "Travis CI"
git config user.email "travis@travis-ci.org"
# Remove everything currently in the gh-pages branch.
# GitHub is smart enough to know which files have changed and which files have
# stayed the same and will only update the changed files. So the gh-pages branch
# can be safely cleaned, and it is sure that everything pushed later is the new
# documentation.
rm -rf *
# Need to create a .nojekyll file to allow filenames starting with an underscore
# to be seen on the gh-pages site. Therefore creating an empty .nojekyll file.
# Presumably this is only needed when the SHORT_NAMES option in Doxygen is set
# to NO, which it is by default. So creating the file just in case.
echo "" > .nojekyll
################################################################################
##### Generate the Doxygen code documentation and log the output. #####
echo 'Generating Doxygen code documentation...'
# Redirect both stderr and stdout to the log file AND the console.
cd ..
doxygen $DOXYFILE 2>&1 | tee doxygen.log
################################################################################
##### Upload the documentation to the gh-pages branch of the repository. #####
# Only upload if Doxygen successfully created the documentation.
# Check this by verifying that the html directory and the file html/index.html
# both exist. This is a good indication that Doxygen did it's work.
if [ -d "html" ] && [ -f "html/index.html" ]; then
cd html
echo 'Uploading documentation to the gh-pages branch...'
# Add everything in this directory (the Doxygen code documentation) to the
# gh-pages branch.
# GitHub is smart enough to know which files have changed and which files have
# stayed the same and will only update the changed files.
git add --all
# Commit the added files with a title and description containing the Travis CI
# build number and the GitHub commit reference that issued this build.
git commit -m "Deploy code docs to GitHub Pages Travis build: ${TRAVIS_BUILD_NUMBER}" -m "Commit: ${TRAVIS_COMMIT}"
# Force push to the remote gh-pages branch.
# The ouput is redirected to /dev/null to hide any sensitive credential data
# that might otherwise be exposed.
git push --force "https://${GH_REPO_TOKEN}@${GH_REPO_REF}" > /dev/null 2>&1
else
echo '' >&2
echo 'Warning: No documentation (html) files have been found!' >&2
echo 'Warning: Not going to push the documentation to GitHub!' >&2
exit 1
fi
#!/usr/bin/env bash
echo -en "travis_fold:start:script.build\\r"
echo "Building with tidy on..."
set -evx
mkdir -p build-tidy
cd build-tidy
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" cmake .. -DCLANG_TIDY_FIX=ON
cmake --build .
set -evx
echo -en "travis_fold:end:script.build\\r"
echo -en "travis_fold:start:script.compare\\r"
echo "Checking git diff..."
set -evx
git diff --exit-code --color
set +evx
echo -en "travis_fold:end:script.compare\\r"
...@@ -8,7 +8,7 @@ set -evx ...@@ -8,7 +8,7 @@ set -evx
mkdir -p build mkdir -p build
cd build cd build
cmake .. -DCLI11_SINGLE_FILE=ON -DCLI11_CXX_STD=$STD -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache $@ cmake .. -DCLI11_WARNINGS_AS_ERRORS=ON -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
......
...@@ -7,3 +7,5 @@ insert_final_newline = true ...@@ -7,3 +7,5 @@ insert_final_newline = true
end_of_line = lf end_of_line = lf
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.yml]
indent_size = 2
...@@ -5,3 +5,6 @@ a.out* ...@@ -5,3 +5,6 @@ a.out*
/Makefile /Makefile
/CMakeFiles/* /CMakeFiles/*
/cmake_install.cmake /cmake_install.cmake
/*.kdev4
/html/*
!/meson.build
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
[subrepo] [subrepo]
remote = git@github.com:CLIUtils/CLI11.git remote = git@github.com:CLIUtils/CLI11.git
branch = master branch = master
commit = 76d2cde6568c9c8870b728aa9bc64b70b29127fd commit = 8ecce8fd2c49f64c80e5757cb12d2fd1fa62f242
parent = ead793c351e37e34227121e50abdce709aeb81af parent = 7de34a384b9d2e24dbbf3707aa01fad53b7df4e6
cmdver = 0.4.0 cmdver = 0.4.0
method = merge method = merge
...@@ -23,17 +23,10 @@ matrix: ...@@ -23,17 +23,10 @@ matrix:
- .ci/make_and_test.sh 14 - .ci/make_and_test.sh 14
- .ci/make_and_test.sh 17 - .ci/make_and_test.sh 17
# Check style/tidy
- compiler: clang
env:
- CHECK_STYLE=yes
script:
- cd "${TRAVIS_BUILD_DIR}"
- scripts/check_style.sh
- .ci/check_tidy.sh
# Docs and clang 3.5 # Docs and clang 3.5
- compiler: clang - compiler: clang
language: node_js
node_js: "7.4.0"
env: env:
- DEPLOY_MAT=yes - DEPLOY_MAT=yes
addons: addons:
...@@ -43,17 +36,16 @@ matrix: ...@@ -43,17 +36,16 @@ matrix:
install: install:
- export CC=clang-3.5 - export CC=clang-3.5
- export CXX=clang++-3.5 - export CXX=clang++-3.5
- npm install gitbook-cli -g
- gitbook fetch 3.2.3
- gitbook install book
script: script:
- .ci/make_and_test.sh 11 - .ci/make_and_test.sh 11
after_success: after_success:
- export DOXYFILE=$TRAVIS_BUILD_DIR/docs/Doxyfile
- export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- | - . .ci/build_doxygen.sh
if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ] - doxygen docs/Doxyfile
then - gitbook build book html/book
. .ci/build_doxygen.sh
.ci/build_docs.sh
fi
# GCC 7 and coverage (8 does not support lcov, wait till 9 and new lcov) # GCC 7 and coverage (8 does not support lcov, wait till 9 and new lcov)
- compiler: gcc - compiler: gcc
...@@ -79,17 +71,17 @@ matrix: ...@@ -79,17 +71,17 @@ matrix:
- .ci/make_and_test.sh 14 -DCLI11_EXAMPLE_JSON=ON - .ci/make_and_test.sh 14 -DCLI11_EXAMPLE_JSON=ON
- .ci/make_and_test.sh 17 -DCLI11_EXAMPLE_JSON=ON - .ci/make_and_test.sh 17 -DCLI11_EXAMPLE_JSON=ON
# GCC 4.7 and Conan # GCC 4.8 and Conan
- compiler: gcc - compiler: gcc
env: env:
- GCC_VER=4.7 - GCC_VER=4.8
addons: addons:
apt: apt:
packages: packages:
- g++-4.7 - g++-4.8
install: install:
- export CC=gcc-4.7 - export CC=gcc-4.8
- export CXX=g++-4.7 - export CXX=g++-4.8
- python -m pip install --user conan - python -m pip install --user conan
- conan user - conan user
script: script:
...@@ -104,29 +96,6 @@ matrix: ...@@ -104,29 +96,6 @@ matrix:
conan upload "*" -c -r origin --all conan upload "*" -c -r origin --all
fi fi
# GCC 4.8
- compiler: gcc
env:
- GCC_VER=4.8
addons:
apt:
packages:
- g++-4.8
install:
- export CC=gcc-4.8
- export CXX=g++-4.8
script:
- .ci/make_and_test.sh 11
# macOS and clang
- os: osx
compiler: clang
install:
- brew update
- echo 'brew "python"' > Brewfile
- echo 'brew "ccache"' >> Brewfile
- brew bundle
- python -m ensurepip --user
install: skip install: skip
...@@ -136,7 +105,15 @@ script: ...@@ -136,7 +105,15 @@ script:
deploy: deploy:
provider: releases - provider: pages
skip_cleanup: true
github_token: ${GH_REPO_TOKEN}
keep_history: false
local_dir: ${TRAVIS_BUILD_DIR}/html
on:
branch: master
condition: "$DEPLOY_MAT = yes"
- provider: releases
api_key: api_key:
secure: L1svZ5J+RiR67dj1fNk/XiZRvYfGJC4c5/dKSvDH+yuKSzZ6ODaTiVmYF8NtMJ7/3AQenEa0OuRBVQ0YpngFz3ugIcRsGCDUHtCMK/Bti0+6ZFdICbqcv6W3BlRIM8s7EOBPhjfbCV+ae7xep9B24HmwBPKukMFjDIj4nwBsmwCHZK9iNFtfaW2J2cr2TJo7QPY01J0W1k/boaj91KzHf9UuhEH8KYqp7szv+6kV00W8bRBtugw419dIm25eXFXgXDT9s/OA7qXV7o5FXWWpkyJ5AINVbY9DerkYag5TStrdOyKk+S1FexRG6TMG4L4Jyu/QxQGhMdu0m1yRCLvIekGtWLDnjNrI2SZrd5HbKprQ0O8j1770Is4q5blVPqAZ6O9jVMJRtVEaYbsJwItz1BJWkPT4S9GFbDL1dq2Z5jR2f5gd/cz2yYH56b47iYHWtzSqEfVhsXiN+atD+tWyQFA4Q/av0bGHwJ6LX0A1q0OCHruUMoxcw1QKfYtV1bkf/folL4Z4Hx3CL+NB0Lkqs8LFsQHxODP4a26I5DS/kaDHofotho8wsWlKFDtonZa+CExORGFFMPnGRz2qX5tMgGoo84wcqrprfoQv2llqeUr3gISPl2qxrljAhj3/Dcl7iI7k0Er7Ji8ENpgjSec4aqnBx8Ke2yaDEmBvwbouFCM= secure: L1svZ5J+RiR67dj1fNk/XiZRvYfGJC4c5/dKSvDH+yuKSzZ6ODaTiVmYF8NtMJ7/3AQenEa0OuRBVQ0YpngFz3ugIcRsGCDUHtCMK/Bti0+6ZFdICbqcv6W3BlRIM8s7EOBPhjfbCV+ae7xep9B24HmwBPKukMFjDIj4nwBsmwCHZK9iNFtfaW2J2cr2TJo7QPY01J0W1k/boaj91KzHf9UuhEH8KYqp7szv+6kV00W8bRBtugw419dIm25eXFXgXDT9s/OA7qXV7o5FXWWpkyJ5AINVbY9DerkYag5TStrdOyKk+S1FexRG6TMG4L4Jyu/QxQGhMdu0m1yRCLvIekGtWLDnjNrI2SZrd5HbKprQ0O8j1770Is4q5blVPqAZ6O9jVMJRtVEaYbsJwItz1BJWkPT4S9GFbDL1dq2Z5jR2f5gd/cz2yYH56b47iYHWtzSqEfVhsXiN+atD+tWyQFA4Q/av0bGHwJ6LX0A1q0OCHruUMoxcw1QKfYtV1bkf/folL4Z4Hx3CL+NB0Lkqs8LFsQHxODP4a26I5DS/kaDHofotho8wsWlKFDtonZa+CExORGFFMPnGRz2qX5tMgGoo84wcqrprfoQv2llqeUr3gISPl2qxrljAhj3/Dcl7iI7k0Er7Ji8ENpgjSec4aqnBx8Ke2yaDEmBvwbouFCM=
skip_cleanup: true skip_cleanup: true
...@@ -145,6 +122,7 @@ deploy: ...@@ -145,6 +122,7 @@ deploy:
repo: CLIUtils/CLI11 repo: CLIUtils/CLI11
tags: true tags: true
condition: "$DEPLOY_MAT = yes" condition: "$DEPLOY_MAT = yes"
notifications: notifications:
webhooks: webhooks:
urls: urls:
...@@ -152,6 +130,7 @@ notifications: ...@@ -152,6 +130,7 @@ notifications:
on_success: change on_success: change
on_failure: always on_failure: always
on_start: never on_start: never
env: env:
global: global:
- secure: cY0OI609iTAxLRYuYQnNMi+H6n0dBwioTAoFXGGRTnngw2V9om3UmY5eUu4HQEQsQZovHdYpNhlSgRmdwQ4UqSp3FGyrwobf0kzacV4bVnMDeXDmHt8RzE5wP/LwDd8elNF6RRYjElY99f0k0FyXVd0fIvuVkGKQECNLOtEk0jQo+4YTh7dhuCxRhBYgTbNiRL6UJynfrcK0YN+DQ+8CJNupu2VxgaEpCSngTfvDHLcddcrXwpvn3MPc3FsDUbtN389ZCIe41qqIL0ATv46DQaTw4FOevyVfRyrBOznONoGCVeAYKL6VBdrk01Fh6aytF5zgI3hKaKobgEn+QFfzR6l68c6APvqA0Qv39iLjuh6KbdIV2YsqXfyt6FBgqP2xZuNEZW1jZ8LxUOLl2I40UEh87nFutvnSbfIzN+FcLrajm2H2jV2kZGNKAMx+4qxkZuXSre4JPkENfJm2WNFAKlqPt4ZSEQarkDYzZPcEr2I9fbGjQYVJICoN4LikCv9K5z7ujpTxCTNbVpQWZcEOT6QQBc6Vml/N/NKAIl9o2OeTLiXCmT31+KQMeO492KYNQ6VmkeqrVhGExOUcJdNyDJV9C+3mSekb3Sq78SneYRKDechkWbMl0ol07wGTdBwQQwgaorjRyn07x1rDxpPr3z19/+eubnpPUW4UQ5MYsjs= - secure: cY0OI609iTAxLRYuYQnNMi+H6n0dBwioTAoFXGGRTnngw2V9om3UmY5eUu4HQEQsQZovHdYpNhlSgRmdwQ4UqSp3FGyrwobf0kzacV4bVnMDeXDmHt8RzE5wP/LwDd8elNF6RRYjElY99f0k0FyXVd0fIvuVkGKQECNLOtEk0jQo+4YTh7dhuCxRhBYgTbNiRL6UJynfrcK0YN+DQ+8CJNupu2VxgaEpCSngTfvDHLcddcrXwpvn3MPc3FsDUbtN389ZCIe41qqIL0ATv46DQaTw4FOevyVfRyrBOznONoGCVeAYKL6VBdrk01Fh6aytF5zgI3hKaKobgEn+QFfzR6l68c6APvqA0Qv39iLjuh6KbdIV2YsqXfyt6FBgqP2xZuNEZW1jZ8LxUOLl2I40UEh87nFutvnSbfIzN+FcLrajm2H2jV2kZGNKAMx+4qxkZuXSre4JPkENfJm2WNFAKlqPt4ZSEQarkDYzZPcEr2I9fbGjQYVJICoN4LikCv9K5z7ujpTxCTNbVpQWZcEOT6QQBc6Vml/N/NKAIl9o2OeTLiXCmT31+KQMeO492KYNQ6VmkeqrVhGExOUcJdNyDJV9C+3mSekb3Sq78SneYRKDechkWbMl0ol07wGTdBwQQwgaorjRyn07x1rDxpPr3z19/+eubnpPUW4UQ5MYsjs=
......
## Version 1.8: Sets and Flags (IN PROGRESS) ## Version 1.9: IN PROGRESS
Set handling has been completely replaced by a new backend that works as a Validator. 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 meson build system supported [#299][]
* 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][]
* `app.immediate_callback()` allows the main app to run before subcommand callbacks. [#292][]
* GCC 4.7 is no longer supported, due mostly to GoogleTest. GCC 4.8+ is now required. [#160][]
* Backend: Cleaner type traits [#286][]
* Bugfix: Fixed undefined behavior in `checked_multiply` [#290][]
* Bugfix: Resetting config option works properly [#301][]
[#160]: https://github.com/CLIUtils/CLI11/pull/160
[#285]: https://github.com/CLIUtils/CLI11/pull/285
[#286]: https://github.com/CLIUtils/CLI11/pull/286
[#290]: https://github.com/CLIUtils/CLI11/pull/290
[#292]: https://github.com/CLIUtils/CLI11/pull/292
[#299]: https://github.com/CLIUtils/CLI11/pull/299
[#300]: https://github.com/CLIUtils/CLI11/pull/300
## Version 1.8: Transformers, default strings, and flags
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]
* 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]
* 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]
* 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] * 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]
* 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 support for aarch64 [#266]
* 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]
> ### 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
> * `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`
...@@ -39,6 +69,16 @@ Set handling has been completely replaced by a new backend that works as a Valid ...@@ -39,6 +69,16 @@ Set handling has been completely replaced by a new backend that works as a Valid
[#233]: https://github.com/CLIUtils/CLI11/pull/233 [#233]: https://github.com/CLIUtils/CLI11/pull/233
[#235]: https://github.com/CLIUtils/CLI11/pull/235 [#235]: https://github.com/CLIUtils/CLI11/pull/235
[#240]: https://github.com/CLIUtils/CLI11/pull/240 [#240]: https://github.com/CLIUtils/CLI11/pull/240
[#242]: https://github.com/CLIUtils/CLI11/pull/242
[#247]: https://github.com/CLIUtils/CLI11/pull/247
[#251]: https://github.com/CLIUtils/CLI11/pull/251
[#253]: https://github.com/CLIUtils/CLI11/pull/253
[#262]: https://github.com/CLIUtils/CLI11/pull/262
[#265]: https://github.com/CLIUtils/CLI11/pull/265
[#266]: https://github.com/CLIUtils/CLI11/pull/266
[#269]: https://github.com/CLIUtils/CLI11/pull/269
[#277]: https://github.com/CLIUtils/CLI11/pull/277
[#279]: https://github.com/CLIUtils/CLI11/pull/279
## Version 1.7.1: Quick patch ## Version 1.7.1: Quick patch
...@@ -70,7 +110,7 @@ Passing the same subcommand multiple times is better supported. Several new feat ...@@ -70,7 +110,7 @@ Passing the same subcommand multiple times is better supported. Several new feat
* Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#179] * Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#179]
* Calling parse multiple times is now officially supported without `clear` (automatic). [#179] * Calling parse multiple times is now officially supported without `clear` (automatic). [#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] * 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 (`CLI11_TESTING` may eventually be removed) [#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]
......
...@@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.4) ...@@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.4)
# Note: this is a header only library. If you have an older CMake than 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. # 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.13) version # Make sure users don't get warnings on a tested (3.4 to 3.14) version
# of CMake. For most of the policies, the new version is better (hence the change). # of CMake. For most of the policies, the new version is better (hence the change).
if(${CMAKE_VERSION} VERSION_LESS 3.13) # We don't use the 3.4...3.14 syntax because of a bug in a version of MSVC
if(${CMAKE_VERSION} VERSION_LESS 3.14)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else() else()
cmake_policy(VERSION 3.13) cmake_policy(VERSION 3.14)
endif() endif()
set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"") set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"")
...@@ -22,24 +23,44 @@ string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}") ...@@ -22,24 +23,44 @@ string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}")
# Add the project # Add the project
project(CLI11 LANGUAGES CXX VERSION ${VERSION_STRING}) project(CLI11 LANGUAGES CXX VERSION ${VERSION_STRING})
# Special target that adds warnings. Is not exported.
add_library(CLI11_warnings INTERFACE)
# 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
set(CLI11_CXX_STD "11" CACHE STRING "The CMake standard to require") set(CLI11_CXX_STD "11" CACHE STRING "The CMake standard to require")
# Special override for Clang on Linux (useful with an old stdlibc++ and a newer clang)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
option(CLI11_FORCE_LIBCXX "Force Clang to use libc++ instead of libstdc++ (Linux only)" OFF)
if(CLI11_FORCE_LIBCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
endif()
endif()
set(CUR_PROJ ON) set(CUR_PROJ ON)
set(CMAKE_CXX_STANDARD ${CLI11_CXX_STD}) set(CMAKE_CXX_STANDARD ${CLI11_CXX_STD})
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(CLI11_WARNINGS_AS_ERRORS "Turn all warnings into errors (for CI)")
# Be moderately paranoid with flags # Be moderately paranoid with flags
if(MSVC) if(MSVC)
add_definitions("/W4") target_compile_options(CLI11_warnings INTERFACE "/W4")
if(CLI11_WARNINGS_AS_ERRORS)
target_compile_options(CLI11_warnings INTERFACE "/WX")
endif()
else() else()
add_definitions(-Wall -Wextra -pedantic -Wshadow) target_compile_options(CLI11_warnings INTERFACE -Wall -Wextra -pedantic -Wshadow)
if(CLI11_WARNINGS_AS_ERRORS)
target_compile_options(CLI11_warnings INTERFACE -Werror)
endif()
endif() endif()
if(CMAKE_VERSION VERSION_GREATER 3.6) if(NOT CMAKE_VERSION VERSION_LESS 3.6)
# Add clang-tidy if available # Add clang-tidy if available
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF) option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
find_program( find_program(
...@@ -56,6 +77,17 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) ...@@ -56,6 +77,17 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
endif() endif()
endif() endif()
endif() endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.9)
find_package(Doxygen)
if(Doxygen_FOUND)
add_subdirectory(docs)
else()
message(STATUS "Doxygen not found, not building docs")
endif()
else()
message(STATUS "Newer CMake adds Doxygen support, update CMake for docs")
endif()
else() else()
set(CUR_PROJ OFF) set(CUR_PROJ OFF)
endif() endif()
...@@ -149,14 +181,23 @@ if(CLI11_SINGLE_FILE) ...@@ -149,14 +181,23 @@ if(CLI11_SINGLE_FILE)
target_include_directories(CLI11_SINGLE INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/include/") target_include_directories(CLI11_SINGLE INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/include/")
endif() endif()
cmake_dependent_option(CLI11_SINGLE_FILE_TESTS "Duplicate all the tests for a single file build" OFF "CLI11_SINGLE_FILE" OFF) cmake_dependent_option(CLI11_SINGLE_FILE_TESTS
"Duplicate all the tests for a single file build"
OFF
"CLI11_SINGLE_FILE"
OFF)
cmake_dependent_option(CLI11_TESTING "Build the tests and add them" ON "CUR_PROJ" OFF)
if(DEFINED BUILD_TESTING) if(DEFINED CLI11_TESTING)
cmake_dependent_option(CLI11_TESTING "" ON "BUILD_TESTING" OFF) set(CLI11_TESTING_INTERNAL "${CLI11_TESTING}")
message(STATUS "BUILD_TESTING is defined and it supersedes CLI11_TESTING. Has forced to ${CLI11_TESTING}") elseif(CUR_PROJ)
option(BUILD_TESTING "Build the tests" ON)
set(CLI11_TESTING_INTERNAL "${BUILD_TESTING}")
else()
set(CLI11_TESTING_INTERNAL OFF)
endif() endif()
if(CLI11_TESTING)
if(CLI11_TESTING_INTERNAL)
enable_testing() enable_testing()
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
......
CLI11 1.7 Copyright (c) 2017-2019 University of Cincinnati, developed by Henry CLI11 1.8 Copyright (c) 2017-2019 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.
...@@ -6,21 +6,87 @@ ...@@ -6,21 +6,87 @@
trigger: trigger:
- master - master
variables:
cli11.single: ON
cli11.std: 14
cli11.build_type: Debug
cli11.options:
CMAKE_BUILD_PARALLEL_LEVEL: 4
jobs: jobs:
- job: Linux
- job: ClangFormatTidy
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"
cli11.options: -DCLANG_TIDY_FIX=ON
cli11.std: 11
cli11.single: OFF
CMAKE_BUILD_PARALLEL_LEVEL: 1
pool: pool:
vmImage: 'ubuntu-16.04' vmImage: 'ubuntu-16.04'
container: silkeh/clang:5
steps: steps:
- template: .ci/azure-steps.yml - script: scripts/check_style.sh
displayName: Check format
- template: .ci/azure-cmake.yml
- template: .ci/azure-build.yml
- script: git diff --exit-code --color
displayName: Check tidy
- job: macOS - job: Native
strategy:
matrix:
Linux:
vmImage: 'ubuntu-latest'
macOS:
vmImage: 'macOS-latest'
Windows:
vmImage: 'vs2017-win2016'
pool: pool:
vmImage: 'macOS-10.13' vmImage: $(vmImage)
steps: steps:
- template: .ci/azure-steps.yml - template: .ci/azure-build.yml
- template: .ci/azure-test.yml
- job: Windows - job: Meson
pool: pool:
vmImage: 'vs2017-win2016' vmImage: 'ubuntu-latest'
steps: steps:
- template: .ci/azure-steps.yml - task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
- script: python3 -m pip install meson ninja
- script: meson build
displayName: Run meson to generate build
workingDirectory: tests/mesonTest
- script: ninja -C tests/mesonTest/build
displayName: Build with Ninja
- script: ./tests/mesonTest/build/main --help
displayName: Run help
- job: Docker
variables:
cli11.single: OFF
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
gcc9:
containerImage: gcc:9
cli11.std: 17
gcc4.8:
containerImage: gcc:4.8
cli11.std: 11
clang3.4:
containerImage: silkeh/clang:3.4
cli11.std: 11
clang8:
containerImage: silkeh/clang:8
cli11.std: 14
cli11.options: -DCLI11_FORCE_LIBCXX=ON
container: $[ variables['containerImage'] ]
steps:
- template: .ci/azure-cmake.yml
- template: .ci/azure-build.yml
- template: .ci/azure-test.yml
# Node rules:
## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
## Dependency directory
## Commenting this out is preferred by some people, see
## https://docs.npmjs.com/misc/faq#should-i-check-my-node_modules-folder-into-git
node_modules
# Book build output
_book
# eBook build output
*.epub
*.mobi
*.pdf
a.out
*build*
# CLI11: An introduction
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].
> 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 1:
```term
gitbook $ ./a.out
Parameter value: 0
gitbook $ ./a.out -p 4
Parameter value: 4
gitbook $ ./a.out --help
App description
Usage: ./a.out [OPTIONS]
Options:
-h,--help Print this help message and exit
-p INT Parameter
```
Like any good command line application, help is provided. This program can be implemented in 10 lines:
[include](code/intro.cpp)
[Source code](https://gitlab.com/CLIUtils/CLI11Tutorial/blob/master/code/intro.cpp)
Unlike some other libraries, this is enough to exit correctly and cleanly if help is requested or if incorrect arguments are passed. You can try this example out for yourself. To compile with GCC:
```term
gitbook:examples $ c++ -std=c++11 intro.cpp
```
Much more complicated options are handled elegantly:
```cpp
std::string req_real_file;
app.add_option("-f,--file", file, "Require an existing file")
->required()
->check(CLI::ExistingFile);
```
You can use any valid type; the above example could have used a `boost::file_system` file instead of a `std::string`. The value is a real value and does not require any special lookups to access. You do not have to risk typos by repeating the values after parsing like some libraries require. The library also handles positional arguments, flags, fixed or unlimited repeating options, interdependent options, flags, custom validators, help groups, and more.
You can use subcommands, as well. Subcommands support callback lambda functions when parsed, or they can be checked later. You can infinitely nest subcommands, and each is a full `App` instance, supporting everything listed above.
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.
This guide was based on CLI11 1.7.
[GooFit]: https://github.com/GooFit/GooFit
[DIANA/HEP]: http://diana-hep.org
[CLI11]: https://github.com/CLIUtils/CLI11
[CLI11Tutorial]: https://gitlab.com/CLIUtils/CLI11Tutorial
[releases]: https://github.com/CLIUtils/CLI11/releases
[API docs]: https://cliutils.github.io/CLI11
[README]: https://github.com/CLIUtils/CLI11/blob/master/README.md
[NSF 1414736]: https://nsf.gov/awardsearch/showAward?AWD_ID=1414736
[University of Cincinnati]: http://www.uc.edu
[Plumbum]: http://plumbum.readthedocs.io/en/latest/
[Click]: http://click.pocoo.org/5/
# Summary
* [Introduction](/README.md)
* [Installation](/chapters/installation.md)
* [Basics](/chapters/basics.md)
* [Flags](/chapters/flags.md)
* [Options](/chapters/options.md)
* [Validators](/chapters/validators.md)
* [Subcommands and the App](/chapters/subcommands.md)
* [An advanced example](/chapters/an-advanced-example.md)
* [Configuration files](/chapters/config.md)
* [Formatting help output](/chapters/formatting.md)
* [Toolkits](/chapters/toolkits.md)
* [Advanced topics](/chapters/advanced-topics.md)
* [Internals](/chapters/internals.md)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment