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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 // Select the command. | 131 // Select the command. |
132 var command = pubCommands[globalOptions.rest[0]]; | 132 var command = pubCommands[globalOptions.rest[0]]; |
133 if (command == null) { | 133 if (command == null) { |
134 log.error('Could not find a command named "${globalOptions.rest[0]}".'); | 134 log.error('Could not find a command named "${globalOptions.rest[0]}".'); |
135 log.error('Run "pub help" to see available commands.'); | 135 log.error('Run "pub help" to see available commands.'); |
136 exit(exit_codes.USAGE); | 136 exit(exit_codes.USAGE); |
137 return; | 137 return; |
138 } | 138 } |
139 | 139 |
140 var commandArgs = | 140 var commandArgs = globalOptions.rest.sublist(1); |
141 globalOptions.rest.getRange(1, globalOptions.rest.length - 1); | |
142 command.run(cache, globalOptions, commandArgs); | 141 command.run(cache, globalOptions, commandArgs); |
143 }); | 142 }); |
144 } | 143 } |
145 | 144 |
146 /// Checks that pub is running on a supported platform. If it isn't, it prints | 145 /// Checks that pub is running on a supported platform. If it isn't, it prints |
147 /// an error message and exits. Completes when the validation is done. | 146 /// an error message and exits. Completes when the validation is done. |
148 Future validatePlatform() { | 147 Future validatePlatform() { |
149 return defer(() { | 148 return defer(() { |
150 if (Platform.operatingSystem != 'windows') return; | 149 if (Platform.operatingSystem != 'windows') return; |
151 | 150 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (exception is HttpException || exception is HttpParserException || | 320 if (exception is HttpException || exception is HttpParserException || |
322 exception is SocketIOException || exception is PubHttpException) { | 321 exception is SocketIOException || exception is PubHttpException) { |
323 return exit_codes.UNAVAILABLE; | 322 return exit_codes.UNAVAILABLE; |
324 } else if (exception is FormatException) { | 323 } else if (exception is FormatException) { |
325 return exit_codes.DATA; | 324 return exit_codes.DATA; |
326 } else { | 325 } else { |
327 return 1; | 326 return 1; |
328 } | 327 } |
329 } | 328 } |
330 } | 329 } |
OLD | NEW |