1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-01-15 22:58:02 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Christoph Bachhuber
5ecb61599a
Add and fix cpplint readability/braces (#431)
* Add readability/braces check

* Fix cpplint readability/braces issues
2020-02-13 09:47:36 +01:00
Josh Soref
51a0efcbbc
Spelling (#429)
* spelling: argument

* spelling: conflicts

* spelling: correctly

* spelling: default

* spelling: description

* spelling: empty

* spelling: enum

* spelling: javascript

* spelling: modifying

* spelling: nonexistent

* spelling: plumbum

* spelling: programmatically

* spelling: received

* spelling: replaced

* spelling: required

* spelling: sanitizers

* spelling: semicolon

* spelling: source

* spelling: subcommands

* spelling: successful
2020-02-12 00:41:58 -05:00
17 changed files with 47 additions and 45 deletions

View File

@ -10,7 +10,7 @@ rm -rf cmake_dir/* build_tmp/*
v=$1
fn=cmake-$v-Linux-x86_64.tar.gz
if [ ! -f cmake_souces/$fn ]; then
if [ ! -f cmake_sources/$fn ]; then
wget -qO cmake_sources/$fn "https://cmake.org/files/v${v%.*}/$fn"
fi

View File

@ -333,7 +333,7 @@ This is a quick patch release that makes LICENSE part of the single header file,
### Version 1.5.1: Access
This patch release adds better access to the App progromatically, to assist with writing custom converters to other formats. It also improves the help output, and uses a new feature in CLI11 1.5 to fix an old "quirk" in the way unlimited options and positionals interact.
This patch release adds better access to the App programmatically, to assist with writing custom converters to other formats. It also improves the help output, and uses a new feature in CLI11 1.5 to fix an old "quirk" in the way unlimited options and positionals interact.
* Make mixing unlimited positionals and options more intuitive [#102]
* Add missing getters `get_options` and `get_description` to App [#105]
@ -360,7 +360,7 @@ Note: This is the final release with `requires`, please switch to `needs`.
* Support for `std::optional`, `std::experimental::optional`, and `boost::optional` added if `__has_include` is supported [#95]
* All macros/CMake variables now start with `CLI11_` instead of just `CLI_` [#95]
* The internal stream was not being cleared before use in some cases. Fixed. [#95]
* Using an emum now requires explicit conversion overload [#97]
* Using an enum now requires explicit conversion overload [#97]
* The separator `--` now is removed when it ends unlimited arguments [#100]
Other, non-user facing changes:
@ -551,7 +551,7 @@ Lots of cleanup and docs additions made it into this release. Parsing is simpler
## Version 0.3: Plumbum compatibility
* Added `->requires`, `->excludes`, and `->envname` from [Plumbum](http://plumbum.readthedocs.io/en/latest/)
* Supports `->mandatory` from Plubmum
* Supports `->mandatory` from Plumbum
* More tests for help strings, improvements in formatting
* Support type and set syntax in positionals help strings
* Added help groups, with `->group("name")` syntax

View File

@ -51,7 +51,7 @@ list(APPEND build-docs "EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/docs")
option(CLI11_WARNINGS_AS_ERRORS "Turn all warnings into errors (for CI)")
option(CLI11_SINGLE_FILE "Generate a single header file")
cmake_dependent_option(CLI11_SANITIZERS
"Download the sanatizers CMake config" OFF
"Download the sanitizers CMake config" OFF
"NOT CMAKE_VERSION VERSION_LESS 3.11" OFF)
cmake_dependent_option(CLI11_BUILD_DOCS
@ -89,7 +89,7 @@ cmake_dependent_option(CLI11_CUDA_TESTS
cmake_dependent_option(CLI11_CLANG_TIDY
"Look for and use Clang-Tidy" OFF
"CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME;NOT CMAKE_VERSION VERSION_LESS 3.6" OFF)
set(CLI11_CLANG_TIDY_OPTIONS "" CACHE STRING "Clang tidy options, such as -fix, simicolon separated")
set(CLI11_CLANG_TIDY_OPTIONS "" CACHE STRING "Clang tidy options, such as -fix, semicolon separated")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)

View File

@ -3,11 +3,11 @@ linelength=120 # As in .clang-format
# Non-used filters
filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers
filter=-readability/nolint # Conficts with clang-tidy
filter=-readability/nolint # Conflicts with clang-tidy
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
filter=-whitespace/indent,-whitespace/comments

View File

@ -105,7 +105,7 @@ CLI::Option* opt = app.add_flag("--opt");
CLI11_PARSE(app, argv, argc);
if(* opt)
std::cout << "Flag recieved " << opt->count() << " times." << std::endl;
std::cout << "Flag received " << opt->count() << " times." << std::endl;
```
## Inheritance of defaults

View File

@ -280,7 +280,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and
# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
# Fortran. In the later case the parser tries to guess whether the code is fixed
@ -1508,7 +1508,7 @@ FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# http://www.mathjax.org) which uses client side Javascript for the rendering
# http://www.mathjax.org) which uses client side JavaScript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
@ -1578,7 +1578,7 @@ MATHJAX_CODEFILE =
SEARCHENGINE = YES
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
# implemented using a web server instead of a web client using Javascript. There
# implemented using a web server instead of a web client using JavaScript. There
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
# setting. When disabled, doxygen will generate a PHP script for searching and
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing

View File

@ -17,7 +17,7 @@ int main(int argc, char **argv) {
auto foo = app.add_option("--foo,-f", foos, "Some unlimited argument");
std::vector<int> bars;
auto bar = app.add_option("--bar", bars, "Some unlimited arggument");
auto bar = app.add_option("--bar", bars, "Some unlimited argument");
app.add_flag("--z,--x", "Random other flags");

View File

@ -984,7 +984,7 @@ class App {
}
///@}
/// @name Subcommmands
/// @name Subcommands
///@{
/// Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag
@ -1246,8 +1246,9 @@ class App {
name_ = nstr.first;
}
commandline = std::move(nstr.second);
} else
} else {
detail::trim(commandline);
}
// the next section of code is to deal with quoted arguments after an '=' or ':' for windows like operations
if(!commandline.empty()) {
commandline = detail::find_and_modify(commandline, "=", detail::escape_detect);

View File

@ -246,11 +246,11 @@ class RequiredError : public ParseError {
class ArgumentMismatch : public ParseError {
CLI11_ERROR_DEF(ParseError, ArgumentMismatch)
CLI11_ERROR_SIMPLE(ArgumentMismatch)
ArgumentMismatch(std::string name, int expected, std::size_t recieved)
ArgumentMismatch(std::string name, int expected, std::size_t received)
: ArgumentMismatch(expected > 0 ? ("Expected exactly " + std::to_string(expected) + " arguments to " + name +
", got " + std::to_string(recieved))
", got " + std::to_string(received))
: ("Expected at least " + std::to_string(-expected) + " arguments to " + name +
", got " + std::to_string(recieved)),
", got " + std::to_string(received)),
ExitCodes::ArgumentMismatch) {}
static ArgumentMismatch AtLeast(std::string name, int num, std::size_t received) {

View File

@ -42,9 +42,9 @@ constexpr int expected_max_vector_size{1 << 29};
inline std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
// Check to see if empty string, give consistent result
if(s.empty())
if(s.empty()) {
elems.emplace_back();
else {
} else {
std::stringstream ss;
ss.str(s);
std::string item;
@ -264,8 +264,9 @@ inline std::ptrdiff_t find_member(std::string name,
it = std::find_if(std::begin(names), std::end(names), [&name](std::string local_name) {
return detail::remove_underscore(local_name) == name;
});
} else
} else {
it = std::find(std::begin(names), std::end(names), name);
}
return (it != std::end(names)) ? (it - std::begin(names)) : (-1);
}

View File

@ -107,14 +107,14 @@ class Validator {
}
}
return retstring;
};
}
/// This is the required operator for a Validator - provided to help
/// users (CLI11 uses the member `func` directly)
std::string operator()(const std::string &str) const {
std::string value = str;
return (active_) ? func_(value) : std::string{};
};
}
/// Specify the type string
Validator &description(std::string validator_desc) {
@ -168,13 +168,13 @@ class Validator {
Validator &application_index(int app_index) {
application_index_ = app_index;
return *this;
};
}
/// Specify the application index of a validator
Validator application_index(int app_index) const {
Validator newval(*this);
newval.application_index_ = app_index;
return newval;
};
}
/// Get the current value of the application index
int get_application_index() const { return application_index_; }
/// Get a boolean if the validator is active
@ -282,7 +282,7 @@ class CustomValidator : public Validator {
namespace detail {
/// CLI enumeration of different file types
enum class path_type { nonexistant, file, directory };
enum class path_type { nonexistent, file, directory };
#if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0
/// get the type of the path from a file name
@ -290,12 +290,12 @@ inline path_type check_path(const char *file) noexcept {
std::error_code ec;
auto stat = std::filesystem::status(file, ec);
if(ec) {
return path_type::nonexistant;
return path_type::nonexistent;
}
switch(stat.type()) {
case std::filesystem::file_type::none:
case std::filesystem::file_type::not_found:
return path_type::nonexistant;
return path_type::nonexistent;
case std::filesystem::file_type::directory:
return path_type::directory;
case std::filesystem::file_type::symlink:
@ -323,7 +323,7 @@ inline path_type check_path(const char *file) noexcept {
return ((buffer.st_mode & S_IFDIR) != 0) ? path_type::directory : path_type::file;
}
#endif
return path_type::nonexistant;
return path_type::nonexistent;
}
#endif
/// Check for an existing file (returns error message if check fails)
@ -332,7 +332,7 @@ class ExistingFileValidator : public Validator {
ExistingFileValidator() : Validator("FILE") {
func_ = [](std::string &filename) {
auto path_result = check_path(filename.c_str());
if(path_result == path_type::nonexistant) {
if(path_result == path_type::nonexistent) {
return "File does not exist: " + filename;
}
if(path_result == path_type::directory) {
@ -349,7 +349,7 @@ class ExistingDirectoryValidator : public Validator {
ExistingDirectoryValidator() : Validator("DIR") {
func_ = [](std::string &filename) {
auto path_result = check_path(filename.c_str());
if(path_result == path_type::nonexistant) {
if(path_result == path_type::nonexistent) {
return "Directory does not exist: " + filename;
}
if(path_result == path_type::file) {
@ -366,7 +366,7 @@ class ExistingPathValidator : public Validator {
ExistingPathValidator() : Validator("PATH(existing)") {
func_ = [](std::string &filename) {
auto path_result = check_path(filename.c_str());
if(path_result == path_type::nonexistant) {
if(path_result == path_type::nonexistent) {
return "Path does not exist: " + filename;
}
return std::string();
@ -380,7 +380,7 @@ class NonexistentPathValidator : public Validator {
NonexistentPathValidator() : Validator("PATH(non-existing)") {
func_ = [](std::string &filename) {
auto path_result = check_path(filename.c_str());
if(path_result != path_type::nonexistant) {
if(path_result != path_type::nonexistent) {
return "Path already exists: " + filename;
}
return std::string();

View File

@ -6,7 +6,7 @@
int main(int argc, char **argv) {
CLI::App app("Some nice discription");
CLI::App app("Some nice description");
int x = 0;
app.add_option("-x", x, "an integer value", true /* show default */);

View File

@ -1394,7 +1394,7 @@ TEST_F(TApp, RequireOptPriorityShort) {
EXPECT_EQ(remain, std::vector<std::string>({"two", "three"}));
}
TEST_F(TApp, NotRequiedExpectedDouble) {
TEST_F(TApp, NotRequiredExpectedDouble) {
std::vector<std::string> strs;
app.add_option("--str", strs)->expected(2);
@ -1404,7 +1404,7 @@ TEST_F(TApp, NotRequiedExpectedDouble) {
EXPECT_THROW(run(), CLI::ArgumentMismatch);
}
TEST_F(TApp, NotRequiedExpectedDoubleShort) {
TEST_F(TApp, NotRequiredExpectedDoubleShort) {
std::vector<std::string> strs;
app.add_option("-s", strs)->expected(2);
@ -2338,7 +2338,7 @@ TEST_F(TApp, OptionWithDefaults) {
}
// Added to test ->transform
TEST_F(TApp, OrderedModifingTransforms) {
TEST_F(TApp, OrderedModifyingTransforms) {
std::vector<std::string> val;
auto m = app.add_option("-m", val);
m->transform([](std::string x) { return x + "1"; });

View File

@ -5,7 +5,7 @@
using ::testing::HasSubstr;
using ::testing::Not;
TEST(Deprecated, Emtpy) {
TEST(Deprecated, Empty) {
// No deprecated features at this time.
EXPECT_TRUE(true);
}

View File

@ -731,7 +731,7 @@ struct CapturedHelp : public ::testing::Test {
}
};
TEST_F(CapturedHelp, Sucessful) {
TEST_F(CapturedHelp, Successful) {
EXPECT_EQ(run(CLI::Success()), 0);
EXPECT_EQ(out.str(), "");
EXPECT_EQ(err.str(), "");
@ -825,7 +825,7 @@ TEST_F(CapturedHelp, AllOnlyError) {
EXPECT_THAT(err.str(), Not(HasSubstr("Usage")));
}
TEST_F(CapturedHelp, RepacedError) {
TEST_F(CapturedHelp, ReplacedError) {
app.failure_message(CLI::FailureMessage::help);
EXPECT_EQ(run(CLI::ExtrasError({"Thing"})), static_cast<int>(CLI::ExitCodes::ExtrasError));
@ -995,7 +995,7 @@ TEST(THelp, CombinedValidatorsText) {
app.add_option("--f1", filename)->check(CLI::ExistingFile | CLI::ExistingDirectory);
// This would be nice if it put something other than string, but would it be path or file?
// Can't programatically tell!
// Can't programmatically tell!
// (Users can use ExistingPath, by the way)
std::string help = app.help();
EXPECT_THAT(help, HasSubstr("TEXT:(FILE) OR (DIR)"));

View File

@ -104,7 +104,7 @@ TEST_F(TApp, CrazyNameSubcommand) {
EXPECT_EQ(sub1->count(), 1u);
}
TEST_F(TApp, RequiredAndSubcoms) { // #23
TEST_F(TApp, RequiredAndSubcommands) { // #23
std::string baz;
app.add_option("baz", baz, "Baz Description", true)->required();
@ -719,7 +719,7 @@ TEST_F(TApp, Required1SubCom) {
EXPECT_THROW(run(), CLI::ExtrasError);
}
TEST_F(TApp, BadSubcomSearch) {
TEST_F(TApp, BadSubcommandSearch) {
auto one = app.add_subcommand("one");
auto two = one->add_subcommand("two");

View File

@ -104,7 +104,7 @@ TEST_F(TApp, EnumCheckedTransform) {
}
// from jzakrzewski Issue #330
TEST_F(TApp, EnumCheckedDefualtTransform) {
TEST_F(TApp, EnumCheckedDefaultTransform) {
enum class existing : std::int16_t { abort, overwrite, remove };
app.add_option("--existing", "What to do if file already exists in the destination")
->transform(
@ -541,7 +541,7 @@ TEST_F(TApp, BoundTests) {
EXPECT_TRUE(help.find("[3.4 - 5.9]") != std::string::npos);
}
TEST_F(TApp, NumberWithUnitCorrecltySplitNumber) {
TEST_F(TApp, NumberWithUnitCorrectlySplitNumber) {
std::map<std::string, int> mapping{{"a", 10}, {"b", 100}, {"cc", 1000}};
int value = 0;