OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "tools/gn/args.h" | 9 #include "tools/gn/args.h" |
10 #include "tools/gn/commands.h" | 10 #include "tools/gn/commands.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 PrintShortHelp(target.second.help_short); | 59 PrintShortHelp(target.second.help_short); |
60 | 60 |
61 OutputString("\nOther help topics:\n"); | 61 OutputString("\nOther help topics:\n"); |
62 PrintShortHelp("all: Print all the help at once"); | 62 PrintShortHelp("all: Print all the help at once"); |
63 PrintShortHelp("buildargs: How build arguments work."); | 63 PrintShortHelp("buildargs: How build arguments work."); |
64 PrintShortHelp("dotfile: Info about the toplevel .gn file."); | 64 PrintShortHelp("dotfile: Info about the toplevel .gn file."); |
65 PrintShortHelp("grammar: Formal grammar for GN build files."); | 65 PrintShortHelp("grammar: Formal grammar for GN build files."); |
66 PrintShortHelp( | 66 PrintShortHelp( |
67 "input_conversion: Processing input from exec_script and read_file."); | 67 "input_conversion: Processing input from exec_script and read_file."); |
68 PrintShortHelp("label_pattern: Matching more than one label."); | 68 PrintShortHelp("label_pattern: Matching more than one label."); |
| 69 PrintShortHelp("nogncheck: Annotating includes for checking."); |
69 PrintShortHelp("runtime_deps: How runtime dependency computation works."); | 70 PrintShortHelp("runtime_deps: How runtime dependency computation works."); |
70 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); | 71 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); |
71 PrintShortHelp("switches: Show available command-line switches."); | 72 PrintShortHelp("switches: Show available command-line switches."); |
72 } | 73 } |
73 | 74 |
74 void PrintSwitchHelp() { | 75 void PrintSwitchHelp() { |
75 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 76 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
76 bool use_markdown = cmdline->HasSwitch(switches::kMarkdown); | 77 bool use_markdown = cmdline->HasSwitch(switches::kMarkdown); |
77 | 78 |
78 OutputString("Available global switches\n", DECORATION_YELLOW); | 79 OutputString("Available global switches\n", DECORATION_YELLOW); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 PrintLongHelp(v.second.help); | 120 PrintLongHelp(v.second.help); |
120 | 121 |
121 for (const auto& v: variables::GetTargetVariables()) | 122 for (const auto& v: variables::GetTargetVariables()) |
122 PrintLongHelp(v.second.help); | 123 PrintLongHelp(v.second.help); |
123 | 124 |
124 PrintLongHelp(kBuildArgs_Help); | 125 PrintLongHelp(kBuildArgs_Help); |
125 PrintLongHelp(kDotfile_Help); | 126 PrintLongHelp(kDotfile_Help); |
126 PrintLongHelp(kGrammar_Help); | 127 PrintLongHelp(kGrammar_Help); |
127 PrintLongHelp(kInputConversion_Help); | 128 PrintLongHelp(kInputConversion_Help); |
128 PrintLongHelp(kLabelPattern_Help); | 129 PrintLongHelp(kLabelPattern_Help); |
| 130 PrintLongHelp(kNoGnCheck_Help); |
129 PrintLongHelp(kRuntimeDeps_Help); | 131 PrintLongHelp(kRuntimeDeps_Help); |
130 PrintLongHelp(kSourceExpansion_Help); | 132 PrintLongHelp(kSourceExpansion_Help); |
131 PrintSwitchHelp(); | 133 PrintSwitchHelp(); |
132 } | 134 } |
133 | 135 |
134 // Prints help on the given switch. There should be no leading hyphens. Returns | 136 // Prints help on the given switch. There should be no leading hyphens. Returns |
135 // true if the switch was found and help was printed. False means the switch is | 137 // true if the switch was found and help was printed. False means the switch is |
136 // unknown. | 138 // unknown. |
137 bool PrintHelpOnSwitch(const std::string& what) { | 139 bool PrintHelpOnSwitch(const std::string& what) { |
138 const switches::SwitchInfoMap& all = switches::GetSwitches(); | 140 const switches::SwitchInfoMap& all = switches::GetSwitches(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Random other topics. | 226 // Random other topics. |
225 std::map<std::string, void(*)()> random_topics; | 227 std::map<std::string, void(*)()> random_topics; |
226 random_topics["all"] = PrintAllHelp; | 228 random_topics["all"] = PrintAllHelp; |
227 random_topics["buildargs"] = []() { PrintLongHelp(kBuildArgs_Help); }; | 229 random_topics["buildargs"] = []() { PrintLongHelp(kBuildArgs_Help); }; |
228 random_topics["dotfile"] = []() { PrintLongHelp(kDotfile_Help); }; | 230 random_topics["dotfile"] = []() { PrintLongHelp(kDotfile_Help); }; |
229 random_topics["grammar"] = []() { PrintLongHelp(kGrammar_Help); }; | 231 random_topics["grammar"] = []() { PrintLongHelp(kGrammar_Help); }; |
230 random_topics["input_conversion"] = []() { | 232 random_topics["input_conversion"] = []() { |
231 PrintLongHelp(kInputConversion_Help); | 233 PrintLongHelp(kInputConversion_Help); |
232 }; | 234 }; |
233 random_topics["label_pattern"] = []() { PrintLongHelp(kLabelPattern_Help); }; | 235 random_topics["label_pattern"] = []() { PrintLongHelp(kLabelPattern_Help); }; |
| 236 random_topics["nogncheck"] = []() { PrintLongHelp(kNoGnCheck_Help); }; |
234 random_topics["runtime_deps"] = []() { PrintLongHelp(kRuntimeDeps_Help); }; | 237 random_topics["runtime_deps"] = []() { PrintLongHelp(kRuntimeDeps_Help); }; |
235 random_topics["source_expansion"] = []() { | 238 random_topics["source_expansion"] = []() { |
236 PrintLongHelp(kSourceExpansion_Help); | 239 PrintLongHelp(kSourceExpansion_Help); |
237 }; | 240 }; |
238 random_topics["switches"] = PrintSwitchHelp; | 241 random_topics["switches"] = PrintSwitchHelp; |
239 auto found_random_topic = random_topics.find(what); | 242 auto found_random_topic = random_topics.find(what); |
240 if (found_random_topic != random_topics.end()) { | 243 if (found_random_topic != random_topics.end()) { |
241 found_random_topic->second(); | 244 found_random_topic->second(); |
242 return 0; | 245 return 0; |
243 } | 246 } |
244 for (const auto& entry : random_topics) | 247 for (const auto& entry : random_topics) |
245 all_help_topics.push_back(entry.first); | 248 all_help_topics.push_back(entry.first); |
246 | 249 |
247 // No help on this. | 250 // No help on this. |
248 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); | 251 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); |
249 base::StringPiece suggestion = SpellcheckString(what, all_help_topics); | 252 base::StringPiece suggestion = SpellcheckString(what, all_help_topics); |
250 if (suggestion.empty()) { | 253 if (suggestion.empty()) { |
251 OutputString("Run `gn help` for a list of available topics.\n", | 254 OutputString("Run `gn help` for a list of available topics.\n", |
252 DECORATION_NONE); | 255 DECORATION_NONE); |
253 } else { | 256 } else { |
254 OutputString("Did you mean `gn help " + suggestion.as_string() + "`?\n", | 257 OutputString("Did you mean `gn help " + suggestion.as_string() + "`?\n", |
255 DECORATION_NONE); | 258 DECORATION_NONE); |
256 } | 259 } |
257 return 1; | 260 return 1; |
258 } | 261 } |
259 | 262 |
260 } // namespace commands | 263 } // namespace commands |
OLD | NEW |