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/lib/args.dart'; | 10 import '../../pkg/args/lib/args.dart'; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } on FormatException catch (e) { | 61 } on FormatException catch (e) { |
62 printUsage(description: e.message); | 62 printUsage(description: e.message); |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 if (globalOptions['version']) { | 66 if (globalOptions['version']) { |
67 printVersion(); | 67 printVersion(); |
68 return; | 68 return; |
69 } | 69 } |
70 | 70 |
71 if (globalOptions['help'] || globalOptions.rest.isEmpty()) { | 71 if (globalOptions['help'] || globalOptions.rest.isEmpty) { |
72 printUsage(); | 72 printUsage(); |
73 return; | 73 return; |
74 } | 74 } |
75 | 75 |
76 // TODO(nweiz): Have a fallback for this this out automatically once 1145 is | 76 // TODO(nweiz): Have a fallback for this this out automatically once 1145 is |
77 // fixed. | 77 // fixed. |
78 var sdkDir = Platform.environment['DART_SDK']; | 78 var sdkDir = Platform.environment['DART_SDK']; |
79 var cacheDir; | 79 var cacheDir; |
80 if (Platform.environment.containsKey('PUB_CACHE')) { | 80 if (Platform.environment.containsKey('PUB_CACHE')) { |
81 cacheDir = Platform.environment['PUB_CACHE']; | 81 cacheDir = Platform.environment['PUB_CACHE']; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 abstract Future onRun(); | 248 abstract Future onRun(); |
249 | 249 |
250 /** Displays usage information for this command. */ | 250 /** Displays usage information for this command. */ |
251 void printUsage([String description]) { | 251 void printUsage([String description]) { |
252 if (description == null) description = this.description; | 252 if (description == null) description = this.description; |
253 print(description); | 253 print(description); |
254 print(''); | 254 print(''); |
255 print('Usage: $usage'); | 255 print('Usage: $usage'); |
256 | 256 |
257 var commandUsage = commandParser.getUsage(); | 257 var commandUsage = commandParser.getUsage(); |
258 if (!commandUsage.isEmpty()) { | 258 if (!commandUsage.isEmpty) { |
259 print(''); | 259 print(''); |
260 print(commandUsage); | 260 print(commandUsage); |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 /// Returns the appropriate exit code for [exception], falling back on 1 if no | 264 /// Returns the appropriate exit code for [exception], falling back on 1 if no |
265 /// appropriate exit code could be found. | 265 /// appropriate exit code could be found. |
266 int _chooseExitCode(exception) { | 266 int _chooseExitCode(exception) { |
267 if (exception is HttpException || exception is HttpParserException || | 267 if (exception is HttpException || exception is HttpParserException || |
268 exception is SocketIOException || exception is PubHttpException) { | 268 exception is SocketIOException || exception is PubHttpException) { |
269 return exit_codes.UNAVAILABLE; | 269 return exit_codes.UNAVAILABLE; |
270 } else if (exception is FormatException) { | 270 } else if (exception is FormatException) { |
271 return exit_codes.DATA; | 271 return exit_codes.DATA; |
272 } else { | 272 } else { |
273 return 1; | 273 return 1; |
274 } | 274 } |
275 } | 275 } |
276 } | 276 } |
OLD | NEW |