Show error with gn desc when no matches are made This tells the user that they input a value that matches nothing so that they know they need to correct the input and try again rather than showing no output and acting like the command worked correctly Bug: 646012 Change-Id: I9e796a4a09216dde8939e4a60b255f8beff0c52b Reviewed-on: https://chromium-review.googlesource.com/1037910 Reviewed-by: Dirk Pranke <dpranke@chromium.org> Commit-Queue: Eli Ribble <eliribble@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#555188} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 9e71c94d75e6c6e8fecbb601ddde8d3f35c4fba1
diff --git a/tools/gn/command_desc.cc b/tools/gn/command_desc.cc index 9a9b243..9bd68e4 100644 --- a/tools/gn/command_desc.cc +++ b/tools/gn/command_desc.cc
@@ -456,6 +456,12 @@ bool json = cmdline->GetSwitchValueASCII("format") == "json"; + if (target_matches.empty() && config_matches.empty()) { + OutputString("The input " + args[1] + + " matches no targets, configs or files.\n", DECORATION_YELLOW); + return 1; + } + if (json) { // Convert all targets/configs to JSON, serialize and print them auto res = std::make_unique<base::DictionaryValue>();