From e591f4aac506e6f25be41074cbd51ca3ba2c85ee Mon Sep 17 00:00:00 2001 From: Philip Top Date: Fri, 3 Oct 2025 06:08:47 -0700 Subject: [PATCH] ensure the parse order is reset on clear() (#1218) Fixes #1216 --- include/CLI/impl/App_inl.hpp | 1 + tests/AppTest.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/CLI/impl/App_inl.hpp b/include/CLI/impl/App_inl.hpp index 614805dd..2a0192c8 100644 --- a/include/CLI/impl/App_inl.hpp +++ b/include/CLI/impl/App_inl.hpp @@ -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(); } diff --git a/tests/AppTest.cpp b/tests/AppTest.cpp index 63f97e08..b75bf9c5 100644 --- a/tests/AppTest.cpp +++ b/tests/AppTest.cpp @@ -2016,6 +2016,8 @@ TEST_CASE_METHOD(TApp, "OriginalOrder", "[app]") { CHECK(std::vector({2}) == st2); CHECK(std::vector({op1, op2, op1, op1}) == app.parse_order()); + app.clear(); + CHECK(app.parse_order().empty()); } TEST_CASE_METHOD(TApp, "NeedsFlags", "[app]") {