| 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 '../../pkg/args/lib/args.dart'; | 9 import '../../pkg/args/lib/args.dart'; |
| 10 import '../../pkg/path/lib/path.dart' as path; | 10 import '../../pkg/path/lib/path.dart' as path; |
| 11 import 'dart:io'; | 11 import 'dart:io'; |
| 12 import 'dart:math'; | 12 import 'dart:math'; |
| 13 import 'http.dart'; | 13 import 'http.dart'; |
| 14 import 'io.dart'; | 14 import 'io.dart'; |
| 15 import 'command_help.dart'; | 15 import 'command_help.dart'; |
| 16 import 'command_install.dart'; | 16 import 'command_install.dart'; |
| 17 import 'command_lish.dart'; | 17 import 'command_lish.dart'; |
| 18 import 'command_update.dart'; | 18 import 'command_update.dart'; |
| 19 import 'command_uploader.dart'; | 19 import 'command_uploader.dart'; |
| 20 import 'command_version.dart'; | 20 import 'command_version.dart'; |
| 21 import 'entrypoint.dart'; | 21 import 'entrypoint.dart'; |
| 22 import 'exit_codes.dart' as exit_codes; | 22 import 'exit_codes.dart' as exit_codes; |
| 23 import 'log.dart' as log; | 23 import 'log.dart' as log; |
| 24 import 'package.dart'; | 24 import 'package.dart'; |
| 25 import 'pubspec.dart'; | 25 import 'pubspec.dart'; |
| 26 import 'sdk.dart' as sdk; |
| 26 import 'source.dart'; | 27 import 'source.dart'; |
| 27 import 'source_registry.dart'; | 28 import 'source_registry.dart'; |
| 28 import 'system_cache.dart'; | 29 import 'system_cache.dart'; |
| 29 import 'utils.dart'; | 30 import 'utils.dart'; |
| 30 import 'version.dart'; | 31 import 'version.dart'; |
| 31 | 32 |
| 32 Version get pubVersion => new Version(0, 0, 0); | |
| 33 | |
| 34 /// The commands that Pub understands. | 33 /// The commands that Pub understands. |
| 35 Map<String, PubCommand> get pubCommands { | 34 Map<String, PubCommand> get pubCommands { |
| 36 var commands = { | 35 var commands = { |
| 37 'help': new HelpCommand(), | 36 'help': new HelpCommand(), |
| 38 'install': new InstallCommand(), | 37 'install': new InstallCommand(), |
| 39 'publish': new LishCommand(), | 38 'publish': new LishCommand(), |
| 40 'update': new UpdateCommand(), | 39 'update': new UpdateCommand(), |
| 41 'uploader': new UploaderCommand(), | 40 'uploader': new UploaderCommand(), |
| 42 'version': new VersionCommand() | 41 'version': new VersionCommand() |
| 43 }; | 42 }; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 buffer.add(' ${padRight(name, length)} ' | 164 buffer.add(' ${padRight(name, length)} ' |
| 166 '${pubCommands[name].description}\n'); | 165 '${pubCommands[name].description}\n'); |
| 167 } | 166 } |
| 168 | 167 |
| 169 buffer.add('\n'); | 168 buffer.add('\n'); |
| 170 buffer.add('Use "pub help [command]" for more information about a command.'); | 169 buffer.add('Use "pub help [command]" for more information about a command.'); |
| 171 log.message(buffer.toString()); | 170 log.message(buffer.toString()); |
| 172 } | 171 } |
| 173 | 172 |
| 174 void printVersion() { | 173 void printVersion() { |
| 175 log.message('Pub $pubVersion'); | 174 log.message('Pub ${sdk.version}'); |
| 176 } | 175 } |
| 177 | 176 |
| 178 abstract class PubCommand { | 177 abstract class PubCommand { |
| 179 SystemCache cache; | 178 SystemCache cache; |
| 180 ArgResults globalOptions; | 179 ArgResults globalOptions; |
| 181 ArgResults commandOptions; | 180 ArgResults commandOptions; |
| 182 | 181 |
| 183 Entrypoint entrypoint; | 182 Entrypoint entrypoint; |
| 184 | 183 |
| 185 /// A one-line description of this command. | 184 /// A one-line description of this command. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (exception is HttpException || exception is HttpParserException || | 301 if (exception is HttpException || exception is HttpParserException || |
| 303 exception is SocketIOException || exception is PubHttpException) { | 302 exception is SocketIOException || exception is PubHttpException) { |
| 304 return exit_codes.UNAVAILABLE; | 303 return exit_codes.UNAVAILABLE; |
| 305 } else if (exception is FormatException) { | 304 } else if (exception is FormatException) { |
| 306 return exit_codes.DATA; | 305 return exit_codes.DATA; |
| 307 } else { | 306 } else { |
| 308 return 1; | 307 return 1; |
| 309 } | 308 } |
| 310 } | 309 } |
| 311 } | 310 } |
| OLD | NEW |