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

Side by Side Diff: args/lib/src/help_command.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « args/lib/src/arg_results.dart ('k') | args/lib/src/option.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 args.help_command;
6
7 import '../command_runner.dart';
8
9 /// The built-in help command that's added to every [CommandRunner].
10 ///
11 /// This command displays help information for the various subcommands.
12 class HelpCommand extends Command {
13 final name = "help";
14 String get description =>
15 "Display help information for ${runner.executableName}.";
16 String get invocation => "${runner.executableName} help [command]";
17
18 void run() {
19 // Show the default help if no command was specified.
20 if (argResults.rest.isEmpty) {
21 runner.printUsage();
22 return;
23 }
24
25 // Walk the command tree to show help for the selected command or
26 // subcommand.
27 var commands = runner.commands;
28 var command = null;
29 var commandString = runner.executableName;
30
31 for (var name in argResults.rest) {
32 if (commands.isEmpty) {
33 command.usageException(
34 'Command "$commandString" does not expect a subcommand.');
35 }
36
37 if (commands[name] == null) {
38 if (command == null) {
39 runner.usageException('Could not find a command named "$name".');
40 }
41
42 command.usageException(
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 }
53 }
OLDNEW
« no previous file with comments | « args/lib/src/arg_results.dart ('k') | args/lib/src/option.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698