From 6ecd741b5ff1931e2f1381479633ceb6ddc47ce6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Jul 2022 15:17:57 -0400 Subject: cmFileCommand: Capture list of parsed keywords via binding --- Source/cmFileCommand.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 987f40e..330d991 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2482,6 +2482,7 @@ bool HandleGenerateCommand(std::vector const& args, bool NoSourcePermissions = false; bool UseSourcePermissions = false; ArgumentParser::NonEmpty> FilePermissions; + std::vector ParsedKeywords; }; static auto const parser = @@ -2494,12 +2495,12 @@ bool HandleGenerateCommand(std::vector const& args, .Bind("NO_SOURCE_PERMISSIONS"_s, &Arguments::NoSourcePermissions) .Bind("USE_SOURCE_PERMISSIONS"_s, &Arguments::UseSourcePermissions) .Bind("FILE_PERMISSIONS"_s, &Arguments::FilePermissions) - .Bind("NEWLINE_STYLE"_s, &Arguments::NewLineStyle); + .Bind("NEWLINE_STYLE"_s, &Arguments::NewLineStyle) + .BindParsedKeywords(&Arguments::ParsedKeywords); std::vector unparsedArguments; - std::vector parsedKeywords; - Arguments const arguments = parser.Parse( - cmMakeRange(args).advance(1), &unparsedArguments, &parsedKeywords); + Arguments const arguments = + parser.Parse(cmMakeRange(args).advance(1), &unparsedArguments); if (arguments.MaybeReportError(status.GetMakefile())) { return true; @@ -2510,7 +2511,7 @@ bool HandleGenerateCommand(std::vector const& args, return false; } - if (!arguments.Output || parsedKeywords[0] != "OUTPUT"_s) { + if (!arguments.Output || arguments.ParsedKeywords[0] != "OUTPUT"_s) { status.SetError("GENERATE requires OUTPUT as first option."); return false; } @@ -2520,8 +2521,8 @@ bool HandleGenerateCommand(std::vector const& args, status.SetError("GENERATE requires INPUT or CONTENT option."); return false; } - const bool inputIsContent = parsedKeywords[1] == "CONTENT"_s; - if (!inputIsContent && parsedKeywords[1] == "INPUT") { + const bool inputIsContent = arguments.ParsedKeywords[1] == "CONTENT"_s; + if (!inputIsContent && arguments.ParsedKeywords[1] == "INPUT") { status.SetError("Unknown argument to GENERATE subcommand."); } std::string const& input = -- cgit v0.12