Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .ci/azure-cmake-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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.28/cmake-3.28.0-linux-x86_64.tar.gz"
echo "898f0b5ca6e2ea5286998e97bd33f030d7d09f18ca4b88be661fdfbad5dadd88 cmake-3.28.0-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.28.0-linux-x86_64/bin"
displayName: Add CMake to PATH
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# modernize-avoid-c-arrays trips up in TEMPLATE_TEST_CASE catch macro
# modernize-return-braced-init-list triggers on lambdas ?
# modernize-make-unique requires C++14
# modernize-type_traits requires C++17
# readability-avoid-const-params-in-decls Affected by the pre-compile split

Checks: |
Expand Down Expand Up @@ -37,6 +38,8 @@ Checks: |
-modernize-concat-nested-namespaces,
-modernize-return-braced-init-list,
-modernize-make-unique,
-modernize-type-traits,
-modernize-macro-to-enum,
*performance*,
-performance-unnecessary-value-param,
-performance-inefficient-string-concatenation,
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
clang-tidy:
name: Clang-Tidy
runs-on: ubuntu-latest
container: silkeh/clang:14
container: silkeh/clang:17
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
cuda12-build:
name: CUDA 12 build only
runs-on: ubuntu-latest
container: nvidia/cuda:12.1.0-devel-ubuntu22.04
container: nvidia/cuda:12.3.1-devel-ubuntu22.04
steps:
- name: Add build tools
run: apt-get update && apt-get install -y wget git cmake
Expand Down Expand Up @@ -336,9 +336,15 @@ jobs:
args: -DCLI11_SANITIZERS=ON -DCLI11_BUILD_EXAMPLES_JSON=ON
if: success() || failure()

- name: Check CMake 3.27 (full)
- name: Check CMake 3.27
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.27"
if: success() || failure()

- name: Check CMake 3.28 (full)
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.28"
args: -DCLI11_SANITIZERS=ON -DCLI11_BUILD_EXAMPLES_JSON=ON
if: success() || failure()
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 3.5)
# Note: this is a header only library. If you have an older CMake than 3.5,
# 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.5 to 3.26) version
# Make sure users don't get warnings on a tested (3.5 to 3.28) version
# of CMake. For most of the policies, the new version is better (hence the change).
# We don't use the 3.5...3.26 syntax because of a bug in an older MSVC's
# We don't use the 3.5...3.28 syntax because of a bug in an older MSVC's
# built-in and modified CMake 3.11
if(${CMAKE_VERSION} VERSION_LESS 3.26)
if(${CMAKE_VERSION} VERSION_LESS 3.28)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.26)
cmake_policy(VERSION 3.28)
endif()

set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"")
Expand Down
25 changes: 25 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,28 @@ jobs:
- template: .ci/azure-cmake.yml
- template: .ci/azure-build.yml
- template: .ci/azure-test.yml

- job: Docker_new
variables:
cli11.single: OFF
pool:
vmImage: "ubuntu-latest"
strategy:
matrix:
gcc13:
containerImage: gcc:13
cli11.std: 17
cli11.options: -DCMAKE_CXX_FLAGS="-Wstrict-overflow=5"
gcc12:
containerImage: gcc:12
cli11.std: 20
cli11.options: -DCMAKE_CXX_FLAGS="-Wredundant-decls -Wconversion"
clang17_20:
containerImage: silkeh/clang:17
cli11.std: 23
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23
container: $[ variables['containerImage'] ]
steps:
- template: .ci/azure-cmake-new.yml
- template: .ci/azure-build.yml
- template: .ci/azure-test.yml
2 changes: 1 addition & 1 deletion book/chapters/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ CLI::Option* opt = app.add_flag("--opt");
CLI11_PARSE(app, argv, argc);

if(* opt)
std::cout << "Flag received " << opt->count() << " times." << std::endl;
std::cout << "Flag received " << opt->count() << " times." << '\n';
```

## Inheritance of defaults
Expand Down
4 changes: 2 additions & 2 deletions examples/arg_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ int main(int argc, const char *argv[]) {
subcom->alias("--sub");
CLI11_PARSE(app, argc, argv);

std::cout << "value=" << value << std::endl;
std::cout << "value=" << value << '\n';
std::cout << "after Args:";
for(const auto &aarg : subcom->remaining()) {
std::cout << aarg << " ";
}
std::cout << std::endl;
std::cout << '\n';
}
6 changes: 3 additions & 3 deletions examples/config_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ int main(int argc, char **argv) {
}

std::cout << "Working on file: " << file << ", direct count: " << app.count("--file")
<< ", opt count: " << opt->count() << std::endl;
<< ", opt count: " << opt->count() << '\n';
std::cout << "Working on count: " << count << ", direct count: " << app.count("--count")
<< ", opt count: " << copt->count() << std::endl;
<< ", opt count: " << copt->count() << '\n';
std::cout << "Received flag: " << v << " (" << flag->count() << ") times\n";
std::cout << "Some value: " << value << std::endl;
std::cout << "Some value: " << value << '\n';

return 0;
}
2 changes: 1 addition & 1 deletion examples/custom_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using DoubleValues = Values<double>;

// the lexical cast operator should be in the same namespace as the type for ADL to work properly
bool lexical_cast(const std::string &input, Values<double> & /*v*/) {
std::cout << "called correct lexical_cast function ! val: " << input << std::endl;
std::cout << "called correct lexical_cast function ! val: " << input << '\n';
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/digit_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ int main(int argc, char **argv) {

CLI11_PARSE(app, argc, argv);

std::cout << "value = " << val << std::endl;
std::cout << "value = " << val << '\n';
return 0;
}
2 changes: 1 addition & 1 deletion examples/enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int argc, char **argv) {

// CLI11's built in enum streaming can be used outside CLI11 like this:
using CLI::enums::operator<<;
std::cout << "Enum received: " << level << std::endl;
std::cout << "Enum received: " << level << '\n';

return 0;
}
2 changes: 1 addition & 1 deletion examples/enum_ostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char **argv) {

// CLI11's built in enum streaming can be used outside CLI11 like this:
using CLI::enums::operator<<;
std::cout << "Enum received: " << level << std::endl;
std::cout << "Enum received: " << level << '\n';

return 0;
}
2 changes: 1 addition & 1 deletion examples/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, char **argv) {

CLI11_PARSE(app, argc, argv);

std::cout << "This app was meant to show off the formatter, run with -h" << std::endl;
std::cout << "This app was meant to show off the formatter, run with -h" << '\n';

return 0;
}
6 changes: 3 additions & 3 deletions examples/groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ int main(int argc, char **argv) {
}

std::cout << "Working on file: " << file << ", direct count: " << app.count("--file")
<< ", opt count: " << opt->count() << std::endl;
<< ", opt count: " << opt->count() << '\n';
std::cout << "Working on count: " << count << ", direct count: " << app.count("--count")
<< ", opt count: " << copt->count() << std::endl;
std::cout << "Some value: " << value << std::endl;
<< ", opt count: " << copt->count() << '\n';
std::cout << "Some value: " << value << '\n';

return 0;
}
2 changes: 1 addition & 1 deletion examples/inter_argument_order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ int main(int argc, char **argv) {

// Prove the vector is correct
for(auto &pair : keyval) {
std::cout << pair.first << " : " << pair.second << std::endl;
std::cout << pair.first << " : " << pair.second << '\n';
}
}
4 changes: 2 additions & 2 deletions examples/modhelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Note that this will not shortcut `->required` and other similar options.)raw"};
if(*help)
throw CLI::CallForHelp();
} catch(const CLI::Error &e) {
std::cout << "Option -a string in help: " << some_option << std::endl;
std::cout << "Option -a string in help: " << some_option << '\n';
return test.exit(e);
}

std::cout << "Option -a string: " << some_option << std::endl;
std::cout << "Option -a string: " << some_option << '\n';
return 0;
}
8 changes: 4 additions & 4 deletions examples/option_groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ int main(int argc, char **argv) {
CLI11_PARSE(app, argc, argv);

std::string format_type = (csv) ? std::string("CSV") : ((human) ? "human readable" : "binary");
std::cout << "Selected " << format_type << " format" << std::endl;
std::cout << "Selected " << format_type << " format\n";
if(!fileLoc.empty()) {
std::cout << " sent to file " << fileLoc << std::endl;
std::cout << " sent to file " << fileLoc << '\n';
} else if(!networkAddress.empty()) {
std::cout << " sent over network to " << networkAddress << std::endl;
std::cout << " sent over network to " << networkAddress << '\n';
} else {
std::cout << " sent to std::cout" << std::endl;
std::cout << " sent to std::cout\n";
}

return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/prefix_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ int main(int argc, char **argv) {
for(int v : vals)
std::cout << ": " << v << " ";

std::cout << std::endl << "Remaining commands: ";
std::cout << '\n' << "Remaining commands: ";

for(const auto &com : more_comms)
std::cout << com << " ";
std::cout << std::endl;
std::cout << '\n';

return 0;
}
6 changes: 3 additions & 3 deletions examples/shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(int argc, char **argv) {
int circle_counter{0};
circle->callback([&radius, &circle_counter] {
++circle_counter;
std::cout << "circle" << circle_counter << " with radius " << radius << std::endl;
std::cout << "circle" << circle_counter << " with radius " << radius << '\n';
});

circle->add_option("radius", radius, "the radius of the circle")->required();
Expand All @@ -32,7 +32,7 @@ int main(int argc, char **argv) {
if(edge2 == 0) {
edge2 = edge1;
}
std::cout << "rectangle" << rect_counter << " with edges [" << edge1 << ',' << edge2 << "]" << std::endl;
std::cout << "rectangle" << rect_counter << " with edges [" << edge1 << ',' << edge2 << "]\n";
edge2 = 0;
});

Expand All @@ -45,7 +45,7 @@ int main(int argc, char **argv) {
tri->callback([&sides, &tri_counter] {
++tri_counter;

std::cout << "triangle" << tri_counter << " with sides [" << CLI::detail::join(sides) << "]" << std::endl;
std::cout << "triangle" << tri_counter << " with sides [" << CLI::detail::join(sides) << "]\n";
});

tri->add_option("sides", sides, "the side lengths of the triangle");
Expand Down
6 changes: 3 additions & 3 deletions examples/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ int main(int argc, char **argv) {
CLI11_PARSE(app, argc, argv);

std::cout << "Working on file: " << file << ", direct count: " << app.count("--file")
<< ", opt count: " << opt->count() << std::endl;
<< ", opt count: " << opt->count() << '\n';
std::cout << "Working on count: " << count << ", direct count: " << app.count("--count")
<< ", opt count: " << copt->count() << std::endl;
<< ", opt count: " << copt->count() << '\n';
std::cout << "Received flag: " << v << " (" << flag->count() << ") times\n";
std::cout << "Some value: " << value << std::endl;
std::cout << "Some value: " << value << '\n';

return 0;
}
2 changes: 1 addition & 1 deletion examples/subcom_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) {
cli_sub.add_option("sub_arg", sub_arg, "Argument for subcommand")->required();
CLI11_PARSE(cli_global, argc, argv);
if(cli_sub) {
std::cout << "Got: " << sub_arg << std::endl;
std::cout << "Got: " << sub_arg << '\n';
}
return 0;
}
4 changes: 2 additions & 2 deletions examples/subcom_in_files/subcommand_a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ void setup_subcommand_a(CLI::App &app) {
/// but having a separate function is cleaner.
void run_subcommand_a(SubcommandAOptions const &opt) {
// Do stuff...
std::cout << "Working on file: " << opt.file << std::endl;
std::cout << "Working on file: " << opt.file << '\n';
if(opt.with_foo) {
std::cout << "Using foo!" << std::endl;
std::cout << "Using foo!" << '\n';
}
}
6 changes: 3 additions & 3 deletions examples/subcom_partitioned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ int main(int argc, char **argv) {
}

std::cout << "Working on file: " << file << ", direct count: " << impOpt->count("--file")
<< ", opt count: " << opt->count() << std::endl;
<< ", opt count: " << opt->count() << '\n';
std::cout << "Working on count: " << count << ", direct count: " << impOpt->count("--count")
<< ", opt count: " << copt->count() << std::endl;
std::cout << "Some value: " << value << std::endl;
<< ", opt count: " << copt->count() << '\n';
std::cout << "Some value: " << value << '\n';

return 0;
}
9 changes: 4 additions & 5 deletions examples/subcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ int main(int argc, char **argv) {

CLI11_PARSE(app, argc, argv);

std::cout << "Working on --file from start: " << file << std::endl;
std::cout << "Working on --count from stop: " << s->count() << ", direct count: " << stop->count("--count")
<< std::endl;
std::cout << "Count of --random flag: " << app.count("--random") << std::endl;
std::cout << "Working on --file from start: " << file << '\n';
std::cout << "Working on --count from stop: " << s->count() << ", direct count: " << stop->count("--count") << '\n';
std::cout << "Count of --random flag: " << app.count("--random") << '\n';
for(auto *subcom : app.get_subcommands())
std::cout << "Subcommand: " << subcom->get_name() << std::endl;
std::cout << "Subcommand: " << subcom->get_name() << '\n';

return 0;
}
4 changes: 2 additions & 2 deletions examples/testEXE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ int main(int argc, const char *argv[]) {
auto *subcom = app.add_subcommand("sub", "")->prefix_command();
CLI11_PARSE(app, argc, argv);

std::cout << "value =" << value << std::endl;
std::cout << "value =" << value << '\n';
std::cout << "after Args:";
for(const auto &aarg : subcom->remaining()) {
std::cout << aarg << " ";
}
std::cout << std::endl;
std::cout << '\n';
}
2 changes: 1 addition & 1 deletion examples/validators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main(int argc, char **argv) {
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;
std::cout << "Try printing help or failing the validator" << '\n';

return 0;
}
2 changes: 1 addition & 1 deletion include/CLI/Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class AutoTimer : public Timer {
// GCC 4.7 does not support using inheriting constructors.

/// This destructor prints the string
~AutoTimer() { std::cout << to_string() << std::endl; }
~AutoTimer() { std::cout << to_string() << '\n'; }
};

} // namespace CLI
Expand Down
Loading