| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 "gn help <anything>\n" | 98 "gn help <anything>\n" |
| 99 " Yo dawg, I heard you like help on your help so I put help on the help\n" | 99 " Yo dawg, I heard you like help on your help so I put help on the help\n" |
| 100 " in the help.\n"; | 100 " in the help.\n"; |
| 101 | 101 |
| 102 int RunHelp(const std::vector<std::string>& args) { | 102 int RunHelp(const std::vector<std::string>& args) { |
| 103 std::string what; | 103 std::string what; |
| 104 if (args.size() == 0) { | 104 if (args.size() == 0) { |
| 105 // If no argument is specified, check for switches to allow things like | 105 // If no argument is specified, check for switches to allow things like |
| 106 // "gn help --args" for help on the args switch. | 106 // "gn help --args" for help on the args switch. |
| 107 const base::CommandLine::SwitchMap& switches = | 107 const base::CommandLine::SwitchMap& switches = |
| 108 CommandLine::ForCurrentProcess()->GetSwitches(); | 108 base::CommandLine::ForCurrentProcess()->GetSwitches(); |
| 109 if (switches.empty()) { | 109 if (switches.empty()) { |
| 110 // Still nothing, show help overview. | 110 // Still nothing, show help overview. |
| 111 PrintToplevelHelp(); | 111 PrintToplevelHelp(); |
| 112 return 0; | 112 return 0; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Switch help needs to be done separately. The CommandLine will strip the | 115 // Switch help needs to be done separately. The CommandLine will strip the |
| 116 // switch separators so --args will come out as "args" which is then | 116 // switch separators so --args will come out as "args" which is then |
| 117 // ambiguous with the variable named "args". | 117 // ambiguous with the variable named "args". |
| 118 if (!PrintHelpOnSwitch(switches.begin()->first)) | 118 if (!PrintHelpOnSwitch(switches.begin()->first)) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 return 0; | 186 return 0; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // No help on this. | 189 // No help on this. |
| 190 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); | 190 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); |
| 191 RunHelp(std::vector<std::string>()); | 191 RunHelp(std::vector<std::string>()); |
| 192 return 1; | 192 return 1; |
| 193 } | 193 } |
| 194 | 194 |
| 195 } // namespace commands | 195 } // namespace commands |
| OLD | NEW |