ensure the parse order is reset on clear() (#1218)

Fixes #1216
This commit is contained in:
Philip Top
2025-10-03 06:08:47 -07:00
committed by GitHub
parent e83695fb10
commit e591f4aac5
2 changed files with 3 additions and 0 deletions

View File

@@ -582,6 +582,7 @@ CLI11_INLINE void App::clear() {
missing_.clear();
parsed_subcommands_.clear();
parse_order_.clear();
for(const Option_p &opt : options_) {
opt->clear();
}

View File

@@ -2016,6 +2016,8 @@ TEST_CASE_METHOD(TApp, "OriginalOrder", "[app]") {
CHECK(std::vector<int>({2}) == st2);
CHECK(std::vector<CLI::Option *>({op1, op2, op1, op1}) == app.parse_order());
app.clear();
CHECK(app.parse_order().empty());
}
TEST_CASE_METHOD(TApp, "NeedsFlags", "[app]") {