Parcourir la source

cmFileCommand: Capture list of parsed keywords via binding

Brad King il y a 3 ans
Parent
commit
6ecd741b5f
1 fichiers modifiés avec 8 ajouts et 7 suppressions
  1. 8 7
      Source/cmFileCommand.cxx

+ 8 - 7
Source/cmFileCommand.cxx

@@ -2482,6 +2482,7 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
     bool NoSourcePermissions = false;
     bool NoSourcePermissions = false;
     bool UseSourcePermissions = false;
     bool UseSourcePermissions = false;
     ArgumentParser::NonEmpty<std::vector<std::string>> FilePermissions;
     ArgumentParser::NonEmpty<std::vector<std::string>> FilePermissions;
+    std::vector<cm::string_view> ParsedKeywords;
   };
   };
 
 
   static auto const parser =
   static auto const parser =
@@ -2494,12 +2495,12 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
       .Bind("NO_SOURCE_PERMISSIONS"_s, &Arguments::NoSourcePermissions)
       .Bind("NO_SOURCE_PERMISSIONS"_s, &Arguments::NoSourcePermissions)
       .Bind("USE_SOURCE_PERMISSIONS"_s, &Arguments::UseSourcePermissions)
       .Bind("USE_SOURCE_PERMISSIONS"_s, &Arguments::UseSourcePermissions)
       .Bind("FILE_PERMISSIONS"_s, &Arguments::FilePermissions)
       .Bind("FILE_PERMISSIONS"_s, &Arguments::FilePermissions)
-      .Bind("NEWLINE_STYLE"_s, &Arguments::NewLineStyle);
+      .Bind("NEWLINE_STYLE"_s, &Arguments::NewLineStyle)
+      .BindParsedKeywords(&Arguments::ParsedKeywords);
 
 
   std::vector<std::string> unparsedArguments;
   std::vector<std::string> unparsedArguments;
-  std::vector<cm::string_view> 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())) {
   if (arguments.MaybeReportError(status.GetMakefile())) {
     return true;
     return true;
@@ -2510,7 +2511,7 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
     return false;
     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.");
     status.SetError("GENERATE requires OUTPUT as first option.");
     return false;
     return false;
   }
   }
@@ -2520,8 +2521,8 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
     status.SetError("GENERATE requires INPUT or CONTENT option.");
     status.SetError("GENERATE requires INPUT or CONTENT option.");
     return false;
     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.");
     status.SetError("Unknown argument to GENERATE subcommand.");
   }
   }
   std::string const& input =
   std::string const& input =