gn: Stop printing all help when the command is unknown
When a command is unrecognized (usually due to a typo), gn previously
printed all the top level help, which scrolled the error off the screen.
Now it just prints the list of known commands.
BUG=
Review-Url: https://codereview.chromium.org/1939603002
Cr-Original-Commit-Position: refs/heads/master@{#390999}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: f2347fca65aa949fb935c500142a5110f99e453c
diff --git a/tools/gn/gn_main.cc b/tools/gn/gn_main.cc
index 135ed56..245270e 100644
--- a/tools/gn/gn_main.cc
+++ b/tools/gn/gn_main.cc
@@ -73,9 +73,12 @@
if (found_command != command_map.end()) {
retval = found_command->second.runner(args);
} else {
- Err(Location(),
- "Command \"" + command + "\" unknown.").PrintToStdout();
- commands::RunHelp(std::vector<std::string>());
+ Err(Location(), "Command \"" + command + "\" unknown.").PrintToStdout();
+ OutputString(
+ "Available commands (type \"gn help <command>\" for more details):\n");
+ for (const auto& cmd : commands::GetCommands())
+ PrintShortHelp(cmd.second.help_short);
+
retval = 1;
}