| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 PrintShortHelp("dotfile: Info about the toplevel .gn file."); | 62 PrintShortHelp("dotfile: Info about the toplevel .gn file."); |
| 63 PrintShortHelp("grammar: Formal grammar for GN build files."); | 63 PrintShortHelp("grammar: Formal grammar for GN build files."); |
| 64 PrintShortHelp("label_pattern: Matching more than one label."); | 64 PrintShortHelp("label_pattern: Matching more than one label."); |
| 65 PrintShortHelp( | 65 PrintShortHelp( |
| 66 "input_conversion: Processing input from exec_script and read_file."); | 66 "input_conversion: Processing input from exec_script and read_file."); |
| 67 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); | 67 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); |
| 68 PrintShortHelp("switches: Show available command-line switches."); | 68 PrintShortHelp("switches: Show available command-line switches."); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void PrintSwitchHelp() { | 71 void PrintSwitchHelp() { |
| 72 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 73 bool use_markdown = cmdline->HasSwitch(switches::kMarkdown); |
| 74 |
| 72 OutputString("Available global switches\n", DECORATION_YELLOW); | 75 OutputString("Available global switches\n", DECORATION_YELLOW); |
| 73 OutputString( | 76 OutputString( |
| 74 " Do \"gn help --the_switch_you_want_help_on\" for more. Individual\n" | 77 " Do \"gn help --the_switch_you_want_help_on\" for more. Individual\n" |
| 75 " commands may take command-specific switches not listed here. See the\n" | 78 " commands may take command-specific switches not listed here. See the\n" |
| 76 " help on your specific command for more.\n\n"); | 79 " help on your specific command for more.\n\n"); |
| 77 | 80 |
| 81 if (use_markdown) |
| 82 OutputString("```\n\n", DECORATION_NONE); |
| 83 |
| 78 for (const auto& s : switches::GetSwitches()) | 84 for (const auto& s : switches::GetSwitches()) |
| 79 PrintShortHelp(s.second.short_help); | 85 PrintShortHelp(s.second.short_help); |
| 86 |
| 87 if (use_markdown) |
| 88 OutputString("\n```\n", DECORATION_NONE); |
| 80 } | 89 } |
| 81 | 90 |
| 82 void PrintAllHelp() { | 91 void PrintAllHelp() { |
| 83 PrintToplevelHelp(); | 92 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 93 if (cmdline->HasSwitch(switches::kMarkdown)) { |
| 94 OutputString("# GN Reference\n\n"); |
| 95 OutputString("[TOC]\n\n"); |
| 96 OutputString("*This page is automatically generated from* " |
| 97 "`gn help --markdown all`.\n\n"); |
| 98 } else { |
| 99 PrintToplevelHelp(); |
| 100 } |
| 84 | 101 |
| 85 for (const auto& s : switches::GetSwitches()) | 102 for (const auto& s : switches::GetSwitches()) |
| 86 PrintLongHelp(s.second.long_help); | 103 PrintLongHelp(s.second.long_help); |
| 87 | 104 |
| 88 for (const auto& c: commands::GetCommands()) | 105 for (const auto& c: commands::GetCommands()) |
| 89 PrintLongHelp(c.second.help); | 106 PrintLongHelp(c.second.help); |
| 90 | 107 |
| 91 for (const auto& f: functions::GetFunctions()) | 108 for (const auto& f: functions::GetFunctions()) |
| 92 PrintLongHelp(f.second.help); | 109 PrintLongHelp(f.second.help); |
| 93 | 110 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return 0; | 240 return 0; |
| 224 } | 241 } |
| 225 | 242 |
| 226 // No help on this. | 243 // No help on this. |
| 227 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); | 244 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); |
| 228 RunHelp(std::vector<std::string>()); | 245 RunHelp(std::vector<std::string>()); |
| 229 return 1; | 246 return 1; |
| 230 } | 247 } |
| 231 | 248 |
| 232 } // namespace commands | 249 } // namespace commands |
| OLD | NEW |