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

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

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