From 24a8fd2098bc4beb26aefbf6a75c65590eebbb66 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Sun, 12 Jan 2020 12:28:07 +0100 Subject: [PATCH 01/14] Add cpplint config file --- CPPLINT.cfg | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 CPPLINT.cfg diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 000000000..ffacd42af --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,16 @@ +set noparent +linelength=120 # As in .clang-format + +# Non-used filters +filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format +filter=-readability/nolint # Conficts with clang-tidy +filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability +filter=-build/c++11 # Only complains about chrono being an unapproved C++11 header + +# Filters to be included in future +#filter=-build # TODO discuss build flags such as include order +filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use,-build_include + +# To be discussed +filter=-legal/copyright,-runtime/references,-runtime/int,-build/include_order + From 1f908046c53c722704fe7c7c4f63ab9eabe798a6 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Sun, 12 Jan 2020 17:52:13 +0100 Subject: [PATCH 02/14] Add cpplint to CI --- azure-pipelines.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bd4e42699..261a08711 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,6 +31,14 @@ jobs: - script: git diff --exit-code --color displayName: Check tidy +- job: CppLint + pool: + vmImage: 'ubuntu-latest' + container: sharaku/cpplint + steps: + - bash: cpplint --counting=detailed --recursive examples include/CLI + displayName: Checking against google style guide + # TODO: Fix macOS error and windows warning in c++17 mode - job: Native strategy: From de13555656bd6e7435610b7d206da0b5eb6428ed Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Sun, 12 Jan 2020 18:01:33 +0100 Subject: [PATCH 03/14] Add checks --- CPPLINT.cfg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CPPLINT.cfg b/CPPLINT.cfg index ffacd42af..b2d61f002 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -5,11 +5,10 @@ linelength=120 # As in .clang-format filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format filter=-readability/nolint # Conficts with clang-tidy filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability -filter=-build/c++11 # Only complains about chrono being an unapproved C++11 header # Filters to be included in future #filter=-build # TODO discuss build flags such as include order -filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use,-build_include +filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use # To be discussed filter=-legal/copyright,-runtime/references,-runtime/int,-build/include_order From 911d139a4dafacc12d60699c897f4542fa30be09 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Sun, 12 Jan 2020 18:35:59 +0100 Subject: [PATCH 04/14] Add docker container tag --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 261a08711..74d2fce4c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,7 +34,7 @@ jobs: - job: CppLint pool: vmImage: 'ubuntu-latest' - container: sharaku/cpplint + container: sharaku/cpplint:latest steps: - bash: cpplint --counting=detailed --recursive examples include/CLI displayName: Checking against google style guide From 1b7bfe9b33393b37b1e0f68e80af6cc224e6e134 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Mon, 13 Jan 2020 19:14:58 +0100 Subject: [PATCH 05/14] Unindent container As suggested in code review Co-Authored-By: Henry Schreiner --- azure-pipelines.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 74d2fce4c..d01a24069 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,7 +34,7 @@ jobs: - job: CppLint pool: vmImage: 'ubuntu-latest' - container: sharaku/cpplint:latest + container: sharaku/cpplint:latest steps: - bash: cpplint --counting=detailed --recursive examples include/CLI displayName: Checking against google style guide @@ -105,4 +105,3 @@ jobs: - template: .ci/azure-cmake.yml - template: .ci/azure-build.yml - template: .ci/azure-test.yml - From aadb8cfb0343ad08e7c9bcfb05b7c9f680d98c76 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Mon, 13 Jan 2020 20:18:11 +0100 Subject: [PATCH 06/14] Fix cpplint issues --- examples/subcom_in_files/subcommand_a.hpp | 1 + include/CLI/App.hpp | 4 +--- include/CLI/Timer.hpp | 7 ++++--- include/CLI/Validators.hpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/subcom_in_files/subcommand_a.hpp b/examples/subcom_in_files/subcommand_a.hpp index 90625650a..f05d6bf69 100644 --- a/examples/subcom_in_files/subcommand_a.hpp +++ b/examples/subcom_in_files/subcommand_a.hpp @@ -1,3 +1,4 @@ +#pragma once // =================================================================== // subcommand_a.hpp // =================================================================== diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 5c616378a..829835ea3 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -2657,9 +2657,7 @@ class App { auto res = op->get_flag_value(arg_name, value); op->add_result(res); parse_order_.push_back(op.get()); - } - // --this=value - else if(!value.empty()) { + } else if(!value.empty()) { // --this=value op->add_result(value, result_count); parse_order_.push_back(op.get()); collected += result_count; diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index 683839d08..c1ef59507 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -10,7 +10,7 @@ #endif #include -#include +#include //NOLINT(build/c++11) #include #include #include @@ -87,8 +87,9 @@ class Timer { /// This prints out a time string from a time std::string make_time_str(double time) const { auto print_it = [](double x, std::string unit) { - std::array buffer; - std::snprintf(buffer.data(), 50, "%.5g", x); + const unsigned int buffer_length = 50; + std::array buffer; + std::snprintf(buffer.data(), buffer_length, "%.5g", x); return buffer.data() + std::string(" ") + unit; }; diff --git a/include/CLI/Validators.hpp b/include/CLI/Validators.hpp index 90dfed65d..2ea5c8f33 100644 --- a/include/CLI/Validators.hpp +++ b/include/CLI/Validators.hpp @@ -35,7 +35,7 @@ #endif #if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0 -#include +#include // NOLINT(build/include) #else #include #include From 3765b02444d2ac7fa3818a380432f60bd80ef05a Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Mon, 13 Jan 2020 20:24:59 +0100 Subject: [PATCH 07/14] Fix clang-format --- include/CLI/App.hpp | 2 +- include/CLI/Timer.hpp | 2 +- include/CLI/Validators.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 829835ea3..16e78ee61 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -2657,7 +2657,7 @@ class App { auto res = op->get_flag_value(arg_name, value); op->add_result(res); parse_order_.push_back(op.get()); - } else if(!value.empty()) { // --this=value + } else if(!value.empty()) { // --this=value op->add_result(value, result_count); parse_order_.push_back(op.get()); collected += result_count; diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index c1ef59507..3b7f360a9 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -10,7 +10,7 @@ #endif #include -#include //NOLINT(build/c++11) +#include //NOLINT(build/c++11) #include #include #include diff --git a/include/CLI/Validators.hpp b/include/CLI/Validators.hpp index 2ea5c8f33..937f9c274 100644 --- a/include/CLI/Validators.hpp +++ b/include/CLI/Validators.hpp @@ -35,7 +35,7 @@ #endif #if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0 -#include // NOLINT(build/include) +#include // NOLINT(build/include) #else #include #include From e380ce6425942e6037584ec0c8c9db7dd1006105 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Tue, 14 Jan 2020 19:51:41 +0100 Subject: [PATCH 08/14] Include and fix modern cpplint runtime/int --- CPPLINT.cfg | 5 +++-- include/CLI/TypeTools.hpp | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CPPLINT.cfg b/CPPLINT.cfg index b2d61f002..24ce72e41 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -5,11 +5,12 @@ linelength=120 # As in .clang-format filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format filter=-readability/nolint # Conficts with clang-tidy filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability +filter=-runtime/references # Requires fundamental change of API, don't see need for this # Filters to be included in future -#filter=-build # TODO discuss build flags such as include order filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use +filter=-legal/copyright # Remove this line after Version 1.9 # To be discussed -filter=-legal/copyright,-runtime/references,-runtime/int,-build/include_order +filter=-build/include_order diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index 3438e573a..bbe526884 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -595,9 +595,9 @@ template (output_ll); - return n == input.size() && static_cast(output) == output_ll; + return n == input.size() && static_cast(output) == output_ll; } catch(const std::invalid_argument &) { return false; } catch(const std::out_of_range &) { @@ -614,9 +614,9 @@ bool lexical_cast(const std::string &input, T &output) { try { std::size_t n = 0; - unsigned long long output_ll = std::stoull(input, &n, 0); + uint64_t output_ll = std::stoull(input, &n, 0); output = static_cast(output_ll); - return n == input.size() && static_cast(output) == output_ll; + return n == input.size() && static_cast(output) == output_ll; } catch(const std::invalid_argument &) { return false; } catch(const std::out_of_range &) { From bddb6a2d6744c5397f387ccd03416a1ec5e29862 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Tue, 14 Jan 2020 20:11:13 +0100 Subject: [PATCH 09/14] Include and fix cpplint build/include_order --- CPPLINT.cfg | 7 ++----- examples/digit_args.cpp | 3 ++- examples/enum.cpp | 3 ++- examples/enum_ostream.cpp | 2 +- examples/formatter.cpp | 2 +- examples/inter_argument_order.cpp | 3 ++- examples/json.cpp | 2 +- examples/modhelp.cpp | 3 +-- examples/nested.cpp | 3 ++- examples/retired.cpp | 3 ++- examples/subcom_help.cpp | 3 ++- examples/subcom_in_files/subcommand_a.hpp | 3 ++- include/CLI/TypeTools.hpp | 3 ++- include/CLI/Validators.hpp | 8 ++++---- 14 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CPPLINT.cfg b/CPPLINT.cfg index 24ce72e41..bab85f83a 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1,7 +1,7 @@ set noparent linelength=120 # As in .clang-format -# Non-used filters +# Unused filters filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format filter=-readability/nolint # Conficts with clang-tidy filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability @@ -9,8 +9,5 @@ filter=-runtime/references # Requires fundamental change of API, don't see need # Filters to be included in future filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use -filter=-legal/copyright # Remove this line after Version 1.9 - -# To be discussed -filter=-build/include_order +filter=-legal/copyright # Include this check line after Version 1.9 diff --git a/examples/digit_args.cpp b/examples/digit_args.cpp index c2193c875..f702673fc 100644 --- a/examples/digit_args.cpp +++ b/examples/digit_args.cpp @@ -1,6 +1,7 @@ -#include #include +#include "CLI/CLI.hpp" + int main(int argc, char **argv) { CLI::App app; diff --git a/examples/enum.cpp b/examples/enum.cpp index a5f84f983..67753667d 100644 --- a/examples/enum.cpp +++ b/examples/enum.cpp @@ -1,6 +1,7 @@ -#include #include +#include "CLI/CLI.hpp" + enum class Level : int { High, Medium, Low }; int main(int argc, char **argv) { diff --git a/examples/enum_ostream.cpp b/examples/enum_ostream.cpp index 62bc69711..5fd7b26c9 100644 --- a/examples/enum_ostream.cpp +++ b/examples/enum_ostream.cpp @@ -1,4 +1,4 @@ -#include +#include "CLI/CLI.hpp" enum class Level : int { High, Medium, Low }; diff --git a/examples/formatter.cpp b/examples/formatter.cpp index 4d67ec612..07ea9eb6d 100644 --- a/examples/formatter.cpp +++ b/examples/formatter.cpp @@ -1,4 +1,4 @@ -#include +#include "CLI/CLI.hpp" class MyFormatter : public CLI::Formatter { public: diff --git a/examples/inter_argument_order.cpp b/examples/inter_argument_order.cpp index 23f8fec36..72203bf55 100644 --- a/examples/inter_argument_order.cpp +++ b/examples/inter_argument_order.cpp @@ -1,9 +1,10 @@ -#include #include #include #include #include +#include "CLI/CLI.hpp" + int main(int argc, char **argv) { CLI::App app{"An app to practice mixing unlimited arguments, but still recover the original order."}; diff --git a/examples/json.cpp b/examples/json.cpp index b4c8101ae..67665841e 100644 --- a/examples/json.cpp +++ b/examples/json.cpp @@ -1,4 +1,4 @@ -#include +#include "CLI/CLI.hpp" #include // This example is only built on GCC 7 on Travis due to mismatch in stdlib diff --git a/examples/modhelp.cpp b/examples/modhelp.cpp index a2568322a..f153339a8 100644 --- a/examples/modhelp.cpp +++ b/examples/modhelp.cpp @@ -1,8 +1,7 @@ +#include #include "CLI/CLI.hpp" -#include - int main(int argc, char **argv) { CLI::App test{R"raw(Modify the help print so that argument values are accessible. Note that this will not shortcut `->required` and other similar options.)raw"}; diff --git a/examples/nested.cpp b/examples/nested.cpp index 1714b8df5..fa19f450e 100644 --- a/examples/nested.cpp +++ b/examples/nested.cpp @@ -1,6 +1,7 @@ -#include #include +#include "CLI/CLI.hpp" + int main(int argc, char **argv) { CLI::App app("Vision Application"); diff --git a/examples/retired.cpp b/examples/retired.cpp index 6c205309f..92297a94a 100644 --- a/examples/retired.cpp +++ b/examples/retired.cpp @@ -1,6 +1,7 @@ -#include "CLI/CLI.hpp" #include +#include "CLI/CLI.hpp" + // This example shows the usage of the retired and deprecated option helper methods int main(int argc, char **argv) { diff --git a/examples/subcom_help.cpp b/examples/subcom_help.cpp index 0d8997d9d..6b765615c 100644 --- a/examples/subcom_help.cpp +++ b/examples/subcom_help.cpp @@ -1,6 +1,7 @@ -#include #include +#include "CLI/CLI.hpp" + int main(int argc, char *argv[]) { CLI::App cli_global{"Demo app"}; auto &cli_sub = *cli_global.add_subcommand("sub", "Some subcommand"); diff --git a/examples/subcom_in_files/subcommand_a.hpp b/examples/subcom_in_files/subcommand_a.hpp index f05d6bf69..23bb82167 100644 --- a/examples/subcom_in_files/subcommand_a.hpp +++ b/examples/subcom_in_files/subcommand_a.hpp @@ -3,10 +3,11 @@ // subcommand_a.hpp // =================================================================== -#include "CLI/CLI.hpp" #include #include +#include "CLI/CLI.hpp" + /// Collection of all options of Subcommand A. struct SubcommandAOptions { std::string file; diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index bbe526884..ec3e9dde9 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -3,13 +3,14 @@ // Distributed under the 3-Clause BSD License. See accompanying // file LICENSE or https://github.com/CLIUtils/CLI11 for details. -#include "StringTools.hpp" #include #include #include #include #include +#include "StringTools.hpp" + namespace CLI { // Type tools diff --git a/include/CLI/Validators.hpp b/include/CLI/Validators.hpp index 937f9c274..f6de6991a 100644 --- a/include/CLI/Validators.hpp +++ b/include/CLI/Validators.hpp @@ -2,10 +2,6 @@ // Distributed under the 3-Clause BSD License. See accompanying // file LICENSE or https://github.com/CLIUtils/CLI11 for details. -#include "CLI/Macros.hpp" -#include "CLI/StringTools.hpp" -#include "CLI/TypeTools.hpp" - #include #include #include @@ -14,6 +10,10 @@ #include #include +#include "CLI/Macros.hpp" +#include "CLI/StringTools.hpp" +#include "CLI/TypeTools.hpp" + // [CLI11:verbatim] // C standard library From caeefc22c49729dd3332fc0433288fff01b3159f Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Fri, 17 Jan 2020 18:18:50 +0100 Subject: [PATCH 10/14] Revert "Include and fix cpplint build/include_order" This reverts commit bddb6a2d6744c5397f387ccd03416a1ec5e29862. --- CPPLINT.cfg | 7 +++++-- examples/digit_args.cpp | 3 +-- examples/enum.cpp | 3 +-- examples/enum_ostream.cpp | 2 +- examples/formatter.cpp | 2 +- examples/inter_argument_order.cpp | 3 +-- examples/json.cpp | 2 +- examples/modhelp.cpp | 3 ++- examples/nested.cpp | 3 +-- examples/retired.cpp | 3 +-- examples/subcom_help.cpp | 3 +-- examples/subcom_in_files/subcommand_a.hpp | 3 +-- include/CLI/TypeTools.hpp | 3 +-- include/CLI/Validators.hpp | 8 ++++---- 14 files changed, 22 insertions(+), 26 deletions(-) diff --git a/CPPLINT.cfg b/CPPLINT.cfg index bab85f83a..24ce72e41 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1,7 +1,7 @@ set noparent linelength=120 # As in .clang-format -# Unused filters +# Non-used filters filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format filter=-readability/nolint # Conficts with clang-tidy filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability @@ -9,5 +9,8 @@ filter=-runtime/references # Requires fundamental change of API, don't see need # Filters to be included in future filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use -filter=-legal/copyright # Include this check line after Version 1.9 +filter=-legal/copyright # Remove this line after Version 1.9 + +# To be discussed +filter=-build/include_order diff --git a/examples/digit_args.cpp b/examples/digit_args.cpp index f702673fc..c2193c875 100644 --- a/examples/digit_args.cpp +++ b/examples/digit_args.cpp @@ -1,7 +1,6 @@ +#include #include -#include "CLI/CLI.hpp" - int main(int argc, char **argv) { CLI::App app; diff --git a/examples/enum.cpp b/examples/enum.cpp index 67753667d..a5f84f983 100644 --- a/examples/enum.cpp +++ b/examples/enum.cpp @@ -1,7 +1,6 @@ +#include #include -#include "CLI/CLI.hpp" - enum class Level : int { High, Medium, Low }; int main(int argc, char **argv) { diff --git a/examples/enum_ostream.cpp b/examples/enum_ostream.cpp index 5fd7b26c9..62bc69711 100644 --- a/examples/enum_ostream.cpp +++ b/examples/enum_ostream.cpp @@ -1,4 +1,4 @@ -#include "CLI/CLI.hpp" +#include enum class Level : int { High, Medium, Low }; diff --git a/examples/formatter.cpp b/examples/formatter.cpp index 07ea9eb6d..4d67ec612 100644 --- a/examples/formatter.cpp +++ b/examples/formatter.cpp @@ -1,4 +1,4 @@ -#include "CLI/CLI.hpp" +#include class MyFormatter : public CLI::Formatter { public: diff --git a/examples/inter_argument_order.cpp b/examples/inter_argument_order.cpp index 72203bf55..23f8fec36 100644 --- a/examples/inter_argument_order.cpp +++ b/examples/inter_argument_order.cpp @@ -1,10 +1,9 @@ +#include #include #include #include #include -#include "CLI/CLI.hpp" - int main(int argc, char **argv) { CLI::App app{"An app to practice mixing unlimited arguments, but still recover the original order."}; diff --git a/examples/json.cpp b/examples/json.cpp index 67665841e..b4c8101ae 100644 --- a/examples/json.cpp +++ b/examples/json.cpp @@ -1,4 +1,4 @@ -#include "CLI/CLI.hpp" +#include #include // This example is only built on GCC 7 on Travis due to mismatch in stdlib diff --git a/examples/modhelp.cpp b/examples/modhelp.cpp index f153339a8..a2568322a 100644 --- a/examples/modhelp.cpp +++ b/examples/modhelp.cpp @@ -1,7 +1,8 @@ -#include #include "CLI/CLI.hpp" +#include + int main(int argc, char **argv) { CLI::App test{R"raw(Modify the help print so that argument values are accessible. Note that this will not shortcut `->required` and other similar options.)raw"}; diff --git a/examples/nested.cpp b/examples/nested.cpp index fa19f450e..1714b8df5 100644 --- a/examples/nested.cpp +++ b/examples/nested.cpp @@ -1,7 +1,6 @@ +#include #include -#include "CLI/CLI.hpp" - int main(int argc, char **argv) { CLI::App app("Vision Application"); diff --git a/examples/retired.cpp b/examples/retired.cpp index 92297a94a..6c205309f 100644 --- a/examples/retired.cpp +++ b/examples/retired.cpp @@ -1,6 +1,5 @@ -#include - #include "CLI/CLI.hpp" +#include // This example shows the usage of the retired and deprecated option helper methods int main(int argc, char **argv) { diff --git a/examples/subcom_help.cpp b/examples/subcom_help.cpp index 6b765615c..0d8997d9d 100644 --- a/examples/subcom_help.cpp +++ b/examples/subcom_help.cpp @@ -1,7 +1,6 @@ +#include #include -#include "CLI/CLI.hpp" - int main(int argc, char *argv[]) { CLI::App cli_global{"Demo app"}; auto &cli_sub = *cli_global.add_subcommand("sub", "Some subcommand"); diff --git a/examples/subcom_in_files/subcommand_a.hpp b/examples/subcom_in_files/subcommand_a.hpp index 23bb82167..f05d6bf69 100644 --- a/examples/subcom_in_files/subcommand_a.hpp +++ b/examples/subcom_in_files/subcommand_a.hpp @@ -3,11 +3,10 @@ // subcommand_a.hpp // =================================================================== +#include "CLI/CLI.hpp" #include #include -#include "CLI/CLI.hpp" - /// Collection of all options of Subcommand A. struct SubcommandAOptions { std::string file; diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index ec3e9dde9..bbe526884 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -3,14 +3,13 @@ // Distributed under the 3-Clause BSD License. See accompanying // file LICENSE or https://github.com/CLIUtils/CLI11 for details. +#include "StringTools.hpp" #include #include #include #include #include -#include "StringTools.hpp" - namespace CLI { // Type tools diff --git a/include/CLI/Validators.hpp b/include/CLI/Validators.hpp index f6de6991a..937f9c274 100644 --- a/include/CLI/Validators.hpp +++ b/include/CLI/Validators.hpp @@ -2,6 +2,10 @@ // Distributed under the 3-Clause BSD License. See accompanying // file LICENSE or https://github.com/CLIUtils/CLI11 for details. +#include "CLI/Macros.hpp" +#include "CLI/StringTools.hpp" +#include "CLI/TypeTools.hpp" + #include #include #include @@ -10,10 +14,6 @@ #include #include -#include "CLI/Macros.hpp" -#include "CLI/StringTools.hpp" -#include "CLI/TypeTools.hpp" - // [CLI11:verbatim] // C standard library From 14f0566961eb1835f135156ac1edb03c58d2c66c Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Fri, 17 Jan 2020 18:23:21 +0100 Subject: [PATCH 11/14] Update explanation, sort alphabetically --- CPPLINT.cfg | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CPPLINT.cfg b/CPPLINT.cfg index 24ce72e41..0b5f205f3 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -2,15 +2,13 @@ set noparent linelength=120 # As in .clang-format # Non-used filters -filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format +filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers filter=-readability/nolint # Conficts with clang-tidy -filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability filter=-runtime/references # Requires fundamental change of API, don't see need for this +filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability +filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format # Filters to be included in future filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use filter=-legal/copyright # Remove this line after Version 1.9 -# To be discussed -filter=-build/include_order - From 03640836a4cd05e4cb622bebb25692e3053c226b Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Fri, 17 Jan 2020 18:28:59 +0100 Subject: [PATCH 12/14] Implement suggestion from code review Co-Authored-By: Henry Schreiner --- include/CLI/Timer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index 3b7f360a9..cc2ba8b33 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -10,7 +10,7 @@ #endif #include -#include //NOLINT(build/c++11) +#include // NOLINT(build/c++11) #include #include #include From 6d0ee4bdb3890023d1b043efbf604ff93fe1d281 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Sat, 18 Jan 2020 12:03:00 +0100 Subject: [PATCH 13/14] Include cstdint header, prefix its symbols with std:: --- include/CLI/TypeTools.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index bbe526884..24d958c0f 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -4,6 +4,7 @@ // file LICENSE or https://github.com/CLIUtils/CLI11 for details. #include "StringTools.hpp" +#include #include #include #include @@ -595,9 +596,9 @@ template (output_ll); - return n == input.size() && static_cast(output) == output_ll; + return n == input.size() && static_cast(output) == output_ll; } catch(const std::invalid_argument &) { return false; } catch(const std::out_of_range &) { @@ -614,7 +615,7 @@ bool lexical_cast(const std::string &input, T &output) { try { std::size_t n = 0; - uint64_t output_ll = std::stoull(input, &n, 0); + std::uint64_t output_ll = std::stoull(input, &n, 0); output = static_cast(output_ll); return n == input.size() && static_cast(output) == output_ll; } catch(const std::invalid_argument &) { From 0309fdb20abf98555ed9cabe527dbae82a92f793 Mon Sep 17 00:00:00 2001 From: Christoph Bachhuber Date: Sat, 18 Jan 2020 12:14:51 +0100 Subject: [PATCH 14/14] Forgot std:: --- include/CLI/TypeTools.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index 24d958c0f..fd4542a62 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -617,7 +617,7 @@ bool lexical_cast(const std::string &input, T &output) { std::size_t n = 0; std::uint64_t output_ll = std::stoull(input, &n, 0); output = static_cast(output_ll); - return n == input.size() && static_cast(output) == output_ll; + return n == input.size() && static_cast(output) == output_ll; } catch(const std::invalid_argument &) { return false; } catch(const std::out_of_range &) {