From f78b167a2364d81fe8effab5face0ff888f6d9c2 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 13 May 2021 09:33:30 -0400 Subject: cmCommandLineArgument: Provide more information syntax error messages --- Source/cmCommandLineArgument.h | 7 ++++--- Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt | 2 +- .../CommandLine/build-unknown-command-partial-match-stderr.txt | 2 +- 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 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 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 \[ \| --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 \[ \| --preset \] \[options\] \[-- \[native-options\]\] -- cgit v0.12