mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 12:13:52 +00:00
Adding remaining, only works on master app for now
This commit is contained in:
parent
ebd238a9db
commit
fc35014dad
@ -863,6 +863,15 @@ class App {
|
||||
/// This gets a vector of pointers with the original parse order
|
||||
const std::vector<Option *> &parse_order() const { return parse_order_; }
|
||||
|
||||
/// This retuns the missing options from the current subcommand
|
||||
std::vector<std::string> remaining() const {
|
||||
std::vector<std::string> miss_list;
|
||||
for(const std::pair<detail::Classifer, std::string>& miss : missing_) {
|
||||
miss_list.push_back(std::get<1>(miss));
|
||||
}
|
||||
return miss_list;
|
||||
}
|
||||
|
||||
///@}
|
||||
|
||||
protected:
|
||||
|
@ -281,6 +281,32 @@ TEST_F(TApp, RequiredSubCom) {
|
||||
run();
|
||||
}
|
||||
|
||||
TEST_F(TApp, SubComExtras) {
|
||||
app.allow_extras();
|
||||
auto sub = app.add_subcommand("sub");
|
||||
|
||||
args = {"extra", "sub"};
|
||||
run();
|
||||
EXPECT_EQ(app.remaining(), std::vector<std::string>({"extra"}));
|
||||
EXPECT_EQ(sub->remaining(), std::vector<std::string>());
|
||||
|
||||
app.reset();
|
||||
|
||||
args = {"extra1", "extra2", "sub"};
|
||||
run();
|
||||
EXPECT_EQ(app.remaining(), std::vector<std::string>({"extra1", "extra2"}));
|
||||
EXPECT_EQ(sub->remaining(), std::vector<std::string>());
|
||||
|
||||
app.reset();
|
||||
|
||||
//args = {"sub", "extra"};
|
||||
//run();
|
||||
//EXPECT_EQ(app.remaining(), std::vector<std::string>());
|
||||
//EXPECT_EQ(sub->remaining(), std::vector<std::string>({"extra"}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST_F(TApp, Required1SubCom) {
|
||||
app.require_subcommand(1);
|
||||
app.add_subcommand("sub1");
|
||||
|
Loading…
x
Reference in New Issue
Block a user