1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00

Removing deprecated features (#380)

This commit is contained in:
Henry Schreiner 2019-12-30 17:52:44 -05:00 committed by GitHub
parent c901ac4bed
commit 8e8746a907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 344 deletions

View File

@ -836,164 +836,6 @@ class App {
return opt;
}
/// Add set of options, string only, ignore case (no default, static set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_case)) instead")
Option *add_set_ignore_case(std::string option_name,
std::string &member, ///< The selected member of the set
std::set<std::string> options, ///< The set of possibilities
std::string option_description = "") {
Option *opt = add_option(option_name, member, std::move(option_description));
opt->transform(IsMember{options, CLI::ignore_case});
return opt;
}
/// Add set of options, string only, ignore case (no default, set can be changed afterwards - do not destroy the
/// set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_case)) with a (shared) pointer instead")
Option *add_mutable_set_ignore_case(std::string option_name,
std::string &member, ///< The selected member of the set
const std::set<std::string> &options, ///< The set of possibilities
std::string option_description = "") {
Option *opt = add_option(option_name, member, std::move(option_description));
opt->transform(IsMember{&options, CLI::ignore_case});
return opt;
}
/// Add set of options, string only, ignore case (default, static set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_case)) instead")
Option *add_set_ignore_case(std::string option_name,
std::string &member, ///< The selected member of the set
std::set<std::string> options, ///< The set of possibilities
std::string option_description,
bool defaulted) {
Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->transform(IsMember{options, CLI::ignore_case});
return opt;
}
/// Add set of options, string only, ignore case (default, set can be changed afterwards - do not destroy the
/// set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(...)) with a (shared) pointer instead")
Option *add_mutable_set_ignore_case(std::string option_name,
std::string &member, ///< The selected member of the set
const std::set<std::string> &options, ///< The set of possibilities
std::string option_description,
bool defaulted) {
Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->transform(IsMember{&options, CLI::ignore_case});
return opt;
}
/// Add set of options, string only, ignore underscore (no default, static set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_underscore)) instead")
Option *add_set_ignore_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
std::set<std::string> options, ///< The set of possibilities
std::string option_description = "") {
Option *opt = add_option(option_name, member, std::move(option_description));
opt->transform(IsMember{options, CLI::ignore_underscore});
return opt;
}
/// Add set of options, string only, ignore underscore (no default, set can be changed afterwards - do not
/// destroy the set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_underscore)) with a (shared) pointer instead")
Option *add_mutable_set_ignore_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
const std::set<std::string> &options, ///< The set of possibilities
std::string option_description = "") {
Option *opt = add_option(option_name, member, std::move(option_description));
opt->transform(IsMember{options, CLI::ignore_underscore});
return opt;
}
/// Add set of options, string only, ignore underscore (default, static set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_underscore)) instead")
Option *add_set_ignore_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
std::set<std::string> options, ///< The set of possibilities
std::string option_description,
bool defaulted) {
Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->transform(IsMember{options, CLI::ignore_underscore});
return opt;
}
/// Add set of options, string only, ignore underscore (default, set can be changed afterwards - do not destroy
/// the set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_underscore)) with a (shared) pointer instead")
Option *add_mutable_set_ignore_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
const std::set<std::string> &options, ///< The set of possibilities
std::string option_description,
bool defaulted) {
Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->transform(IsMember{&options, CLI::ignore_underscore});
return opt;
}
/// Add set of options, string only, ignore underscore and case (no default, static set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) instead")
Option *add_set_ignore_case_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
std::set<std::string> options, ///< The set of possibilities
std::string option_description = "") {
Option *opt = add_option(option_name, member, std::move(option_description));
opt->transform(IsMember{options, CLI::ignore_underscore, CLI::ignore_case});
return opt;
}
/// Add set of options, string only, ignore underscore and case (no default, set can be changed afterwards - do
/// not destroy the set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) with a "
"(shared) pointer instead")
Option *add_mutable_set_ignore_case_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
const std::set<std::string> &options, ///< The set of possibilities
std::string option_description = "") {
Option *opt = add_option(option_name, member, std::move(option_description));
opt->transform(IsMember{&options, CLI::ignore_underscore, CLI::ignore_case});
return opt;
}
/// Add set of options, string only, ignore underscore and case (default, static set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) instead")
Option *add_set_ignore_case_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
std::set<std::string> options, ///< The set of possibilities
std::string option_description,
bool defaulted) {
Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->transform(IsMember{options, CLI::ignore_underscore, CLI::ignore_case});
return opt;
}
/// Add set of options, string only, ignore underscore and case (default, set can be changed afterwards - do not
/// destroy the set) DEPRECATED
CLI11_DEPRECATED("Use ->transform(CLI::IsMember(..., CLI::ignore_case, CLI::ignore_underscore)) with a "
"(shared) pointer instead")
Option *add_mutable_set_ignore_case_underscore(std::string option_name,
std::string &member, ///< The selected member of the set
const std::set<std::string> &options, ///< The set of possibilities
std::string option_description,
bool defaulted) {
Option *opt = add_option(option_name, member, std::move(option_description), defaulted);
opt->transform(IsMember{&options, CLI::ignore_underscore, CLI::ignore_case});
return opt;
}
/// Add a complex number
template <typename T, typename XC = double>
Option *add_complex(std::string option_name,

View File

@ -652,10 +652,6 @@ class Option : public OptionBase<Option> {
/// The set of options excluded
std::set<Option *> get_excludes() const { return excludes_; }
/// The default value (for help printing) DEPRECATED Use get_default_str() instead
CLI11_DEPRECATED("Use get_default_str() instead")
std::string get_defaultval() const { return default_str_; }
/// The default value (for help printing)
std::string get_default_str() const { return default_str_; }

View File

@ -30,15 +30,6 @@ TEST_F(TApp, SetWithDefaultsConversion) {
EXPECT_THROW(run(), CLI::ValidationError);
}
TEST_F(TApp, SetWithDefaultsIC) {
std::string someint = "ho";
app.add_set_ignore_case("-a", someint, {"Hi", "Ho"}, "", true);
args = {"-aHi", "-aHo"};
EXPECT_THROW(run(), CLI::ArgumentMismatch);
}
TEST_F(TApp, InSet) {
std::string choice;
@ -70,23 +61,6 @@ TEST_F(TApp, InSetWithDefault) {
EXPECT_THROW(run(), CLI::ValidationError);
}
TEST_F(TApp, InCaselessSetWithDefault) {
std::string choice = "one";
app.add_set_ignore_case("-q,--quick", choice, {"one", "two", "three"}, "", true);
run();
EXPECT_EQ("one", choice);
args = {"--quick", "tWo"};
run();
EXPECT_EQ("two", choice);
args = {"--quick", "four"};
EXPECT_THROW(run(), CLI::ValidationError);
}
TEST_F(TApp, InIntSet) {
int choice;
@ -144,131 +118,6 @@ TEST_F(TApp, FailMutableSet) {
EXPECT_THROW(run(), CLI::ValidationError);
}
TEST_F(TApp, InSetIgnoreCase) {
std::string choice;
app.add_set_ignore_case("-q,--quick", choice, {"one", "Two", "THREE"});
args = {"--quick", "One"};
run();
EXPECT_EQ("one", choice);
args = {"--quick", "two"};
run();
EXPECT_EQ("Two", choice); // Keeps caps from set
args = {"--quick", "ThrEE"};
run();
EXPECT_EQ("THREE", choice); // Keeps caps from set
args = {"--quick", "four"};
EXPECT_THROW(run(), CLI::ValidationError);
args = {"--quick=one", "--quick=two"};
EXPECT_THROW(run(), CLI::ArgumentMismatch);
}
TEST_F(TApp, InSetIgnoreCaseMutableValue) {
std::set<std::string> options{"one", "Two", "THREE"};
std::string choice;
app.add_mutable_set_ignore_case("-q,--quick", choice, options);
args = {"--quick", "One"};
run();
EXPECT_EQ("one", choice);
args = {"--quick", "two"};
run();
EXPECT_EQ("Two", choice); // Keeps caps from set
args = {"--quick", "ThrEE"};
run();
EXPECT_EQ("THREE", choice); // Keeps caps from set
options.clear();
args = {"--quick", "ThrEE"};
EXPECT_THROW(run(), CLI::ValidationError);
}
TEST_F(TApp, InSetIgnoreCasePointer) {
auto options = std::make_shared<std::set<std::string>>(std::initializer_list<std::string>{"one", "Two", "THREE"});
std::string choice;
app.add_set_ignore_case("-q,--quick", choice, *options);
args = {"--quick", "One"};
run();
EXPECT_EQ("one", choice);
args = {"--quick", "two"};
run();
EXPECT_EQ("Two", choice); // Keeps caps from set
args = {"--quick", "ThrEE"};
run();
EXPECT_EQ("THREE", choice); // Keeps caps from set
options.reset();
args = {"--quick", "ThrEE"};
run();
EXPECT_EQ("THREE", choice); // this does not throw a segfault
args = {"--quick", "four"};
EXPECT_THROW(run(), CLI::ValidationError);
args = {"--quick=one", "--quick=two"};
EXPECT_THROW(run(), CLI::ArgumentMismatch);
}
TEST_F(TApp, InSetIgnoreUnderscore) {
std::string choice;
app.add_set_ignore_underscore("-q,--quick", choice, {"option_one", "option_two", "optionthree"});
args = {"--quick", "option_one"};
run();
EXPECT_EQ("option_one", choice);
args = {"--quick", "optiontwo"};
run();
EXPECT_EQ("option_two", choice); // Keeps underscore from set
args = {"--quick", "_option_thr_ee"};
run();
EXPECT_EQ("optionthree", choice); // no underscore
args = {"--quick", "Option4"};
EXPECT_THROW(run(), CLI::ValidationError);
args = {"--quick=option_one", "--quick=option_two"};
EXPECT_THROW(run(), CLI::ArgumentMismatch);
}
TEST_F(TApp, InSetIgnoreCaseUnderscore) {
std::string choice;
app.add_set_ignore_case_underscore("-q,--quick", choice, {"Option_One", "option_two", "OptionThree"});
args = {"--quick", "option_one"};
run();
EXPECT_EQ("Option_One", choice);
args = {"--quick", "OptionTwo"};
run();
EXPECT_EQ("option_two", choice); // Keeps underscore and case from set
args = {"--quick", "_OPTION_thr_ee"};
run();
EXPECT_EQ("OptionThree", choice); // no underscore
args = {"--quick", "Option4"};
EXPECT_THROW(run(), CLI::ValidationError);
args = {"--quick=option_one", "--quick=option_two"};
EXPECT_THROW(run(), CLI::ArgumentMismatch);
}
// #113
TEST_F(TApp, AddRemoveSetItems) {
std::set<std::string> items{"TYPE1", "TYPE2", "TYPE3", "TYPE4", "TYPE5"};
@ -301,37 +150,6 @@ TEST_F(TApp, AddRemoveSetItems) {
EXPECT_THROW(run(), CLI::ValidationError);
}
TEST_F(TApp, AddRemoveSetItemsNoCase) {
std::set<std::string> items{"TYPE1", "TYPE2", "TYPE3", "TYPE4", "TYPE5"};
std::string type1, type2;
app.add_mutable_set_ignore_case("--type1", type1, items);
app.add_mutable_set_ignore_case("--type2", type2, items, "", true);
args = {"--type1", "TYPe1", "--type2", "TyPE2"};
run();
EXPECT_EQ(type1, "TYPE1");
EXPECT_EQ(type2, "TYPE2");
items.insert("TYPE6");
items.insert("TYPE7");
items.erase("TYPE1");
items.erase("TYPE2");
args = {"--type1", "TyPE6", "--type2", "tYPE7"};
run();
EXPECT_EQ(type1, "TYPE6");
EXPECT_EQ(type2, "TYPE7");
args = {"--type1", "TYPe1"};
EXPECT_THROW(run(), CLI::ValidationError);
args = {"--type2", "TYpE2"};
EXPECT_THROW(run(), CLI::ValidationError);
}
TEST(THelp, Defaults) {
CLI::App app{"My prog"};