| 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'); |   5 #library('command_list'); | 
|   6  |   6  | 
|   7 #import('package.dart'); |   7 #import('package.dart'); | 
|   8 #import('pub.dart'); |   8 #import('pub.dart'); | 
|   9  |   9  | 
|  10 /** |  10 /** | 
|  11  * 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 | 
|  12  * 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 | 
|  13  * 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 | 
|  14  * may go away. |  14  * may go away. | 
|  15  */ |  15  */ | 
|  16 class ListCommand extends PubCommand { |  16 class ListCommand extends PubCommand { | 
|  17   String get description() => 'print the contents of repositories'; |  17   String get description => 'print the contents of repositories'; | 
|  18  |  18   String get usage => 'pub list'; | 
|  19   String get usage() => 'pub list'; |  | 
|  20  |  19  | 
|  21   Future onRun() { |  20   Future onRun() { | 
|  22     // TODO(nweiz): also list the contents of the packages directory when it's |  21     // TODO(nweiz): also list the contents of the packages directory when it's | 
|  23     // able to determine the source of its packages (that is, when we have a |  22     // able to determine the source of its packages (that is, when we have a | 
|  24     // lockfile). |  23     // lockfile). | 
|  25     return cache.listAll().transform((ids) { |  24     return cache.listAll().transform((ids) { | 
|  26       _printIds('system cache', ids); |  25       _printIds('system cache', ids); | 
|  27     }); |  26     }); | 
|  28   } |  27   } | 
|  29  |  28  | 
|  30   _printIds(String title, List<PackageId> ids) { |  29   _printIds(String title, List<PackageId> ids) { | 
|  31     ids = new List<PackageId>.from(ids); |  30     ids = new List<PackageId>.from(ids); | 
|  32     ids.sort((a, b) => a.compareTo(b)); |  31     ids.sort((a, b) => a.compareTo(b)); | 
|  33  |  32  | 
|  34     print('From $title:'); |  33     print('From $title:'); | 
|  35     for (var id in ids) { |  34     for (var id in ids) { | 
|  36       print('  $id'); |  35       print('  $id'); | 
|  37     } |  36     } | 
|  38   } |  37   } | 
|  39 } |  38 } | 
| OLD | NEW |