Index: pkg/args/lib/src/help_command.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/command/help.dart b/pkg/args/lib/src/help_command.dart |
similarity index 50% |
copy from sdk/lib/_internal/pub/lib/src/command/help.dart |
copy to pkg/args/lib/src/help_command.dart |
index d7df22324b3775f7e77a517f255fe972821b12ef..86c53f8903486083c678fbf4b032419939e138b0 100644 |
--- a/sdk/lib/_internal/pub/lib/src/command/help.dart |
+++ b/pkg/args/lib/src/help_command.dart |
@@ -1,33 +1,36 @@ |
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library pub.command.help; |
+library args.help_command; |
-import 'dart:async'; |
+import 'command_runner.dart'; |
-import '../command.dart'; |
+/// The built-in help command that's added to every [CommandRunner]. |
+/// |
+/// This command displays help information for the various subcommands. |
+class HelpCommand extends Command { |
+ final name = "help"; |
Bob Nystrom
2014/12/11 20:25:31
Why not make this a getter too?
nweiz
2014/12/11 23:55:24
I don't like constant-valued getters when fields w
Bob Nystrom
2014/12/12 18:13:22
I know you feel that way, but I still don't unders
|
+ String get description => |
+ "Display help information for ${runner.executableName}."; |
+ String get usage => "${runner.executableName} help [command]"; |
-/// Handles the `help` pub command. |
-class HelpCommand extends PubCommand { |
- String get description => "Display help information for Pub."; |
- String get usage => "pub help [command]"; |
- bool get takesArguments => true; |
+ HelpCommand(); |
Bob Nystrom
2014/12/11 20:25:31
Delete.
nweiz
2014/12/11 23:55:24
Done.
|
- Future onRun() { |
+ void run() { |
// Show the default help if no command was specified. |
- if (commandOptions.rest.isEmpty) { |
- PubCommand.printGlobalUsage(); |
- return null; |
+ if (options.rest.isEmpty) { |
+ runner.printUsage(); |
+ return; |
} |
// Walk the command tree to show help for the selected command or |
// subcommand. |
- var commands = PubCommand.mainCommands; |
+ var commands = runner.topLevelCommands; |
var command = null; |
- var commandString = "pub"; |
+ var commandString = runner.executableName; |
- for (var name in commandOptions.rest) { |
+ for (var name in options.rest) { |
if (commands.isEmpty) { |
command.usageError( |
'Command "$commandString" does not expect a subcommand.'); |
@@ -35,8 +38,7 @@ class HelpCommand extends PubCommand { |
if (commands[name] == null) { |
if (command == null) { |
- PubCommand.usageErrorWithCommands(commands, |
- 'Could not find a command named "$name".'); |
+ runner.usageError('Could not find a command named "$name".'); |
} |
command.usageError( |
@@ -49,6 +51,5 @@ class HelpCommand extends PubCommand { |
} |
command.printUsage(); |
- return null; |
} |
} |