diff --git a/args.hxx b/args.hxx index 8eba1f2..dd12861 100644 --- a/args.hxx +++ b/args.hxx @@ -3186,6 +3186,8 @@ namespace args // `end` instead so the iterator stays in the caller's // container. Parse(curArgs.begin(), curArgs.end()); + error = Error::Completion; + errorMsg.clear(); return end; #endif } diff --git a/test/noexcept_completion.cxx b/test/noexcept_completion.cxx index 4d4af54..2523bd4 100644 --- a/test/noexcept_completion.cxx +++ b/test/noexcept_completion.cxx @@ -21,5 +21,25 @@ int main() p.ParseArgs(std::vector{"--completion", "bash", "1", "test", "-"}); test::require(p.GetError() == args::Error::Completion); test::require(args::get(c) == "-f\n-b"); + + args::ArgumentParser p2("parser"); + args::CompletionFlag complete2(p2, {"completion"}); + + args::Command c1(p2, "command1", "desc", [](args::Subparser &sp) + { + args::ValueFlag f1(sp, "name", "description", {'f', "foo"}, "abc"); + sp.Parse(); + }); + + args::Command c2(p2, "command2", "desc", [](args::Subparser &sp) + { + args::ValueFlag f1(sp, "name", "description", {'b', "bar"}, "abc"); + sp.Parse(); + }); + + p2.ParseArgs(std::vector{"--completion", "bash", "2", "test", "command3", ""}); + test::require(p2.GetError() == args::Error::Completion); + test::require(p2.GetErrorMsg().empty()); + test::require(args::get(complete2).empty()); return 0; }