diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 09b2641..451b3e2 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -1310,6 +1310,7 @@ class abstract_value : public Value no_implicit_value() override { m_implicit = false; + m_disabled_args = false; return shared_from_this(); } diff --git a/test/options.cpp b/test/options.cpp index 23ae158..e2aec47 100644 --- a/test/options.cpp +++ b/test/options.cpp @@ -643,8 +643,10 @@ TEST_CASE("Implicit value with disabled_args", "[no_value]") const char prog_name[] = "disabled_args"; cxxopts::Options options(prog_name, "Implicit value with disabled args"); options.add_options() - ("b,bool", "description", cxxopts::value()->implicit_value("true", true)) - ("s,string", "description", cxxopts::value()->implicit_value("value", true)); + ("b,bool", "bool with disabled_args", cxxopts::value()->implicit_value("true", true)) + ("s,string", "string with disabled_args", cxxopts::value()->implicit_value("value", true)) + ("x,string2", "string with first disabled and then enabled args", + cxxopts::value()->implicit_value("value", true)->no_implicit_value()); struct testcase{ std::string name; Argv argv; @@ -691,10 +693,11 @@ TEST_CASE("Implicit value with disabled_args", "[no_value]") cxxopts::exceptions::no_such_option); } SECTION("No exception"){ - Argv argv{prog_name, "--string", "-b"}; + Argv argv{prog_name, "--string", "-b", "--string2=new_value"}; auto result = options.parse(argv.argc(), argv.argv()); CHECK(result["bool"].as() == true); CHECK(result["string"].as() == "value"); + CHECK(result["string2"].as() == "new_value"); } }