| 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 16 matching lines...) Expand all Loading... |
| 27 import 'source_registry.dart'; | 27 import 'source_registry.dart'; |
| 28 import 'system_cache.dart'; | 28 import 'system_cache.dart'; |
| 29 import 'utils.dart'; | 29 import 'utils.dart'; |
| 30 import 'version.dart'; | 30 import 'version.dart'; |
| 31 | 31 |
| 32 Version get pubVersion => new Version(0, 0, 0); | 32 Version get pubVersion => new Version(0, 0, 0); |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * The commands that Pub understands. | 35 * The commands that Pub understands. |
| 36 */ | 36 */ |
| 37 Map<String, PubCommand> get pubCommands => { | 37 Map<String, PubCommand> get pubCommands { |
| 38 'help': new HelpCommand(), | 38 var commands = { |
| 39 'install': new InstallCommand(), | 39 'help': new HelpCommand(), |
| 40 'lish': new LishCommand(), | 40 'install': new InstallCommand(), |
| 41 'update': new UpdateCommand(), | 41 'publish': new LishCommand(), |
| 42 'version': new VersionCommand() | 42 'update': new UpdateCommand(), |
| 43 }; | 43 'version': new VersionCommand() |
| 44 }; |
| 45 for (var command in commands.values) { |
| 46 for (var alias in command.aliases) { |
| 47 commands[alias] = command; |
| 48 } |
| 49 } |
| 50 return commands; |
| 51 } |
| 44 | 52 |
| 45 /** | 53 /** |
| 46 * The parser for arguments that are global to Pub rather than specific to a | 54 * The parser for arguments that are global to Pub rather than specific to a |
| 47 * single command. | 55 * single command. |
| 48 */ | 56 */ |
| 49 ArgParser get pubArgParser { | 57 ArgParser get pubArgParser { |
| 50 var parser = new ArgParser(); | 58 var parser = new ArgParser(); |
| 51 parser.addFlag('help', abbr: 'h', negatable: false, | 59 parser.addFlag('help', abbr: 'h', negatable: false, |
| 52 help: 'Prints this usage information'); | 60 help: 'Prints this usage information'); |
| 53 parser.addFlag('version', negatable: false, | 61 parser.addFlag('version', negatable: false, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 String get description; | 165 String get description; |
| 158 | 166 |
| 159 /** | 167 /** |
| 160 * How to invoke this command (e.g. `"pub install [package]"`). | 168 * How to invoke this command (e.g. `"pub install [package]"`). |
| 161 */ | 169 */ |
| 162 String get usage; | 170 String get usage; |
| 163 | 171 |
| 164 /// Whether or not this command requires [entrypoint] to be defined. If false, | 172 /// Whether or not this command requires [entrypoint] to be defined. If false, |
| 165 /// Pub won't look for a pubspec and [entrypoint] will be null when the | 173 /// Pub won't look for a pubspec and [entrypoint] will be null when the |
| 166 /// command runs. | 174 /// command runs. |
| 167 bool get requiresEntrypoint => true; | 175 final requiresEntrypoint = true; |
| 176 |
| 177 /// Alternate names for this command. These names won't be used in the |
| 178 /// documentation, but they will work when invoked on the command line. |
| 179 final aliases = const <String>[]; |
| 168 | 180 |
| 169 /** | 181 /** |
| 170 * Override this to define command-specific options. The results will be made | 182 * Override this to define command-specific options. The results will be made |
| 171 * available in [commandOptions]. | 183 * available in [commandOptions]. |
| 172 */ | 184 */ |
| 173 ArgParser get commandParser => new ArgParser(); | 185 ArgParser get commandParser => new ArgParser(); |
| 174 | 186 |
| 175 void run(SystemCache cache_, ArgResults globalOptions_, | 187 void run(SystemCache cache_, ArgResults globalOptions_, |
| 176 List<String> commandArgs) { | 188 List<String> commandArgs) { |
| 177 cache = cache_; | 189 cache = cache_; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (exception is HttpException || exception is HttpParserException || | 284 if (exception is HttpException || exception is HttpParserException || |
| 273 exception is SocketIOException || exception is PubHttpException) { | 285 exception is SocketIOException || exception is PubHttpException) { |
| 274 return exit_codes.UNAVAILABLE; | 286 return exit_codes.UNAVAILABLE; |
| 275 } else if (exception is FormatException) { | 287 } else if (exception is FormatException) { |
| 276 return exit_codes.DATA; | 288 return exit_codes.DATA; |
| 277 } else { | 289 } else { |
| 278 return 1; | 290 return 1; |
| 279 } | 291 } |
| 280 } | 292 } |
| 281 } | 293 } |
| OLD | NEW |