blob: 61b54b9008df3a532b650abe6ba47d146078389a [file] [log] [blame]
library pub.command.cache_list;
import 'dart:async';
import 'dart:convert';
import '../command.dart';
import '../log.dart' as log;
import '../source/cached.dart';
class CacheListCommand extends PubCommand {
String get description => "List packages in the system cache.";
String get usage => "pub cache list";
bool get hidden => true;
Future onRun() {
var packagesObj = <String, Map>{};
var source = cache.sources.defaultSource as CachedSource;
for (var package in source.getCachedPackages()) {
var packageInfo = packagesObj.putIfAbsent(package.name, () => {});
packageInfo[package.version.toString()] = {
'location': package.dir
};
}
log.message(JSON.encode({
'packages': packagesObj
}));
return null;
}
}