| 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 | 105 |
| 89 for (const auto& c: commands::GetCommands()) { | 106 for (const auto& c: commands::GetCommands()) { |
| 90 PrintLongHelp(c.second.help); | 107 PrintLongHelp(c.second.help); |
| 91 } | 108 } |
| 92 | 109 |
| 93 for (const auto& f: functions::GetFunctions()) { | 110 for (const auto& f: functions::GetFunctions()) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return 0; | 247 return 0; |
| 231 } | 248 } |
| 232 | 249 |
| 233 // No help on this. | 250 // No help on this. |
| 234 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); | 251 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); |
| 235 RunHelp(std::vector<std::string>()); | 252 RunHelp(std::vector<std::string>()); |
| 236 return 1; | 253 return 1; |
| 237 } | 254 } |
| 238 | 255 |
| 239 } // namespace commands | 256 } // namespace commands |
| OLD | NEW |