Commit fda6126d7cc955f2ae3342fa8bbcdc036bb76f48
Committed by
Henry Schreiner
1 parent
8ecce8fd
Adding pre-commit
Showing
16 changed files
with
132 additions
and
81 deletions
.clang-format
| ... | ... | @@ -19,7 +19,7 @@ BasedOnStyle: LLVM |
| 19 | 19 | # AlwaysBreakTemplateDeclarations: false |
| 20 | 20 | BinPackArguments: false |
| 21 | 21 | BinPackParameters: false |
| 22 | -# BraceWrapping: | |
| 22 | +# BraceWrapping: | |
| 23 | 23 | # AfterClass: false |
| 24 | 24 | # AfterControlStatement: false |
| 25 | 25 | # AfterEnum: false |
| ... | ... | @@ -69,7 +69,7 @@ IndentWidth: 4 |
| 69 | 69 | # PenaltyReturnTypeOnItsOwnLine: 60 |
| 70 | 70 | # PointerAlignment: Right |
| 71 | 71 | # ReflowComments: true |
| 72 | -SortIncludes: false | |
| 72 | +SortIncludes: true | |
| 73 | 73 | # SpaceAfterCStyleCast: false |
| 74 | 74 | # SpaceAfterTemplateKeyword: true |
| 75 | 75 | # SpaceBeforeAssignmentOperators: true | ... | ... |
azure-pipelines.yml
| ... | ... | @@ -15,7 +15,24 @@ variables: |
| 15 | 15 | |
| 16 | 16 | jobs: |
| 17 | 17 | |
| 18 | -- job: ClangFormatTidy | |
| 18 | +- job: Formatting | |
| 19 | + pool: | |
| 20 | + vmImage: 'ubuntu-16.04' | |
| 21 | + steps: | |
| 22 | + - task: UsePythonVersion@0 | |
| 23 | + inputs: | |
| 24 | + versionSpec: '3.7' | |
| 25 | + architecture: 'x64' | |
| 26 | + - script: python -m pip install pre-commit | |
| 27 | + displayName: Install pre-commit | |
| 28 | + - script: pre-commit run --all | |
| 29 | + displayName: Run pre-commit | |
| 30 | + - script: git diff --exit-code | |
| 31 | + displayName: Display format changes | |
| 32 | + condition: always() | |
| 33 | + | |
| 34 | + | |
| 35 | +- job: ClangTidy | |
| 19 | 36 | variables: |
| 20 | 37 | 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" |
| 21 | 38 | cli11.options: -DCLANG_TIDY_FIX=ON |
| ... | ... | @@ -26,8 +43,6 @@ jobs: |
| 26 | 43 | vmImage: 'ubuntu-16.04' |
| 27 | 44 | container: silkeh/clang:5 |
| 28 | 45 | steps: |
| 29 | - - script: scripts/check_style.sh | |
| 30 | - displayName: Check format | |
| 31 | 46 | - template: .ci/azure-cmake.yml |
| 32 | 47 | - template: .ci/azure-build.yml |
| 33 | 48 | - script: git diff --exit-code --color | ... | ... |
book/chapters/config.md
| ... | ... | @@ -44,10 +44,10 @@ std::vector<CLI::ConfigItem> from_config(std::istream &input) const; |
| 44 | 44 | |
| 45 | 45 | The `CLI::ConfigItem`s that you return are simple structures with a name, a vector of parents, and a vector of results. A optionally customizable `to_flag` method on the formatter lets you change what happens when a ConfigItem turns into a flag. |
| 46 | 46 | |
| 47 | -Finally, set your new class as new config formatter: | |
| 47 | +Finally, set your new class as new config formatter: | |
| 48 | 48 | |
| 49 | 49 | ```cpp |
| 50 | 50 | app.config_formatter(std::make_shared<NewConfig>()); |
| 51 | 51 | ``` |
| 52 | 52 | |
| 53 | -See [`examples/json.cpp`](https://github.com/CLIUtils/CLI11/blob/master/examples/json.cpp) for a complete JSON config example. | |
| 53 | +See [`examples/json.cpp`](https://github.com/CLIUtils/CLI11/blob/master/examples/json.cpp) for a complete JSON config example. | ... | ... |
book/chapters/flags.md
| ... | ... | @@ -73,7 +73,7 @@ The values would be used like this: |
| 73 | 73 | |
| 74 | 74 | [include:"usage"](../code/flags.cpp) |
| 75 | 75 | |
| 76 | -[Source code](https://gitlab.com/CLIUtils/CLI11Tutorial/blob/master/code/flags.cpp) | |
| 76 | +[Source code](https://gitlab.com/CLIUtils/CLI11Tutorial/blob/master/code/flags.cpp) | |
| 77 | 77 | |
| 78 | 78 | If you compile and run: |
| 79 | 79 | ... | ... |
book/chapters/formatting.md
| ... | ... | @@ -51,7 +51,7 @@ This is a normal printout, with `<>` indicating the methods used to produce each |
| 51 | 51 | <make_group(app, "Option Group 2"), false, filter> |
| 52 | 52 | ... |
| 53 | 53 | <make_subcommands(app)> |
| 54 | - <make_subcommand(sub1, Mode::Normal)> | |
| 54 | + <make_subcommand(sub1, Mode::Normal)> | |
| 55 | 55 | <make_subcommand(sub2, Mode::Normal)> |
| 56 | 56 | <make_footer(app)> |
| 57 | 57 | ``` |
| ... | ... | @@ -61,10 +61,10 @@ This is a normal printout, with `<>` indicating the methods used to produce each |
| 61 | 61 | The `make_groups` print the group name then call `make_option(o)` on the options listed in that group. The normal printout for an option looks like this: |
| 62 | 62 | |
| 63 | 63 | ``` |
| 64 | - make_option_opts(o) | |
| 65 | - ┌───┴────┐ | |
| 66 | - -n,--name (REQUIRED) This is a description | |
| 67 | -└────┬────┘ └──────────┬──────────┘ | |
| 64 | + make_option_opts(o) | |
| 65 | + ┌───┴────┐ | |
| 66 | + -n,--name (REQUIRED) This is a description | |
| 67 | +└────┬────┘ └──────────┬──────────┘ | |
| 68 | 68 | make_option_name(o,p) make_option_desc(o) |
| 69 | 69 | ``` |
| 70 | 70 | ... | ... |
book/chapters/installation.md
| 1 | -# Installation | |
| 1 | +# Installation | |
| 2 | 2 | |
| 3 | 3 | ## Single file edition |
| 4 | 4 | |
| ... | ... | @@ -50,7 +50,7 @@ root:build # cmake .. |
| 50 | 50 | root:build # make |
| 51 | 51 | Scanning dependencies ... |
| 52 | 52 | root:build # make test |
| 53 | -[warning]Running tests... | |
| 53 | +[warning]Running tests... | |
| 54 | 54 | Test project /CLI11/build |
| 55 | 55 | Start 1: HelpersTest |
| 56 | 56 | 1/10 Test #1: HelpersTest ...................... Passed 0.01 sec | ... | ... |
book/chapters/options.md
| ... | ... | @@ -20,7 +20,7 @@ You can use any C++ int-like type, not just `int`. CLI11 understands the followi |
| 20 | 20 | |
| 21 | 21 | | Type | CLI11 | |
| 22 | 22 | |-------------|-------| |
| 23 | -| int-like | Integer conversion up to 64-bit, can be unsigned | | |
| 23 | +| int-like | Integer conversion up to 64-bit, can be unsigned | | |
| 24 | 24 | | float-like | Floating point conversions | |
| 25 | 25 | | string-like | Anything else that can be shifted into a StringStream | |
| 26 | 26 | | vector-like | A vector of the above three types (see below) | |
| ... | ... | @@ -54,7 +54,7 @@ If you use a vector instead of a plain option, you can accept more than one valu |
| 54 | 54 | |-------------------|-----------------| |
| 55 | 55 | | `--vec 1 --vec 2` | `--vec 1 2` | |
| 56 | 56 | |
| 57 | -The original version did allow the option system to access information on the grouping of options received, but was removed for simplicity. | |
| 57 | +The original version did allow the option system to access information on the grouping of options received, but was removed for simplicity. | |
| 58 | 58 | |
| 59 | 59 | An example of setting up a vector option: |
| 60 | 60 | ... | ... |
book/chapters/toolkits.md
| ... | ... | @@ -27,4 +27,4 @@ You can call anything you would like to configure in the constructor, like `opti |
| 27 | 27 | |
| 28 | 28 | # Virtual functions provided |
| 29 | 29 | |
| 30 | -You are given a few virtual functions that you can change (only on the main App). `pre_callback` runs right before the callbacks run, letting you print out custom messages at the top of your app. | |
| 30 | +You are given a few virtual functions that you can change (only on the main App). `pre_callback` runs right before the callbacks run, letting you print out custom messages at the top of your app. | ... | ... |
cmake/CodeCoverage.cmake
| ... | ... | @@ -170,7 +170,7 @@ function(SETUP_TARGET_FOR_COVERAGE) |
| 170 | 170 | DEPENDS ${Coverage_DEPENDENCIES} |
| 171 | 171 | COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." |
| 172 | 172 | ) |
| 173 | - | |
| 173 | + | |
| 174 | 174 | # Show where to find the lcov info report |
| 175 | 175 | add_custom_command(TARGET ${Coverage_NAME} POST_BUILD |
| 176 | 176 | COMMAND ; | ... | ... |
conanfile.py
| ... | ... | @@ -2,6 +2,7 @@ from conans import ConanFile, CMake |
| 2 | 2 | from conans.tools import load |
| 3 | 3 | import re |
| 4 | 4 | |
| 5 | + | |
| 5 | 6 | def get_version(): |
| 6 | 7 | try: |
| 7 | 8 | content = load("include/CLI/Version.hpp") |
| ... | ... | @@ -10,6 +11,7 @@ def get_version(): |
| 10 | 11 | except Exception: |
| 11 | 12 | return None |
| 12 | 13 | |
| 14 | + | |
| 13 | 15 | class CLI11Conan(ConanFile): |
| 14 | 16 | name = "CLI11" |
| 15 | 17 | version = get_version() |
| ... | ... | @@ -21,9 +23,17 @@ class CLI11Conan(ConanFile): |
| 21 | 23 | license = "BSD-3-Clause" |
| 22 | 24 | |
| 23 | 25 | settings = "os", "compiler", "arch", "build_type" |
| 24 | - exports_sources = "LICENSE", "README.md", "include/*", "extern/*", "cmake/*", "CMakeLists.txt", "tests/*" | |
| 26 | + exports_sources = ( | |
| 27 | + "LICENSE", | |
| 28 | + "README.md", | |
| 29 | + "include/*", | |
| 30 | + "extern/*", | |
| 31 | + "cmake/*", | |
| 32 | + "CMakeLists.txt", | |
| 33 | + "tests/*", | |
| 34 | + ) | |
| 25 | 35 | |
| 26 | - def build(self): # this is not building a library, just tests | |
| 36 | + def build(self): # this is not building a library, just tests | |
| 27 | 37 | cmake = CMake(self) |
| 28 | 38 | cmake.definitions["CLI11_EXAMPLES"] = "OFF" |
| 29 | 39 | cmake.definitions["CLI11_SINGLE_FILE"] = "OFF" | ... | ... |
include/CLI/Validators.hpp
| ... | ... | @@ -474,9 +474,10 @@ template <typename T> std::string generate_set(const T &set) { |
| 474 | 474 | using element_t = typename detail::element_type<T>::type; |
| 475 | 475 | using iteration_type_t = typename detail::pair_adaptor<element_t>::value_type; // the type of the object pair |
| 476 | 476 | std::string out(1, '{'); |
| 477 | - out.append(detail::join(detail::smart_deref(set), | |
| 478 | - [](const iteration_type_t &v) { return detail::pair_adaptor<element_t>::first(v); }, | |
| 479 | - ",")); | |
| 477 | + out.append(detail::join( | |
| 478 | + detail::smart_deref(set), | |
| 479 | + [](const iteration_type_t &v) { return detail::pair_adaptor<element_t>::first(v); }, | |
| 480 | + ",")); | |
| 480 | 481 | out.push_back('}'); |
| 481 | 482 | return out; |
| 482 | 483 | } |
| ... | ... | @@ -486,17 +487,18 @@ template <typename T> std::string generate_map(const T &map, bool key_only = fal |
| 486 | 487 | using element_t = typename detail::element_type<T>::type; |
| 487 | 488 | using iteration_type_t = typename detail::pair_adaptor<element_t>::value_type; // the type of the object pair |
| 488 | 489 | std::string out(1, '{'); |
| 489 | - out.append(detail::join(detail::smart_deref(map), | |
| 490 | - [key_only](const iteration_type_t &v) { | |
| 491 | - std::string res{detail::to_string(detail::pair_adaptor<element_t>::first(v))}; | |
| 492 | - | |
| 493 | - if(!key_only) { | |
| 494 | - res.append("->"); | |
| 495 | - res += detail::to_string(detail::pair_adaptor<element_t>::second(v)); | |
| 496 | - } | |
| 497 | - return res; | |
| 498 | - }, | |
| 499 | - ",")); | |
| 490 | + out.append(detail::join( | |
| 491 | + detail::smart_deref(map), | |
| 492 | + [key_only](const iteration_type_t &v) { | |
| 493 | + std::string res{detail::to_string(detail::pair_adaptor<element_t>::first(v))}; | |
| 494 | + | |
| 495 | + if(!key_only) { | |
| 496 | + res.append("->"); | |
| 497 | + res += detail::to_string(detail::pair_adaptor<element_t>::second(v)); | |
| 498 | + } | |
| 499 | + return res; | |
| 500 | + }, | |
| 501 | + ",")); | |
| 500 | 502 | out.push_back('}'); |
| 501 | 503 | return out; |
| 502 | 504 | } |
| ... | ... | @@ -657,9 +659,10 @@ class IsMember : public Validator { |
| 657 | 659 | /// You can pass in as many filter functions as you like, they nest (string only currently) |
| 658 | 660 | template <typename T, typename... Args> |
| 659 | 661 | IsMember(T &&set, filter_fn_t filter_fn_1, filter_fn_t filter_fn_2, Args &&... other) |
| 660 | - : IsMember(std::forward<T>(set), | |
| 661 | - [filter_fn_1, filter_fn_2](std::string a) { return filter_fn_2(filter_fn_1(a)); }, | |
| 662 | - other...) {} | |
| 662 | + : IsMember( | |
| 663 | + std::forward<T>(set), | |
| 664 | + [filter_fn_1, filter_fn_2](std::string a) { return filter_fn_2(filter_fn_1(a)); }, | |
| 665 | + other...) {} | |
| 663 | 666 | }; |
| 664 | 667 | |
| 665 | 668 | /// definition of the default transformation object |
| ... | ... | @@ -717,9 +720,10 @@ class Transformer : public Validator { |
| 717 | 720 | /// You can pass in as many filter functions as you like, they nest |
| 718 | 721 | template <typename T, typename... Args> |
| 719 | 722 | Transformer(T &&mapping, filter_fn_t filter_fn_1, filter_fn_t filter_fn_2, Args &&... other) |
| 720 | - : Transformer(std::forward<T>(mapping), | |
| 721 | - [filter_fn_1, filter_fn_2](std::string a) { return filter_fn_2(filter_fn_1(a)); }, | |
| 722 | - other...) {} | |
| 723 | + : Transformer( | |
| 724 | + std::forward<T>(mapping), | |
| 725 | + [filter_fn_1, filter_fn_2](std::string a) { return filter_fn_2(filter_fn_1(a)); }, | |
| 726 | + other...) {} | |
| 723 | 727 | }; |
| 724 | 728 | |
| 725 | 729 | /// translate named items to other or a value set |
| ... | ... | @@ -793,9 +797,10 @@ class CheckedTransformer : public Validator { |
| 793 | 797 | /// You can pass in as many filter functions as you like, they nest |
| 794 | 798 | template <typename T, typename... Args> |
| 795 | 799 | CheckedTransformer(T &&mapping, filter_fn_t filter_fn_1, filter_fn_t filter_fn_2, Args &&... other) |
| 796 | - : CheckedTransformer(std::forward<T>(mapping), | |
| 797 | - [filter_fn_1, filter_fn_2](std::string a) { return filter_fn_2(filter_fn_1(a)); }, | |
| 798 | - other...) {} | |
| 800 | + : CheckedTransformer( | |
| 801 | + std::forward<T>(mapping), | |
| 802 | + [filter_fn_1, filter_fn_2](std::string a) { return filter_fn_2(filter_fn_1(a)); }, | |
| 803 | + other...) {} | |
| 799 | 804 | }; |
| 800 | 805 | |
| 801 | 806 | /// Helper function to allow ignore_case to be passed to IsMember or Transform | ... | ... |
scripts/ExtractVersion.py
| ... | ... | @@ -3,15 +3,15 @@ |
| 3 | 3 | import os |
| 4 | 4 | import re |
| 5 | 5 | |
| 6 | -base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| 7 | -config_h = os.path.join(base_path, 'include', 'CLI', 'Version.hpp') | |
| 8 | -data = {'MAJOR': 0, 'MINOR': 0, 'PATCH': 0} | |
| 9 | -reg = re.compile(r'^\s*#define\s+CLI11_VERSION_([A-Z]+)\s+([0-9]+).*$') | |
| 6 | +base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | |
| 7 | +config_h = os.path.join(base_path, "include", "CLI", "Version.hpp") | |
| 8 | +data = {"MAJOR": 0, "MINOR": 0, "PATCH": 0} | |
| 9 | +reg = re.compile(r"^\s*#define\s+CLI11_VERSION_([A-Z]+)\s+([0-9]+).*$") | |
| 10 | 10 | |
| 11 | -with open(config_h, 'r') as fp: | |
| 12 | - for l in fp: | |
| 13 | - m = reg.match(l) | |
| 14 | - if m: | |
| 15 | - data[m.group(1)] = int(m.group(2)) | |
| 11 | +with open(config_h, "r") as fp: | |
| 12 | + for l in fp: | |
| 13 | + m = reg.match(l) | |
| 14 | + if m: | |
| 15 | + data[m.group(1)] = int(m.group(2)) | |
| 16 | 16 | |
| 17 | -print('{}.{}.{}'.format(data['MAJOR'], data['MINOR'], data['PATCH'])) | |
| 17 | +print("{}.{}.{}".format(data["MAJOR"], data["MINOR"], data["PATCH"])) | ... | ... |
scripts/MakeSingleHeader.py
| ... | ... | @@ -24,11 +24,13 @@ CLI11:verbatim # The tag |
| 24 | 24 | [^\n]* # Up to end of line |
| 25 | 25 | $ # End of a line |
| 26 | 26 | """ |
| 27 | -verbatim_all = re.compile(verbatim_tag_str + "(.*)" + verbatim_tag_str, | |
| 28 | - re.MULTILINE | re.DOTALL | re.VERBOSE) | |
| 27 | +verbatim_all = re.compile( | |
| 28 | + verbatim_tag_str + "(.*)" + verbatim_tag_str, re.MULTILINE | re.DOTALL | re.VERBOSE | |
| 29 | +) | |
| 29 | 30 | |
| 30 | 31 | DIR = os.path.dirname(os.path.abspath(__file__)) |
| 31 | 32 | |
| 33 | + | |
| 32 | 34 | class HeaderFile(object): |
| 33 | 35 | TAG = "Unknown git revision" |
| 34 | 36 | LICENSE = "// BSD 3 clause" |
| ... | ... | @@ -43,7 +45,7 @@ class HeaderFile(object): |
| 43 | 45 | self.__class__.VERSION = version.groups()[0] |
| 44 | 46 | |
| 45 | 47 | # add self.verbatim |
| 46 | - if 'CLI11:verbatim' in inner: | |
| 48 | + if "CLI11:verbatim" in inner: | |
| 47 | 49 | self.verbatim = ["\n\n// Verbatim copy from {0}:".format(inc)] |
| 48 | 50 | self.verbatim += verbatim_all.findall(inner) |
| 49 | 51 | inner = verbatim_all.sub("", inner) |
| ... | ... | @@ -52,7 +54,7 @@ class HeaderFile(object): |
| 52 | 54 | |
| 53 | 55 | self.headers = set(includes_system.findall(inner)) |
| 54 | 56 | |
| 55 | - self.body = '\n// From {0}:\n\n'.format(inc) + inner[inner.find('namespace'):] | |
| 57 | + self.body = "\n// From {0}:\n\n".format(inc) + inner[inner.find("namespace") :] | |
| 56 | 58 | |
| 57 | 59 | self.namespace = None |
| 58 | 60 | |
| ... | ... | @@ -65,11 +67,11 @@ class HeaderFile(object): |
| 65 | 67 | |
| 66 | 68 | @property |
| 67 | 69 | def header_str(self): |
| 68 | - return '\n'.join('#include <'+h+'>' for h in sorted(self.headers)) | |
| 70 | + return "\n".join("#include <" + h + ">" for h in sorted(self.headers)) | |
| 69 | 71 | |
| 70 | 72 | @property |
| 71 | 73 | def verbatim_str(self): |
| 72 | - return '\n'.join(self.verbatim) | |
| 74 | + return "\n".join(self.verbatim) | |
| 73 | 75 | |
| 74 | 76 | def insert_namespace(self, namespace): |
| 75 | 77 | self.namespace = namespace |
| ... | ... | @@ -79,7 +81,7 @@ class HeaderFile(object): |
| 79 | 81 | self.body = self.body.replace(before, after) |
| 80 | 82 | |
| 81 | 83 | def __str__(self): |
| 82 | - result = '''\ | |
| 84 | + result = """\ | |
| 83 | 85 | #pragma once |
| 84 | 86 | |
| 85 | 87 | // CLI11: Version {self.VERSION} |
| ... | ... | @@ -96,21 +98,27 @@ class HeaderFile(object): |
| 96 | 98 | // Standard combined includes: |
| 97 | 99 | |
| 98 | 100 | {self.header_str} |
| 99 | -'''.format(self=self) | |
| 101 | +""".format( | |
| 102 | + self=self | |
| 103 | + ) | |
| 100 | 104 | |
| 101 | 105 | if self.namespace: |
| 102 | - result += '\nnamespace ' + self.namespace + ' {\n\n' | |
| 103 | - result += '{self.verbatim_str}\n{self.body}\n'.format(self=self) | |
| 106 | + result += "\nnamespace " + self.namespace + " {\n\n" | |
| 107 | + result += "{self.verbatim_str}\n{self.body}\n".format(self=self) | |
| 104 | 108 | if self.namespace: |
| 105 | - result += '} // namespace ' + self.namespace + '\n\n' | |
| 109 | + result += "} // namespace " + self.namespace + "\n\n" | |
| 106 | 110 | |
| 107 | 111 | return result |
| 108 | 112 | |
| 109 | 113 | |
| 110 | -def MakeHeader(output, main_header, include_dir = '../include', namespace=None, macro=None): | |
| 114 | +def MakeHeader( | |
| 115 | + output, main_header, include_dir="../include", namespace=None, macro=None | |
| 116 | +): | |
| 111 | 117 | # Set tag if possible to class variable |
| 112 | 118 | try: |
| 113 | - proc = Popen(['git', 'describe', '--tags', '--always'], cwd=str(DIR), stdout=PIPE) | |
| 119 | + proc = Popen( | |
| 120 | + ["git", "describe", "--tags", "--always"], cwd=str(DIR), stdout=PIPE | |
| 121 | + ) | |
| 114 | 122 | out, _ = proc.communicate() |
| 115 | 123 | except OSError: |
| 116 | 124 | pass |
| ... | ... | @@ -120,10 +128,10 @@ def MakeHeader(output, main_header, include_dir = '../include', namespace=None, |
| 120 | 128 | |
| 121 | 129 | base_dir = os.path.abspath(os.path.join(DIR, include_dir)) |
| 122 | 130 | main_header = os.path.join(base_dir, main_header) |
| 123 | - licence_file = os.path.abspath(os.path.join(DIR, '../LICENSE')) | |
| 131 | + licence_file = os.path.abspath(os.path.join(DIR, "../LICENSE")) | |
| 124 | 132 | |
| 125 | 133 | with open(licence_file) as f: |
| 126 | - HeaderFile.LICENSE = ''.join('// ' + line for line in f) | |
| 134 | + HeaderFile.LICENSE = "".join("// " + line for line in f) | |
| 127 | 135 | |
| 128 | 136 | with open(main_header) as f: |
| 129 | 137 | header = f.read() |
| ... | ... | @@ -134,7 +142,7 @@ def MakeHeader(output, main_header, include_dir = '../include', namespace=None, |
| 134 | 142 | single_header = reduce(add, headers) |
| 135 | 143 | |
| 136 | 144 | if macro is not None: |
| 137 | - before = 'CLI11_' | |
| 145 | + before = "CLI11_" | |
| 138 | 146 | print("Converting macros", before, "->", macro) |
| 139 | 147 | single_header.macro_replacement(before, macro) |
| 140 | 148 | |
| ... | ... | @@ -142,19 +150,25 @@ def MakeHeader(output, main_header, include_dir = '../include', namespace=None, |
| 142 | 150 | print("Adding namespace", namespace) |
| 143 | 151 | single_header.insert_namespace(namespace) |
| 144 | 152 | |
| 145 | - with open(output, 'w') as f: | |
| 153 | + with open(output, "w") as f: | |
| 146 | 154 | f.write(str(single_header)) |
| 147 | 155 | |
| 148 | 156 | print("Created", output) |
| 149 | 157 | |
| 150 | -if __name__ == '__main__': | |
| 151 | - parser = ArgumentParser(usage='Convert source to single header include. Can optionally add namespace and search-replace replacements (for macros).') | |
| 158 | + | |
| 159 | +if __name__ == "__main__": | |
| 160 | + parser = ArgumentParser( | |
| 161 | + usage="Convert source to single header include. Can optionally add namespace and search-replace replacements (for macros)." | |
| 162 | + ) | |
| 152 | 163 | parser.add_argument("output", help="Single header file output") |
| 153 | - parser.add_argument("--main", default='CLI/CLI.hpp', help="The main include file that defines the other files") | |
| 154 | - parser.add_argument("--include", default='../include', help="The include directory") | |
| 164 | + parser.add_argument( | |
| 165 | + "--main", | |
| 166 | + default="CLI/CLI.hpp", | |
| 167 | + help="The main include file that defines the other files", | |
| 168 | + ) | |
| 169 | + parser.add_argument("--include", default="../include", help="The include directory") | |
| 155 | 170 | parser.add_argument("--namespace", help="Add an optional namespace") |
| 156 | 171 | parser.add_argument("--macro", help="Replaces CLI11_ with NEW_PREFIX_") |
| 157 | 172 | args = parser.parse_args() |
| 158 | 173 | |
| 159 | 174 | MakeHeader(args.output, args.main, args.include, args.namespace, args.macro) |
| 160 | - | ... | ... |
scripts/UpdateDownloadProj.py
| ... | ... | @@ -5,20 +5,25 @@ from __future__ import print_function, division |
| 5 | 5 | from plumbum import local, cli, FG |
| 6 | 6 | from plumbum.cmd import curl |
| 7 | 7 | |
| 8 | -FILES = [ 'https://raw.githubusercontent.com/Crascit/DownloadProject/master/DownloadProject.cmake', | |
| 9 | - 'https://raw.githubusercontent.com/Crascit/DownloadProject/master/DownloadProject.CMakeLists.cmake.in'] | |
| 8 | +FILES = [ | |
| 9 | + "https://raw.githubusercontent.com/Crascit/DownloadProject/master/DownloadProject.cmake", | |
| 10 | + "https://raw.githubusercontent.com/Crascit/DownloadProject/master/DownloadProject.CMakeLists.cmake.in", | |
| 11 | +] | |
| 10 | 12 | |
| 11 | 13 | DIR = local.path(__file__).dirname |
| 12 | 14 | |
| 15 | + | |
| 13 | 16 | def download_file(path): |
| 14 | - name = path.split('/')[-1] | |
| 17 | + name = path.split("/")[-1] | |
| 15 | 18 | (curl[path] > name) & FG |
| 16 | 19 | |
| 20 | + | |
| 17 | 21 | class UpdateDownloadProj(cli.Application): |
| 18 | 22 | def main(self): |
| 19 | - with local.cwd(DIR / '../cmake'): | |
| 23 | + with local.cwd(DIR / "../cmake"): | |
| 20 | 24 | for f in FILES: |
| 21 | 25 | download_file(f) |
| 22 | 26 | |
| 27 | + | |
| 23 | 28 | if __name__ == "__main__": |
| 24 | 29 | UpdateDownloadProj() | ... | ... |
test_package/conanfile.py
tests/OptionalTest.cpp
| ... | ... | @@ -162,7 +162,8 @@ TEST_F(TApp, BoostOptionalEnumTest) { |
| 162 | 162 | |
| 163 | 163 | TEST_F(TApp, BoostOptionalVector) { |
| 164 | 164 | boost::optional<std::vector<int>> opt; |
| 165 | - app.add_option_function<std::vector<int>>("-v,--vec", [&opt](const std::vector<int> &v) { opt = v; }, "some vector") | |
| 165 | + app.add_option_function<std::vector<int>>( | |
| 166 | + "-v,--vec", [&opt](const std::vector<int> &v) { opt = v; }, "some vector") | |
| 166 | 167 | ->expected(3); |
| 167 | 168 | run(); |
| 168 | 169 | EXPECT_FALSE(opt); | ... | ... |