Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Unified Diff: utils/pub/pub.dart

Issue 10340005: Add support for pub install. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Chromium review errors? Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: utils/pub/pub.dart
diff --git a/utils/pub/pub.dart b/utils/pub/pub.dart
index eef7ba38e92ab37c359d7c54f6da3de8e0724cb1..377c3e6a4fe652a90661d513e1cb81d51b94b818 100644
--- a/utils/pub/pub.dart
+++ b/utils/pub/pub.dart
@@ -12,11 +12,15 @@
#import('io.dart');
#import('utils.dart');
-#source('cache.dart');
+#source('system_cache.dart');
+#source('app_cache.dart');
#source('command_list.dart');
+#source('command_install.dart');
#source('command_update.dart');
#source('command_version.dart');
#source('package.dart');
+#source('source.dart');
+#source('sdk_source.dart');
main() {
final args = new Options().arguments;
@@ -26,6 +30,7 @@ main() {
// be consistent with other Unix apps.
final commands = {
'list': new ListCommand(),
+ 'install': new InstallCommand(),
'update': new UpdateCommand(),
'version': new VersionCommand()
};
@@ -52,17 +57,23 @@ main() {
// TODO(rnystrom): Hack. This is temporary code to allow the pub tests to
// pass in relevant paths. Eventually these should be either environment
// variables or at least a cleaner arg parser.
- var cacheDir;
+ var cacheDir, sdkDir;
for (var i = 0; i < args.length; i++) {
if (args[i].startsWith('--cachedir=')) {
cacheDir = args[i].substring('--cachedir='.length);
args.removeRange(i, 1);
- break;
+ i--;
+ } else if (args[i].startsWith('--sdkdir=')) {
+ sdkDir = args[i].substring('--sdkdir='.length);
+ args.removeRange(i, 1);
+ i--;
}
}
// TODO(rnystrom): Do we want this to be global?
- final cache = new PackageCache(cacheDir);
+ final systemCache = new SystemCache(cacheDir);
+
+ Source.defaultSource = new SdkSource(sdkDir);
// Select the command.
final command = commands[args[0]];
@@ -74,7 +85,7 @@ main() {
}
args.removeRange(0, 1);
- command.run(cache, args);
+ command.run(systemCache, args);
}
/** Displays usage information for the app. */
@@ -123,12 +134,14 @@ Future<Package> getWorkingPackage() {
}
class PubCommand {
- PackageCache cache;
+ SystemCache systemCache;
+ AppCache appCache;
abstract String get description();
- void run(PackageCache cache_, List<String> args) {
- cache = cache_;
+ void run(SystemCache systemCache_, List<String> args) {
+ systemCache = systemCache_;
+ appCache = new AppCache(workingDir, systemCache);
// TODO(rnystrom): Each command should define the arguments it expects and
// we can handle them generically here.

Powered by Google App Engine
This is Rietveld 408576698