| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #library('command_list'); | |
| 6 | |
| 7 #import('package.dart'); | |
| 8 #import('pub.dart'); | |
| 9 | |
| 10 /** | |
| 11 * Handles the `list` pub command. This is mostly just used so we can pull | |
| 12 * some basic data out of pub in the integration tests. Once pub is more | |
| 13 * full-featured and has other commands that test everything it does, this | |
| 14 * may go away. | |
| 15 */ | |
| 16 class ListCommand extends PubCommand { | |
| 17 String get description => 'print the contents of repositories'; | |
| 18 String get usage => 'pub list'; | |
| 19 | |
| 20 Future onRun() { | |
| 21 // TODO(nweiz): also list the contents of the packages directory when it's | |
| 22 // able to determine the source of its packages (that is, when we have a | |
| 23 // lockfile). | |
| 24 return cache.listAll().transform((ids) { | |
| 25 _printIds('system cache', ids); | |
| 26 }); | |
| 27 } | |
| 28 | |
| 29 _printIds(String title, List<PackageId> ids) { | |
| 30 ids = new List<PackageId>.from(ids); | |
| 31 ids.sort((a, b) => a.compareTo(b)); | |
| 32 | |
| 33 print('From $title:'); | |
| 34 for (var id in ids) { | |
| 35 print(' $id'); | |
| 36 } | |
| 37 } | |
| 38 } | |
| OLD | NEW |