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 /// The main entrypoint for the pub command line application. | 5 /// The main entrypoint for the pub command line application. |
6 library pub; | 6 library pub; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:math'; | 10 import 'dart:math'; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 /// Override this to define command-specific options. The results will be made | 220 /// Override this to define command-specific options. The results will be made |
221 /// available in [commandOptions]. | 221 /// available in [commandOptions]. |
222 ArgParser get commandParser => new ArgParser(); | 222 ArgParser get commandParser => new ArgParser(); |
223 | 223 |
224 void run(SystemCache cache_, ArgResults globalOptions_, | 224 void run(SystemCache cache_, ArgResults globalOptions_, |
225 List<String> commandArgs) { | 225 List<String> commandArgs) { |
226 cache = cache_; | 226 cache = cache_; |
227 globalOptions = globalOptions_; | 227 globalOptions = globalOptions_; |
228 | 228 |
229 try { | 229 try { |
230 commandOptions = commandParser.parse(commandArgs); | 230 commandOptions = commandParser.parse(commandArgs); |
231 } on FormatException catch (e) { | 231 } on FormatException catch (e) { |
232 log.error(e.message); | 232 log.error(e.message); |
233 log.error('Use "pub help" for more information.'); | 233 log.error('Use "pub help" for more information.'); |
234 exit(exit_codes.USAGE); | 234 exit(exit_codes.USAGE); |
235 } | 235 } |
236 | 236 |
237 handleError(error, trace) { | 237 handleError(error, trace) { |
238 // This is basically the top-level exception handler so that we don't | 238 // This is basically the top-level exception handler so that we don't |
239 // spew a stack trace on our users. | 239 // spew a stack trace on our users. |
240 var message; | 240 var message; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (exception is HttpException || exception is HttpParserException || | 318 if (exception is HttpException || exception is HttpParserException || |
319 exception is SocketIOException || exception is PubHttpException) { | 319 exception is SocketIOException || exception is PubHttpException) { |
320 return exit_codes.UNAVAILABLE; | 320 return exit_codes.UNAVAILABLE; |
321 } else if (exception is FormatException) { | 321 } else if (exception is FormatException) { |
322 return exit_codes.DATA; | 322 return exit_codes.DATA; |
323 } else { | 323 } else { |
324 return 1; | 324 return 1; |
325 } | 325 } |
326 } | 326 } |
327 } | 327 } |
OLD | NEW |