mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 18:29:37 -06:00
cmCMakeHost*Command: Report keyword errors via argument parser results
This commit is contained in:
@@ -474,7 +474,7 @@ bool QueryWindowsRegistry(Range args, cmExecutionStatus& status,
|
||||
}
|
||||
std::string const& key = *args.begin();
|
||||
|
||||
struct Arguments
|
||||
struct Arguments : public ArgumentParser::ParseResult
|
||||
{
|
||||
std::string ValueName;
|
||||
bool ValueNames = false;
|
||||
@@ -491,19 +491,15 @@ bool QueryWindowsRegistry(Range args, cmExecutionStatus& status,
|
||||
.Bind("SEPARATOR"_s, &Arguments::Separator)
|
||||
.Bind("ERROR_VARIABLE"_s, &Arguments::ErrorVariable);
|
||||
std::vector<std::string> invalidArgs;
|
||||
std::vector<cm::string_view> keywordsMissingValue;
|
||||
|
||||
Arguments const arguments =
|
||||
parser.Parse(args.advance(1), &invalidArgs, &keywordsMissingValue);
|
||||
Arguments const arguments = parser.Parse(args.advance(1), &invalidArgs);
|
||||
if (!invalidArgs.empty()) {
|
||||
status.SetError(cmStrCat("given invalid argument(s) \"",
|
||||
cmJoin(invalidArgs, ", "_s), "\"."));
|
||||
return false;
|
||||
}
|
||||
if (!keywordsMissingValue.empty()) {
|
||||
status.SetError(cmStrCat("missing expected value for argument(s) \"",
|
||||
cmJoin(keywordsMissingValue, ", "_s), "\"."));
|
||||
return false;
|
||||
if (arguments.MaybeReportError(status.GetMakefile())) {
|
||||
return true;
|
||||
}
|
||||
if ((!arguments.ValueName.empty() &&
|
||||
(arguments.ValueNames || arguments.SubKeys)) ||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
CMake Error at Registry_BadQuery2.cmake:[0-9]+ \(cmake_host_system_information\):
|
||||
cmake_host_system_information missing expected value for argument\(s\)
|
||||
"VALUE".
|
||||
Error after keyword "VALUE":
|
||||
|
||||
missing required value
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
CMake Error at Registry_BadView1.cmake:[0-9]+ \(cmake_host_system_information\):
|
||||
cmake_host_system_information missing expected value for argument\(s\)
|
||||
"VIEW".
|
||||
Error after keyword "VIEW":
|
||||
|
||||
missing required value
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
|
||||
Reference in New Issue
Block a user