cmArgumentParser doesn't distinguish between single-arg keywords without an argument and multi-arg keywords without an argument
This issue was found while using file(GET_RUNTIME_DEPENDENCIES)
.
Let's say you have the following use of cmArgumentParser
:
struct Arguments
{
std::string SingleArg;
std::vector<std::string> MultiArg;
};
static auto const parser = cmArgumentParser<Arguments>{}
.Bind("SINGLE_ARG", &Arguments::SingleArg)
.Bind("MULTI_ARG", &Arguments::MultiArg);
std::vector<std::string> keywordsMissingValues;
auto parsedArgs = parser.Parse({"MULTI_ARG"}, nullptr, &keywordsMissingValues);
After this code is run, keywordsMissingValues
will contain MULTI_ARG
. Code that checks !keywordsMissingValues.empty()
for an error will error on this code even though the usage isn't really incorrect. While it's still useful to get a list of multi-arg keywords missing a value for diagnostic purposes, I think we should have a way to distinguish between single-arg keywords and multi-arg keywords.
Currently, you can work around this issue by simply filtering out the multi-arg keywords from keywordsMissingValues
, but I think this usage pattern is going to become common enough that we should add first-class support for it in cmArgumentParser
.