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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (found_command != command_map.end()) { | 238 if (found_command != command_map.end()) { |
239 PrintLongHelp(found_command->second.help); | 239 PrintLongHelp(found_command->second.help); |
240 return 0; | 240 return 0; |
241 } | 241 } |
242 for (const auto& entry : command_map) | 242 for (const auto& entry : command_map) |
243 all_help_topics.push_back(entry.first); | 243 all_help_topics.push_back(entry.first); |
244 | 244 |
245 // Check functions. | 245 // Check functions. |
246 const functions::FunctionInfoMap& function_map = functions::GetFunctions(); | 246 const functions::FunctionInfoMap& function_map = functions::GetFunctions(); |
247 auto found_function = function_map.find(what); | 247 auto found_function = function_map.find(what); |
248 if (found_function != function_map.end()) { | 248 if (found_function != function_map.end()) |
249 PrintLongHelp(found_function->second.help); | 249 PrintLongHelp(found_function->second.help); |
250 return 0; | |
251 } | |
252 for (const auto& entry : function_map) | 250 for (const auto& entry : function_map) |
253 all_help_topics.push_back(entry.first); | 251 all_help_topics.push_back(entry.first); |
254 | 252 |
255 // Builtin variables. | 253 // Builtin variables. |
256 const variables::VariableInfoMap& builtin_vars = | 254 const variables::VariableInfoMap& builtin_vars = |
257 variables::GetBuiltinVariables(); | 255 variables::GetBuiltinVariables(); |
258 auto found_builtin_var = builtin_vars.find(what); | 256 auto found_builtin_var = builtin_vars.find(what); |
259 if (found_builtin_var != builtin_vars.end()) { | 257 if (found_builtin_var != builtin_vars.end()) |
260 PrintLongHelp(found_builtin_var->second.help); | 258 PrintLongHelp(found_builtin_var->second.help); |
261 return 0; | |
262 } | |
263 for (const auto& entry : builtin_vars) | 259 for (const auto& entry : builtin_vars) |
264 all_help_topics.push_back(entry.first); | 260 all_help_topics.push_back(entry.first); |
265 | 261 |
266 // Target variables. | 262 // Target variables. |
267 const variables::VariableInfoMap& target_vars = | 263 const variables::VariableInfoMap& target_vars = |
268 variables::GetTargetVariables(); | 264 variables::GetTargetVariables(); |
269 auto found_target_var = target_vars.find(what); | 265 auto found_target_var = target_vars.find(what); |
270 if (found_target_var != target_vars.end()) { | 266 if (found_target_var != target_vars.end()) |
271 PrintLongHelp(found_target_var->second.help); | 267 PrintLongHelp(found_target_var->second.help); |
272 return 0; | |
273 } | |
274 for (const auto& entry : target_vars) | 268 for (const auto& entry : target_vars) |
275 all_help_topics.push_back(entry.first); | 269 all_help_topics.push_back(entry.first); |
276 | 270 |
| 271 if (found_function != function_map.end() || |
| 272 found_builtin_var != builtin_vars.end() || |
| 273 found_target_var != target_vars.end()) |
| 274 return 0; |
| 275 |
277 // Random other topics. | 276 // Random other topics. |
278 std::map<std::string, void(*)()> random_topics; | 277 std::map<std::string, void(*)()> random_topics; |
279 random_topics["all"] = PrintAllHelp; | 278 random_topics["all"] = PrintAllHelp; |
280 random_topics["execution"] = []() { PrintLongHelp(kExecution_Help); }; | 279 random_topics["execution"] = []() { PrintLongHelp(kExecution_Help); }; |
281 random_topics["buildargs"] = []() { PrintLongHelp(kBuildArgs_Help); }; | 280 random_topics["buildargs"] = []() { PrintLongHelp(kBuildArgs_Help); }; |
282 random_topics["dotfile"] = []() { PrintLongHelp(kDotfile_Help); }; | 281 random_topics["dotfile"] = []() { PrintLongHelp(kDotfile_Help); }; |
283 random_topics["grammar"] = []() { PrintLongHelp(kGrammar_Help); }; | 282 random_topics["grammar"] = []() { PrintLongHelp(kGrammar_Help); }; |
284 random_topics["input_conversion"] = []() { | 283 random_topics["input_conversion"] = []() { |
285 PrintLongHelp(kInputConversion_Help); | 284 PrintLongHelp(kInputConversion_Help); |
286 }; | 285 }; |
(...skipping 21 matching lines...) Expand all Loading... |
308 OutputString("Run `gn help` for a list of available topics.\n", | 307 OutputString("Run `gn help` for a list of available topics.\n", |
309 DECORATION_NONE); | 308 DECORATION_NONE); |
310 } else { | 309 } else { |
311 OutputString("Did you mean `gn help " + suggestion.as_string() + "`?\n", | 310 OutputString("Did you mean `gn help " + suggestion.as_string() + "`?\n", |
312 DECORATION_NONE); | 311 DECORATION_NONE); |
313 } | 312 } |
314 return 1; | 313 return 1; |
315 } | 314 } |
316 | 315 |
317 } // namespace commands | 316 } // namespace commands |
OLD | NEW |