-
Hello all, I did not find a way to specify it. Proposition :
RequiresError.what() will give : Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
TEST_CASE_METHOD(TApp, "NeedsTrue", "[app]") {
std::string str;
CLI::Option *opts = app.add_option("-s,--string", str);
app.add_flag("--opt1")->check([&](const std::string &) {
return (str != "val_with_opt1")?std::string("--opt1 requires --string val_with_opt1"):std::string{};
});
run();
args = {"--opt1"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
args = {"--string", "val"};
run();
args = {"--string", "val", "--opt1"};
CHECK_THROWS_AS(run(), CLI::ValidationError);
args = {"--string", "val_with_opt1", "--opt1"};
run();
args = {"--opt1", "--string", "val_with_opt1"}; // order is not revelant
run();
} The check method can be used for this purpose and other general validation operations. |
Beta Was this translation helpful? Give feedback.
-
Thanks, it works But I need the same thing for Option_group |
Beta Was this translation helpful? Give feedback.
The check metho…