Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: utils/pub/command_list.dart

Issue 10805017: Add a "help" command to Pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test failures Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
19 String get usage() => 'pub list';
20
19 Future onRun() { 21 Future onRun() {
20 // TODO(nweiz): also list the contents of the packages directory when it's 22 // TODO(nweiz): also list the contents of the packages directory when it's
21 // able to determine the source of its packages (that is, when we have a 23 // able to determine the source of its packages (that is, when we have a
22 // lockfile). 24 // lockfile).
23 return cache.listAll().transform((ids) { 25 return cache.listAll().transform((ids) {
24 _printIds('system cache', ids); 26 _printIds('system cache', ids);
25 }); 27 });
26 } 28 }
27 29
28 _printIds(String title, List<PackageId> ids) { 30 _printIds(String title, List<PackageId> ids) {
29 ids = new List<PackageId>.from(ids); 31 ids = new List<PackageId>.from(ids);
30 ids.sort((a, b) => a.compareTo(b)); 32 ids.sort((a, b) => a.compareTo(b));
31 33
32 print('From $title:'); 34 print('From $title:');
33 for (var id in ids) { 35 for (var id in ids) {
34 print(' $id'); 36 print(' $id');
35 } 37 }
36 } 38 }
37 } 39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698