summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Maynard <rmaynard@nvidia.com>2021-05-13 13:33:30 (GMT)
committerRobert Maynard <rmaynard@nvidia.com>2021-05-13 13:33:30 (GMT)
commitf78b167a2364d81fe8effab5face0ff888f6d9c2 (patch)
treea7e2d36c01ca6484c41b0892eefb4fc247e65794
parent5aa0dec6b011c74225f4af895922edd10db09607 (diff)
downloadCMake-f78b167a2364d81fe8effab5face0ff888f6d9c2.zip
CMake-f78b167a2364d81fe8effab5face0ff888f6d9c2.tar.gz
CMake-f78b167a2364d81fe8effab5face0ff888f6d9c2.tar.bz2
cmCommandLineArgument: Provide more information syntax error messages
-rw-r--r--Source/cmCommandLineArgument.h7
-rw-r--r--Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/build-unknown-command-partial-match-stderr.txt2
3 files changed, 6 insertions, 5 deletions
diff --git a/Source/cmCommandLineArgument.h b/Source/cmCommandLineArgument.h
index f4153fc..ddfff32 100644
--- a/Source/cmCommandLineArgument.h
+++ b/Source/cmCommandLineArgument.h
@@ -25,7 +25,7 @@ struct cmCommandLineArgument
template <typename FunctionType>
cmCommandLineArgument(std::string n, Values t, FunctionType&& func)
- : InvalidSyntaxMessage(cmStrCat("Invalid syntax used with ", n))
+ : InvalidSyntaxMessage(cmStrCat(" is invalid syntax for ", n))
, InvalidValueMessage(cmStrCat("Invalid value used with ", n))
, Name(std::move(n))
, Type(t)
@@ -36,7 +36,7 @@ struct cmCommandLineArgument
template <typename FunctionType>
cmCommandLineArgument(std::string n, std::string failedMsg, Values t,
FunctionType&& func)
- : InvalidSyntaxMessage(cmStrCat("Invalid syntax used with ", n))
+ : InvalidSyntaxMessage(cmStrCat(" is invalid syntax for ", n))
, InvalidValueMessage(std::move(failedMsg))
, Name(std::move(n))
, Type(t)
@@ -150,7 +150,8 @@ struct cmCommandLineArgument
}
if (parseState == ParseMode::SyntaxError) {
- cmSystemTools::Error(this->InvalidSyntaxMessage);
+ cmSystemTools::Error(
+ cmStrCat("'", input, "'", this->InvalidSyntaxMessage));
} else if (parseState == ParseMode::ValueError) {
cmSystemTools::Error(this->InvalidValueMessage);
}
diff --git a/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt b/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt
index ce1c92d..5fe2539 100644
--- a/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt
+++ b/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: Invalid syntax used with --target
+^CMake Error: '--target=invalid' is invalid syntax for --target
Usage: cmake --build \[<dir> \| --preset <preset>\] \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/build-unknown-command-partial-match-stderr.txt b/Tests/RunCMake/CommandLine/build-unknown-command-partial-match-stderr.txt
index ce1c92d..d69338a 100644
--- a/Tests/RunCMake/CommandLine/build-unknown-command-partial-match-stderr.txt
+++ b/Tests/RunCMake/CommandLine/build-unknown-command-partial-match-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: Invalid syntax used with --target
+^CMake Error: '--targetinvalid' is invalid syntax for --target
Usage: cmake --build \[<dir> \| --preset <preset>\] \[options\] \[-- \[native-options\]\]