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