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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/command/help.dart

Issue 805393002: Update pub to use the new command runner API in args. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 11 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
(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 pub.command.help;
6
7 import 'dart:async';
8
9 import '../command.dart';
10
11 /// Handles the `help` pub command.
12 class HelpCommand extends PubCommand {
13 String get description => "Display help information for Pub.";
14 String get usage => "pub help [command]";
15 bool get takesArguments => true;
16
17 Future onRun() {
18 // Show the default help if no command was specified.
19 if (commandOptions.rest.isEmpty) {
20 PubCommand.printGlobalUsage();
21 return null;
22 }
23
24 // Walk the command tree to show help for the selected command or
25 // subcommand.
26 var commands = PubCommand.mainCommands;
27 var command = null;
28 var commandString = "pub";
29
30 for (var name in commandOptions.rest) {
31 if (commands.isEmpty) {
32 command.usageError(
33 'Command "$commandString" does not expect a subcommand.');
34 }
35
36 if (commands[name] == null) {
37 if (command == null) {
38 PubCommand.usageErrorWithCommands(commands,
39 'Could not find a command named "$name".');
40 }
41
42 command.usageError(
43 'Could not find a subcommand named "$name" for "$commandString".');
44 }
45
46 command = commands[name];
47 commands = command.subcommands;
48 commandString += " $name";
49 }
50
51 command.printUsage();
52 return null;
53 }
54 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command/global_run.dart ('k') | sdk/lib/_internal/pub/lib/src/command/lish.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698