Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions args.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 20 additions & 0 deletions test/noexcept_completion.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,25 @@ int main()
p.ParseArgs(std::vector<std::string>{"--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<std::string> f1(sp, "name", "description", {'f', "foo"}, "abc");
sp.Parse();
});

args::Command c2(p2, "command2", "desc", [](args::Subparser &sp)
{
args::ValueFlag<std::string> f1(sp, "name", "description", {'b', "bar"}, "abc");
sp.Parse();
});

p2.ParseArgs(std::vector<std::string>{"--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;
}
Loading