OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
Bob Nystrom
2013/03/12 22:12:03
2013
keertip
2013/03/13 15:55:00
Done.
| |
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. | |
4 | |
5 library command_cache; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:io'; | |
9 import 'dart:json' as json; | |
Bob Nystrom
2013/03/12 22:12:03
Can you add a blank line between the "dart:" and o
keertip
2013/03/13 15:55:00
Done.
| |
10 import 'exit_codes.dart' as exit_codes; | |
11 import 'log.dart' as log; | |
12 import 'pub.dart'; | |
13 | |
14 | |
15 /// Handles the `cache` pub command. | |
16 class CacheCommand extends PubCommand { | |
17 | |
Bob Nystrom
2013/03/12 22:12:03
Remove this blank line.
keertip
2013/03/13 15:55:00
Done.
| |
18 String get description => "Works on the pub cache."; | |
Bob Nystrom
2013/03/12 22:12:03
"Inspect the system cache."
keertip
2013/03/13 15:55:00
Done.
| |
19 String get usage => 'pub cache {list}'; | |
Bob Nystrom
2013/03/12 22:12:03
'pub cache list'
keertip
2013/03/13 15:55:00
Done.
| |
20 bool get requiresEntrypoint => false; | |
21 | |
22 Future onRun() { | |
23 if (commandOptions.rest.isEmpty) { | |
Bob Nystrom
2013/03/12 22:12:03
.rest.length != 1
keertip
2013/03/13 15:55:00
Done.
| |
24 log.error('No cache command given.'); | |
Bob Nystrom
2013/03/12 22:12:03
'The cache command expects one argument.'
keertip
2013/03/13 15:55:00
Done.
| |
25 this.printUsage(); | |
26 exit(exit_codes.USAGE); | |
27 } | |
28 | |
29 var command = commandOptions.rest.removeAt(0); | |
30 if (!['list'].contains(command)) { | |
Bob Nystrom
2013/03/12 22:12:03
if (commandOptions.rest[0] != 'list')
keertip
2013/03/13 15:55:00
Done.
| |
31 log.error('Unknown cache command "$command".'); | |
32 this.printUsage(); | |
33 exit(exit_codes.USAGE); | |
34 } | |
35 | |
36 return cache.sources.defaultSource.getCachedPackages().then((packages){ | |
nweiz
2013/03/12 22:58:48
Add a TODO here to add a flag to list packages fro
keertip
2013/03/13 15:55:00
Done.
| |
37 var packagesObj = <String, Map>{}; | |
38 for (var p in packages){ | |
Bob Nystrom
2013/03/12 22:12:03
p -> package
keertip
2013/03/13 15:55:00
Done.
| |
39 packagesObj[p.name] = { | |
40 'version': p.version.toString(), | |
41 'location': p.dir | |
42 }; | |
43 } | |
Bob Nystrom
2013/03/12 22:12:03
Add a TODO to support non-JSON format and check fo
keertip
2013/03/13 15:55:00
Done.
| |
44 log.message(' ${json.stringify({'pubcache': packagesObj})}'); | |
Bob Nystrom
2013/03/12 22:12:03
Instead of 'pubcache', how about 'packages'?
Also
keertip
2013/03/13 15:55:00
Done.
| |
45 }); | |
46 } | |
47 } | |
48 | |
OLD | NEW |