Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: tools/gn/command_help.cc

Issue 1021923002: Add a "gn help all" option to GN to print all of the help at once. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn_help
Patch Set: review feedback - remove braces and blank lines Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 for (const auto& builtin : variables::GetBuiltinVariables()) 50 for (const auto& builtin : variables::GetBuiltinVariables())
51 PrintShortHelp(builtin.second.help_short); 51 PrintShortHelp(builtin.second.help_short);
52 52
53 // Target variables. 53 // Target variables.
54 OutputString("\nVariables you set in targets (type \"gn help <variable>\" " 54 OutputString("\nVariables you set in targets (type \"gn help <variable>\" "
55 "for more details):\n"); 55 "for more details):\n");
56 for (const auto& target : variables::GetTargetVariables()) 56 for (const auto& target : variables::GetTargetVariables())
57 PrintShortHelp(target.second.help_short); 57 PrintShortHelp(target.second.help_short);
58 58
59 OutputString("\nOther help topics:\n"); 59 OutputString("\nOther help topics:\n");
60 PrintShortHelp("all: Print all the help at once");
60 PrintShortHelp("buildargs: How build arguments work."); 61 PrintShortHelp("buildargs: How build arguments work.");
61 PrintShortHelp("dotfile: Info about the toplevel .gn file."); 62 PrintShortHelp("dotfile: Info about the toplevel .gn file.");
62 PrintShortHelp("grammar: Formal grammar for GN build files."); 63 PrintShortHelp("grammar: Formal grammar for GN build files.");
63 PrintShortHelp("label_pattern: Matching more than one label."); 64 PrintShortHelp("label_pattern: Matching more than one label.");
64 PrintShortHelp( 65 PrintShortHelp(
65 "input_conversion: Processing input from exec_script and read_file."); 66 "input_conversion: Processing input from exec_script and read_file.");
66 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); 67 PrintShortHelp("source_expansion: Map sources to outputs for scripts.");
67 PrintShortHelp("switches: Show available command-line switches."); 68 PrintShortHelp("switches: Show available command-line switches.");
68 } 69 }
69 70
70 void PrintSwitchHelp() { 71 void PrintSwitchHelp() {
71 OutputString("Available global switches\n", DECORATION_YELLOW); 72 OutputString("Available global switches\n", DECORATION_YELLOW);
72 OutputString( 73 OutputString(
73 " Do \"gn help --the_switch_you_want_help_on\" for more. Individual\n" 74 " Do \"gn help --the_switch_you_want_help_on\" for more. Individual\n"
74 " commands may take command-specific switches not listed here. See the\n" 75 " commands may take command-specific switches not listed here. See the\n"
75 " help on your specific command for more.\n\n"); 76 " help on your specific command for more.\n\n");
76 77
77 for (const auto& s : switches::GetSwitches()) 78 for (const auto& s : switches::GetSwitches())
78 PrintShortHelp(s.second.short_help); 79 PrintShortHelp(s.second.short_help);
79 } 80 }
80 81
82 void PrintAllHelp() {
83 PrintToplevelHelp();
84
85 for (const auto& s : switches::GetSwitches())
86 PrintLongHelp(s.second.long_help);
87
88 for (const auto& c: commands::GetCommands())
89 PrintLongHelp(c.second.help);
90
91 for (const auto& f: functions::GetFunctions())
92 PrintLongHelp(f.second.help);
93
94 for (const auto& v: variables::GetBuiltinVariables())
95 PrintLongHelp(v.second.help);
96
97 for (const auto& v: variables::GetTargetVariables())
98 PrintLongHelp(v.second.help);
99
100 PrintLongHelp(kBuildArgs_Help);
101 PrintLongHelp(kDotfile_Help);
102 PrintLongHelp(kInputConversion_Help);
103 PrintLongHelp(kLabelPattern_Help);
104 PrintLongHelp(kSourceExpansion_Help);
105 PrintSwitchHelp();
106 }
107
81 // Prints help on the given switch. There should be no leading hyphens. Returns 108 // Prints help on the given switch. There should be no leading hyphens. Returns
82 // true if the switch was found and help was printed. False means the switch is 109 // true if the switch was found and help was printed. False means the switch is
83 // unknown. 110 // unknown.
84 bool PrintHelpOnSwitch(const std::string& what) { 111 bool PrintHelpOnSwitch(const std::string& what) {
85 const switches::SwitchInfoMap& all = switches::GetSwitches(); 112 const switches::SwitchInfoMap& all = switches::GetSwitches();
86 switches::SwitchInfoMap::const_iterator found = 113 switches::SwitchInfoMap::const_iterator found =
87 all.find(base::StringPiece(what)); 114 all.find(base::StringPiece(what));
88 if (found == all.end()) 115 if (found == all.end())
89 return false; 116 return false;
90 PrintLongHelp(found->second.long_help); 117 PrintLongHelp(found->second.long_help);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const variables::VariableInfoMap& target_vars = 183 const variables::VariableInfoMap& target_vars =
157 variables::GetTargetVariables(); 184 variables::GetTargetVariables();
158 variables::VariableInfoMap::const_iterator found_target_var = 185 variables::VariableInfoMap::const_iterator found_target_var =
159 target_vars.find(what); 186 target_vars.find(what);
160 if (found_target_var != target_vars.end()) { 187 if (found_target_var != target_vars.end()) {
161 PrintLongHelp(found_target_var->second.help); 188 PrintLongHelp(found_target_var->second.help);
162 return 0; 189 return 0;
163 } 190 }
164 191
165 // Random other topics. 192 // Random other topics.
193 if (what == "all") {
194 PrintAllHelp();
195 return 0;
196 }
166 if (what == "buildargs") { 197 if (what == "buildargs") {
167 PrintLongHelp(kBuildArgs_Help); 198 PrintLongHelp(kBuildArgs_Help);
168 return 0; 199 return 0;
169 } 200 }
170 if (what == "dotfile") { 201 if (what == "dotfile") {
171 PrintLongHelp(kDotfile_Help); 202 PrintLongHelp(kDotfile_Help);
172 return 0; 203 return 0;
173 } 204 }
174 if (what == "grammar") { 205 if (what == "grammar") {
175 PrintLongHelp(kGrammar_Help); 206 PrintLongHelp(kGrammar_Help);
(...skipping 16 matching lines...) Expand all
192 return 0; 223 return 0;
193 } 224 }
194 225
195 // No help on this. 226 // No help on this.
196 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); 227 Err(Location(), "No help on \"" + what + "\".").PrintToStdout();
197 RunHelp(std::vector<std::string>()); 228 RunHelp(std::vector<std::string>());
198 return 1; 229 return 1;
199 } 230 }
200 231
201 } // namespace commands 232 } // namespace commands
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698