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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 for (const auto& builtin : variables::GetBuiltinVariables()) | 49 for (const auto& builtin : variables::GetBuiltinVariables()) |
50 PrintShortHelp(builtin.second.help_short); | 50 PrintShortHelp(builtin.second.help_short); |
51 | 51 |
52 // Target variables. | 52 // Target variables. |
53 OutputString("\nVariables you set in targets (type \"gn help <variable>\" " | 53 OutputString("\nVariables you set in targets (type \"gn help <variable>\" " |
54 "for more details):\n"); | 54 "for more details):\n"); |
55 for (const auto& target : variables::GetTargetVariables()) | 55 for (const auto& target : variables::GetTargetVariables()) |
56 PrintShortHelp(target.second.help_short); | 56 PrintShortHelp(target.second.help_short); |
57 | 57 |
58 OutputString("\nOther help topics:\n"); | 58 OutputString("\nOther help topics:\n"); |
59 PrintShortHelp("all: Print all the help at once"); | |
59 PrintShortHelp("buildargs: How build arguments work."); | 60 PrintShortHelp("buildargs: How build arguments work."); |
60 PrintShortHelp("dotfile: Info about the toplevel .gn file."); | 61 PrintShortHelp("dotfile: Info about the toplevel .gn file."); |
61 PrintShortHelp("label_pattern: Matching more than one label."); | 62 PrintShortHelp("label_pattern: Matching more than one label."); |
62 PrintShortHelp( | 63 PrintShortHelp( |
63 "input_conversion: Processing input from exec_script and read_file."); | 64 "input_conversion: Processing input from exec_script and read_file."); |
64 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); | 65 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); |
65 PrintShortHelp("switches: Show available command-line switches."); | 66 PrintShortHelp("switches: Show available command-line switches."); |
66 } | 67 } |
67 | 68 |
68 void PrintSwitchHelp() { | 69 void PrintSwitchHelp() { |
69 OutputString("Available global switches\n", DECORATION_YELLOW); | 70 OutputString("Available global switches\n", DECORATION_YELLOW); |
70 OutputString( | 71 OutputString( |
71 " Do \"gn help --the_switch_you_want_help_on\" for more. Individual\n" | 72 " Do \"gn help --the_switch_you_want_help_on\" for more. Individual\n" |
72 " commands may take command-specific switches not listed here. See the\n" | 73 " commands may take command-specific switches not listed here. See the\n" |
73 " help on your specific command for more.\n\n"); | 74 " help on your specific command for more.\n\n"); |
74 | 75 |
75 for (const auto& s : switches::GetSwitches()) | 76 for (const auto& s : switches::GetSwitches()) |
76 PrintShortHelp(s.second.short_help); | 77 PrintShortHelp(s.second.short_help); |
77 } | 78 } |
78 | 79 |
80 void PrintAllHelp() { | |
81 PrintToplevelHelp(); | |
82 | |
83 for (const auto& s : switches::GetSwitches()) { | |
brettw
2015/04/16 23:35:13
No {} for these loops
Dirk Pranke
2015/04/16 23:36:50
ah, right.
| |
84 PrintLongHelp(s.second.long_help); | |
85 } | |
86 | |
87 for (const auto& c: commands::GetCommands()) { | |
brettw
2015/04/16 23:35:13
Space before the colon for these loops.
Dirk Pranke
2015/04/16 23:36:50
Acknowledged.
| |
88 PrintLongHelp(c.second.help); | |
89 } | |
90 | |
91 for (const auto& f: functions::GetFunctions()) { | |
92 PrintLongHelp(f.second.help); | |
93 } | |
94 | |
95 for (const auto& v: variables::GetBuiltinVariables()) { | |
96 PrintLongHelp(v.second.help); | |
97 } | |
98 | |
99 for (const auto& v: variables::GetTargetVariables()) { | |
100 PrintLongHelp(v.second.help); | |
101 } | |
102 | |
103 PrintLongHelp(kBuildArgs_Help); | |
104 PrintLongHelp(kDotfile_Help); | |
105 PrintLongHelp(kInputConversion_Help); | |
106 PrintLongHelp(kLabelPattern_Help); | |
107 PrintLongHelp(kSourceExpansion_Help); | |
108 PrintSwitchHelp(); | |
109 } | |
110 | |
111 | |
brettw
2015/04/16 23:35:13
Got some extra blank lines in here (should just be
Dirk Pranke
2015/04/16 23:36:50
Acknowledged.
| |
112 | |
79 // Prints help on the given switch. There should be no leading hyphens. Returns | 113 // Prints help on the given switch. There should be no leading hyphens. Returns |
80 // true if the switch was found and help was printed. False means the switch is | 114 // true if the switch was found and help was printed. False means the switch is |
81 // unknown. | 115 // unknown. |
82 bool PrintHelpOnSwitch(const std::string& what) { | 116 bool PrintHelpOnSwitch(const std::string& what) { |
83 const switches::SwitchInfoMap& all = switches::GetSwitches(); | 117 const switches::SwitchInfoMap& all = switches::GetSwitches(); |
84 switches::SwitchInfoMap::const_iterator found = | 118 switches::SwitchInfoMap::const_iterator found = |
85 all.find(base::StringPiece(what)); | 119 all.find(base::StringPiece(what)); |
86 if (found == all.end()) | 120 if (found == all.end()) |
87 return false; | 121 return false; |
88 PrintLongHelp(found->second.long_help); | 122 PrintLongHelp(found->second.long_help); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 const variables::VariableInfoMap& target_vars = | 188 const variables::VariableInfoMap& target_vars = |
155 variables::GetTargetVariables(); | 189 variables::GetTargetVariables(); |
156 variables::VariableInfoMap::const_iterator found_target_var = | 190 variables::VariableInfoMap::const_iterator found_target_var = |
157 target_vars.find(what); | 191 target_vars.find(what); |
158 if (found_target_var != target_vars.end()) { | 192 if (found_target_var != target_vars.end()) { |
159 PrintLongHelp(found_target_var->second.help); | 193 PrintLongHelp(found_target_var->second.help); |
160 return 0; | 194 return 0; |
161 } | 195 } |
162 | 196 |
163 // Random other topics. | 197 // Random other topics. |
198 if (what == "all") { | |
199 PrintAllHelp(); | |
200 return 0; | |
201 } | |
164 if (what == "buildargs") { | 202 if (what == "buildargs") { |
165 PrintLongHelp(kBuildArgs_Help); | 203 PrintLongHelp(kBuildArgs_Help); |
166 return 0; | 204 return 0; |
167 } | 205 } |
168 if (what == "dotfile") { | 206 if (what == "dotfile") { |
169 PrintLongHelp(kDotfile_Help); | 207 PrintLongHelp(kDotfile_Help); |
170 return 0; | 208 return 0; |
171 } | 209 } |
172 if (what == "input_conversion") { | 210 if (what == "input_conversion") { |
173 PrintLongHelp(kInputConversion_Help); | 211 PrintLongHelp(kInputConversion_Help); |
(...skipping 12 matching lines...) Expand all Loading... | |
186 return 0; | 224 return 0; |
187 } | 225 } |
188 | 226 |
189 // No help on this. | 227 // No help on this. |
190 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); | 228 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); |
191 RunHelp(std::vector<std::string>()); | 229 RunHelp(std::vector<std::string>()); |
192 return 1; | 230 return 1; |
193 } | 231 } |
194 | 232 |
195 } // namespace commands | 233 } // namespace commands |
OLD | NEW |