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