| 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('io.dart'); | 10 #import('io.dart'); |
| 11 #import('command_install.dart'); | 11 #import('command_install.dart'); |
| 12 #import('command_list.dart'); | 12 #import('command_list.dart'); |
| 13 #import('command_update.dart'); | 13 #import('command_update.dart'); |
| 14 #import('command_version.dart'); | 14 #import('command_version.dart'); |
| 15 #import('entrypoint.dart'); | 15 #import('entrypoint.dart'); |
| 16 #import('git_source.dart'); | 16 #import('git_source.dart'); |
| 17 #import('package.dart'); | 17 #import('package.dart'); |
| 18 #import('pubspec.dart'); | 18 #import('pubspec.dart'); |
| 19 #import('repo_source.dart'); |
| 19 #import('sdk_source.dart'); | 20 #import('sdk_source.dart'); |
| 20 #import('source.dart'); | 21 #import('source.dart'); |
| 21 #import('source_registry.dart'); | 22 #import('source_registry.dart'); |
| 22 #import('system_cache.dart'); | 23 #import('system_cache.dart'); |
| 23 #import('utils.dart'); | 24 #import('utils.dart'); |
| 24 #import('version.dart'); | 25 #import('version.dart'); |
| 25 | 26 |
| 26 Version get pubVersion() => new Version(0, 0, 0); | 27 Version get pubVersion() => new Version(0, 0, 0); |
| 27 | 28 |
| 28 main() { | 29 main() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 70 |
| 70 if (args[0] == '--version') { | 71 if (args[0] == '--version') { |
| 71 printVersion(); | 72 printVersion(); |
| 72 return; | 73 return; |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 var cache = new SystemCache(cacheDir); | 77 var cache = new SystemCache(cacheDir); |
| 77 cache.sources.register(new SdkSource(sdkDir)); | 78 cache.sources.register(new SdkSource(sdkDir)); |
| 78 cache.sources.register(new GitSource()); | 79 cache.sources.register(new GitSource()); |
| 80 cache.sources.register(new RepoSource()); |
| 81 // TODO(nweiz): Make 'repo' the default once pub.dartlang.org exists |
| 79 cache.sources.setDefault('sdk'); | 82 cache.sources.setDefault('sdk'); |
| 80 | 83 |
| 81 // Select the command. | 84 // Select the command. |
| 82 var command = commands[args[0]]; | 85 var command = commands[args[0]]; |
| 83 if (command == null) { | 86 if (command == null) { |
| 84 printError('Unknown command "${args[0]}".'); | 87 printError('Unknown command "${args[0]}".'); |
| 85 printError('Run "pub help" to see available commands.'); | 88 printError('Run "pub help" to see available commands.'); |
| 86 exit(64); // See http://www.freebsd.org/cgi/man.cgi?query=sysexits. | 89 exit(64); // See http://www.freebsd.org/cgi/man.cgi?query=sysexits. |
| 87 return; | 90 return; |
| 88 } | 91 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 Package.load(workingDir, cache.sources).chain((package) { | 164 Package.load(workingDir, cache.sources).chain((package) { |
| 162 entrypoint = new Entrypoint(package, cache); | 165 entrypoint = new Entrypoint(package, cache); |
| 163 | 166 |
| 164 try { | 167 try { |
| 165 var commandFuture = onRun(); | 168 var commandFuture = onRun(); |
| 166 if (commandFuture == null) return new Future.immediate(true); | 169 if (commandFuture == null) return new Future.immediate(true); |
| 167 | 170 |
| 168 return commandFuture; | 171 return commandFuture; |
| 169 } catch (var error) { | 172 } catch (var error) { |
| 170 handleError(error); | 173 handleError(error); |
| 174 return new Future.immediate(null); |
| 171 } | 175 } |
| 172 }).handleException(handleError); | 176 }).handleException(handleError); |
| 173 } | 177 } |
| 174 | 178 |
| 175 /** | 179 /** |
| 176 * Override this to perform the specific command. Return a future that | 180 * Override this to perform the specific command. Return a future that |
| 177 * completes when the command is done or fails if the command fails. If the | 181 * completes when the command is done or fails if the command fails. If the |
| 178 * command is synchronous, it may return `null`. | 182 * command is synchronous, it may return `null`. |
| 179 */ | 183 */ |
| 180 abstract Future onRun(); | 184 abstract Future onRun(); |
| 181 } | 185 } |
| OLD | NEW |