OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * The main entrypoint for the pub command line application. | 6 * The main entrypoint for the pub command line application. |
7 */ | 7 */ |
8 #library('pub'); | 8 #library('pub'); |
9 | 9 |
10 #import('../../pkg/args/args.dart'); | 10 #import('../../pkg/args/args.dart'); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 try { | 170 try { |
171 commandOptions = commandParser.parse(commandArgs); | 171 commandOptions = commandParser.parse(commandArgs); |
172 } on FormatException catch (e) { | 172 } on FormatException catch (e) { |
173 this.printUsage(description: e.message); | 173 this.printUsage(description: e.message); |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 handleError(error, trace) { | 177 handleError(error, trace) { |
178 // This is basically the top-level exception handler so that we don't | 178 // This is basically the top-level exception handler so that we don't |
179 // spew a stack trace on our users. | 179 // spew a stack trace on our users. |
180 // TODO(rnystrom): Add --trace flag so stack traces can be enabled for | |
181 // debugging. | |
182 var message = error.toString(); | 180 var message = error.toString(); |
183 | 181 |
184 // TODO(rnystrom): The default exception implementation class puts | 182 // TODO(rnystrom): The default exception implementation class puts |
185 // "Exception:" in the output, so strip that off. | 183 // "Exception:" in the output, so strip that off. |
186 if (message.startsWith("Exception: ")) { | 184 if (message.startsWith("Exception: ")) { |
187 message = message.substring("Exception: ".length); | 185 message = message.substring("Exception: ".length); |
188 } | 186 } |
189 | 187 |
190 printError(message); | 188 printError(message); |
191 if (globalOptions['trace'] && trace != null) { | 189 if (globalOptions['trace'] && trace != null) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 print(''); | 225 print(''); |
228 print('Usage: $usage'); | 226 print('Usage: $usage'); |
229 | 227 |
230 var commandUsage = commandParser.getUsage(); | 228 var commandUsage = commandParser.getUsage(); |
231 if (!commandUsage.isEmpty()) { | 229 if (!commandUsage.isEmpty()) { |
232 print(''); | 230 print(''); |
233 print(commandUsage); | 231 print(commandUsage); |
234 } | 232 } |
235 } | 233 } |
236 } | 234 } |
OLD | NEW |