Skip to content

Commit

Permalink
Update CLI11 from 2.2.0 to 2.3.2 (#5606)
Browse files Browse the repository at this point in the history
  • Loading branch information
jumaffre authored Sep 4, 2023
1 parent 25b6efc commit c89ca65
Show file tree
Hide file tree
Showing 16 changed files with 4,865 additions and 7,842 deletions.
2,154 changes: 156 additions & 1,998 deletions 3rdparty/internal/CLI11/App.hpp

Large diffs are not rendered by default.

8,277 changes: 4,424 additions & 3,853 deletions 3rdparty/internal/CLI11/CLI11.hpp

Large diffs are not rendered by default.

376 changes: 14 additions & 362 deletions 3rdparty/internal/CLI11/Config.hpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions 3rdparty/internal/CLI11/ConfigFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ConfigItem {
std::vector<std::string> inputs{};

/// The list of parents and name joined by "."
std::string fullname() const {
CLI11_NODISCARD std::string fullname() const {
std::vector<std::string> tmp = parents;
tmp.emplace_back(name);
return detail::join(tmp, ".");
Expand All @@ -54,18 +54,18 @@ class Config {
virtual std::vector<ConfigItem> from_config(std::istream &) const = 0;

/// Get a flag value
virtual std::string to_flag(const ConfigItem &item) const {
CLI11_NODISCARD virtual std::string to_flag(const ConfigItem &item) const {
if(item.inputs.size() == 1) {
return item.inputs.at(0);
}
if(item.inputs.empty()) {
return "{}";
}
throw ConversionError::TooManyInputsFlag(item.fullname());
throw ConversionError::TooManyInputsFlag(item.fullname()); // LCOV_EXCL_LINE
}

/// Parse a config file, throw an error (ParseError:ConfigParseError or FileError) on failure
std::vector<ConfigItem> from_file(const std::string &name) {
CLI11_NODISCARD std::vector<ConfigItem> from_file(const std::string &name) const {
std::ifstream input{name};
if(!input.good())
throw FileError::Missing(name);
Expand Down Expand Up @@ -148,7 +148,7 @@ class ConfigBase : public Config {
/// get a reference to the configuration section
std::string &sectionRef() { return configSection; }
/// get the section
const std::string &section() const { return configSection; }
CLI11_NODISCARD const std::string &section() const { return configSection; }
/// specify a particular section of the configuration file to use
ConfigBase *section(const std::string &sectionName) {
configSection = sectionName;
Expand All @@ -158,7 +158,7 @@ class ConfigBase : public Config {
/// get a reference to the configuration index
int16_t &indexRef() { return configIndex; }
/// get the section index
int16_t index() const { return configIndex; }
CLI11_NODISCARD int16_t index() const { return configIndex; }
/// specify a particular index in the section to use (-1) for all sections to use
ConfigBase *index(int16_t sectionIndex) {
configIndex = sectionIndex;
Expand Down
33 changes: 16 additions & 17 deletions 3rdparty/internal/CLI11/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// [CLI11:public_includes:end]

// CLI library includes
#include "Macros.hpp"
#include "StringTools.hpp"

namespace CLI {
Expand Down Expand Up @@ -72,9 +73,9 @@ class Error : public std::runtime_error {
std::string error_name{"Error"};

public:
int get_exit_code() const { return actual_exit_code; }
CLI11_NODISCARD int get_exit_code() const { return actual_exit_code; }

std::string get_name() const { return error_name; }
CLI11_NODISCARD std::string get_name() const { return error_name; }

Error(std::string name, std::string msg, int exit_code = static_cast<int>(ExitCodes::BaseClass))
: runtime_error(msg), actual_exit_code(exit_code), error_name(std::move(name)) {}
Expand Down Expand Up @@ -137,10 +138,10 @@ class OptionAlreadyAdded : public ConstructionError {
explicit OptionAlreadyAdded(std::string name)
: OptionAlreadyAdded(name + " is already added", ExitCodes::OptionAlreadyAdded) {}
static OptionAlreadyAdded Requires(std::string name, std::string other) {
return OptionAlreadyAdded(name + " requires " + other, ExitCodes::OptionAlreadyAdded);
return {name + " requires " + other, ExitCodes::OptionAlreadyAdded};
}
static OptionAlreadyAdded Excludes(std::string name, std::string other) {
return OptionAlreadyAdded(name + " excludes " + other, ExitCodes::OptionAlreadyAdded);
return {name + " excludes " + other, ExitCodes::OptionAlreadyAdded};
}
};

Expand Down Expand Up @@ -223,32 +224,30 @@ class RequiredError : public ParseError {
if(min_subcom == 1) {
return RequiredError("A subcommand");
}
return RequiredError("Requires at least " + std::to_string(min_subcom) + " subcommands",
ExitCodes::RequiredError);
return {"Requires at least " + std::to_string(min_subcom) + " subcommands", ExitCodes::RequiredError};
}
static RequiredError
Option(std::size_t min_option, std::size_t max_option, std::size_t used, const std::string &option_list) {
if((min_option == 1) && (max_option == 1) && (used == 0))
return RequiredError("Exactly 1 option from [" + option_list + "]");
if((min_option == 1) && (max_option == 1) && (used > 1)) {
return RequiredError("Exactly 1 option from [" + option_list + "] is required and " + std::to_string(used) +
" were given",
ExitCodes::RequiredError);
return {"Exactly 1 option from [" + option_list + "] is required and " + std::to_string(used) +
" were given",
ExitCodes::RequiredError};
}
if((min_option == 1) && (used == 0))
return RequiredError("At least 1 option from [" + option_list + "]");
if(used < min_option) {
return RequiredError("Requires at least " + std::to_string(min_option) + " options used and only " +
std::to_string(used) + "were given from [" + option_list + "]",
ExitCodes::RequiredError);
return {"Requires at least " + std::to_string(min_option) + " options used and only " +
std::to_string(used) + "were given from [" + option_list + "]",
ExitCodes::RequiredError};
}
if(max_option == 1)
return RequiredError("Requires at most 1 options be given from [" + option_list + "]",
ExitCodes::RequiredError);
return {"Requires at most 1 options be given from [" + option_list + "]", ExitCodes::RequiredError};

return RequiredError("Requires at most " + std::to_string(max_option) + " options be used and " +
std::to_string(used) + "were given from [" + option_list + "]",
ExitCodes::RequiredError);
return {"Requires at most " + std::to_string(max_option) + " options be used and " + std::to_string(used) +
"were given from [" + option_list + "]",
ExitCodes::RequiredError};
}
};

Expand Down
Loading

0 comments on commit c89ca65

Please sign in to comment.