mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-03 14:03:52 +00:00
Adding tidy suggestions, mostly empty() fixes
This commit is contained in:
parent
8cdf1c8651
commit
79aaa8b8d7
@ -552,7 +552,7 @@ class App {
|
|||||||
remove_option(config_ptr_);
|
remove_option(config_ptr_);
|
||||||
config_name_ = default_filename;
|
config_name_ = default_filename;
|
||||||
config_required_ = required;
|
config_required_ = required;
|
||||||
config_ptr_ = add_option(name, config_name_, help, default_filename != "");
|
config_ptr_ = add_option(name, config_name_, help, !default_filename.empty());
|
||||||
return config_ptr_;
|
return config_ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +716,7 @@ class App {
|
|||||||
out << name << "=" << detail::inijoin(opt->results()) << std::endl;
|
out << name << "=" << detail::inijoin(opt->results()) << std::endl;
|
||||||
|
|
||||||
// If the option has a default and is requested by optional argument
|
// If the option has a default and is requested by optional argument
|
||||||
else if(default_also && opt->defaultval_ != "")
|
else if(default_also && !opt->defaultval_.empty())
|
||||||
out << name << "=" << opt->defaultval_ << std::endl;
|
out << name << "=" << opt->defaultval_ << std::endl;
|
||||||
// Flag, one passed
|
// Flag, one passed
|
||||||
} else if(opt->count() == 1) {
|
} else if(opt->count() == 1) {
|
||||||
@ -740,7 +740,7 @@ class App {
|
|||||||
/// Makes a help message, with a column wid for column 1
|
/// Makes a help message, with a column wid for column 1
|
||||||
std::string help(size_t wid = 30, std::string prev = "") const {
|
std::string help(size_t wid = 30, std::string prev = "") const {
|
||||||
// Delegate to subcommand if needed
|
// Delegate to subcommand if needed
|
||||||
if(prev == "")
|
if(prev.empty())
|
||||||
prev = name_;
|
prev = name_;
|
||||||
else
|
else
|
||||||
prev += " " + name_;
|
prev += " " + name_;
|
||||||
@ -931,7 +931,7 @@ class App {
|
|||||||
config_ptr_->run_callback();
|
config_ptr_->run_callback();
|
||||||
config_required_ = true;
|
config_required_ = true;
|
||||||
}
|
}
|
||||||
if(config_name_ != "") {
|
if(!config_name_.empty()) {
|
||||||
try {
|
try {
|
||||||
std::vector<detail::ini_ret_t> values = detail::parse_ini(config_name_);
|
std::vector<detail::ini_ret_t> values = detail::parse_ini(config_name_);
|
||||||
while(!values.empty()) {
|
while(!values.empty()) {
|
||||||
@ -948,7 +948,7 @@ class App {
|
|||||||
|
|
||||||
// Get envname options if not yet passed
|
// Get envname options if not yet passed
|
||||||
for(const Option_p &opt : options_) {
|
for(const Option_p &opt : options_) {
|
||||||
if(opt->count() == 0 && opt->envname_ != "") {
|
if(opt->count() == 0 && !opt->envname_.empty()) {
|
||||||
char *buffer = nullptr;
|
char *buffer = nullptr;
|
||||||
std::string ename_string;
|
std::string ename_string;
|
||||||
|
|
||||||
@ -1029,7 +1029,7 @@ class App {
|
|||||||
std::string name = current.name();
|
std::string name = current.name();
|
||||||
|
|
||||||
// If a parent is listed, go to a subcommand
|
// If a parent is listed, go to a subcommand
|
||||||
if(parent != "") {
|
if(!parent.empty()) {
|
||||||
current.level++;
|
current.level++;
|
||||||
for(const App_p &com : subcommands_)
|
for(const App_p &com : subcommands_)
|
||||||
if(com->check_name(parent))
|
if(com->check_name(parent))
|
||||||
@ -1200,7 +1200,7 @@ class App {
|
|||||||
if(num == 0) {
|
if(num == 0) {
|
||||||
op->add_result("");
|
op->add_result("");
|
||||||
parse_order_.push_back(op.get());
|
parse_order_.push_back(op.get());
|
||||||
} else if(rest != "") {
|
} else if(!rest.empty()) {
|
||||||
if(num > 0)
|
if(num > 0)
|
||||||
num--;
|
num--;
|
||||||
op->add_result(rest);
|
op->add_result(rest);
|
||||||
@ -1223,7 +1223,7 @@ class App {
|
|||||||
parse_order_.push_back(op.get());
|
parse_order_.push_back(op.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rest != "") {
|
if(!rest.empty()) {
|
||||||
rest = "-" + rest;
|
rest = "-" + rest;
|
||||||
args.push_back(rest);
|
args.push_back(rest);
|
||||||
}
|
}
|
||||||
@ -1261,7 +1261,7 @@ class App {
|
|||||||
|
|
||||||
int num = op->get_expected();
|
int num = op->get_expected();
|
||||||
|
|
||||||
if(value != "") {
|
if(!value.empty()) {
|
||||||
if(num != -1)
|
if(num != -1)
|
||||||
num--;
|
num--;
|
||||||
op->add_result(value);
|
op->add_result(value);
|
||||||
|
@ -310,16 +310,16 @@ class Option {
|
|||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
if(get_expected() != 0) {
|
if(get_expected() != 0) {
|
||||||
if(typeval_ != "")
|
if(!typeval_.empty())
|
||||||
out << " " << typeval_;
|
out << " " << typeval_;
|
||||||
if(defaultval_ != "")
|
if(!defaultval_.empty())
|
||||||
out << "=" << defaultval_;
|
out << "=" << defaultval_;
|
||||||
if(get_expected() > 1)
|
if(get_expected() > 1)
|
||||||
out << " x " << get_expected();
|
out << " x " << get_expected();
|
||||||
if(get_expected() == -1)
|
if(get_expected() == -1)
|
||||||
out << " ...";
|
out << " ...";
|
||||||
}
|
}
|
||||||
if(envname_ != "")
|
if(!envname_.empty())
|
||||||
out << " (env:" << envname_ << ")";
|
out << " (env:" << envname_ << ")";
|
||||||
if(!requires_.empty()) {
|
if(!requires_.empty()) {
|
||||||
out << " Requires:";
|
out << " Requires:";
|
||||||
|
@ -18,7 +18,7 @@ namespace detail {
|
|||||||
inline std::vector<std::string> split(const std::string &s, char delim) {
|
inline std::vector<std::string> split(const std::string &s, char delim) {
|
||||||
std::vector<std::string> elems;
|
std::vector<std::string> elems;
|
||||||
// Check to see if emtpy string, give consistent result
|
// Check to see if emtpy string, give consistent result
|
||||||
if(s == "")
|
if(s.empty())
|
||||||
elems.emplace_back("");
|
elems.emplace_back("");
|
||||||
else {
|
else {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
@ -106,7 +106,7 @@ inline std::string trim_copy(const std::string &str, const std::string &filter)
|
|||||||
inline void format_help(std::stringstream &out, std::string name, std::string description, size_t wid) {
|
inline void format_help(std::stringstream &out, std::string name, std::string description, size_t wid) {
|
||||||
name = " " + name;
|
name = " " + name;
|
||||||
out << std::setw(static_cast<int>(wid)) << std::left << name;
|
out << std::setw(static_cast<int>(wid)) << std::left << name;
|
||||||
if(description != "") {
|
if(!description.empty()) {
|
||||||
if(name.length() >= wid)
|
if(name.length() >= wid)
|
||||||
out << std::endl << std::setw(static_cast<int>(wid)) << "";
|
out << std::endl << std::setw(static_cast<int>(wid)) << "";
|
||||||
out << description;
|
out << description;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user