mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
Clean up command help.
It was missing a newline before which made it look busted: some command helpUsage: pub foo Review URL: https://codereview.chromium.org//11485012 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15944 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
48b4286880
commit
9125bd4591
7 changed files with 58 additions and 37 deletions
|
@ -12,7 +12,7 @@ import 'pub.dart';
|
|||
|
||||
/** Handles the `help` pub command. */
|
||||
class HelpCommand extends PubCommand {
|
||||
String get description => "display help information for Pub";
|
||||
String get description => "Display help information for Pub.";
|
||||
String get usage => 'pub help [command]';
|
||||
bool get requiresEntrypoint => false;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'pub.dart';
|
|||
|
||||
/** Handles the `install` pub command. */
|
||||
class InstallCommand extends PubCommand {
|
||||
String get description => "install the current package's dependencies";
|
||||
String get description => "Install the current package's dependencies.";
|
||||
String get usage => "pub install";
|
||||
|
||||
Future onRun() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import 'validator.dart';
|
|||
// 6949.
|
||||
/// Handles the `lish` and `publish` pub commands.
|
||||
class LishCommand extends PubCommand {
|
||||
final description = "publish the current package to pub.dartlang.org";
|
||||
final description = "Publish the current package to pub.dartlang.org.";
|
||||
final usage = "pub publish [options]";
|
||||
final aliases = const ["lish", "lush"];
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import 'pub.dart';
|
|||
/** Handles the `update` pub command. */
|
||||
class UpdateCommand extends PubCommand {
|
||||
String get description =>
|
||||
"update the current package's dependencies to the latest versions";
|
||||
"Update the current package's dependencies to the latest versions.";
|
||||
|
||||
String get usage => 'pub update [dependencies...]';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'pub.dart';
|
|||
|
||||
/** Handles the `version` pub command. */
|
||||
class VersionCommand extends PubCommand {
|
||||
String get description => 'print Pub version';
|
||||
String get description => 'Print pub version.';
|
||||
String get usage => 'pub version';
|
||||
bool get requiresEntrypoint => false;
|
||||
|
||||
|
|
|
@ -56,21 +56,21 @@ Map<String, PubCommand> get pubCommands {
|
|||
ArgParser get pubArgParser {
|
||||
var parser = new ArgParser();
|
||||
parser.addFlag('help', abbr: 'h', negatable: false,
|
||||
help: 'print this usage information');
|
||||
help: 'Print this usage information.');
|
||||
parser.addFlag('version', negatable: false,
|
||||
help: 'print the version of pub');
|
||||
help: 'Print pub version.');
|
||||
parser.addFlag('trace',
|
||||
help: 'print debugging information when an error occurs');
|
||||
help: 'Print debugging information when an error occurs.');
|
||||
parser.addOption('verbosity',
|
||||
help: 'control output verbosity',
|
||||
help: 'Control output verbosity.',
|
||||
allowed: ['normal', 'io', 'all'],
|
||||
allowedHelp: {
|
||||
'normal': 'errors, warnings, and user messages are shown',
|
||||
'io': 'IO operations are also shown',
|
||||
'all': 'all output including internal tracing messages are shown'
|
||||
'normal': 'Errors, warnings, and user messages are shown.',
|
||||
'io': 'IO operations are also shown.',
|
||||
'all': 'All output including internal tracing messages are shown.'
|
||||
});
|
||||
parser.addFlag('verbose', abbr: 'v', negatable: false,
|
||||
help: 'shortcut for "--verbosity=all"');
|
||||
help: 'Shortcut for "--verbosity=all"');
|
||||
return parser;
|
||||
}
|
||||
|
||||
|
@ -297,13 +297,11 @@ abstract class PubCommand {
|
|||
if (description == null) description = this.description;
|
||||
|
||||
var buffer = new StringBuffer();
|
||||
buffer.add(description);
|
||||
buffer.add('');
|
||||
buffer.add('Usage: $usage');
|
||||
buffer.add('$description\n\nUsage: $usage');
|
||||
|
||||
var commandUsage = commandParser.getUsage();
|
||||
if (!commandUsage.isEmpty) {
|
||||
buffer.add('');
|
||||
buffer.add('\n');
|
||||
buffer.add(commandUsage);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,23 +15,23 @@ final USAGE_STRING = """
|
|||
Usage: pub command [arguments]
|
||||
|
||||
Global options:
|
||||
-h, --help print this usage information
|
||||
--version print the version of pub
|
||||
--[no-]trace print debugging information when an error occurs
|
||||
--verbosity control output verbosity
|
||||
-h, --help Print this usage information.
|
||||
--version Print pub version.
|
||||
--[no-]trace Print debugging information when an error occurs.
|
||||
--verbosity Control output verbosity.
|
||||
|
||||
[all] all output including internal tracing messages are shown
|
||||
[io] IO operations are also shown
|
||||
[normal] errors, warnings, and user messages are shown
|
||||
[all] All output including internal tracing messages are shown.
|
||||
[io] IO operations are also shown.
|
||||
[normal] Errors, warnings, and user messages are shown.
|
||||
|
||||
-v, --verbose shortcut for "--verbosity=all"
|
||||
-v, --verbose Shortcut for "--verbosity=all"
|
||||
|
||||
Available commands:
|
||||
help display help information for Pub
|
||||
install install the current package's dependencies
|
||||
publish publish the current package to pub.dartlang.org
|
||||
update update the current package's dependencies to the latest versions
|
||||
version print Pub version
|
||||
help Display help information for Pub.
|
||||
install Install the current package's dependencies.
|
||||
publish Publish the current package to pub.dartlang.org.
|
||||
update Update the current package's dependencies to the latest versions.
|
||||
version Print pub version.
|
||||
|
||||
Use "pub help [command]" for more information about a command.
|
||||
""";
|
||||
|
@ -82,13 +82,36 @@ main() {
|
|||
exitCode: 64);
|
||||
});
|
||||
|
||||
test('an unknown help command displays an error message', () {
|
||||
runPub(args: ['help', 'quylthulg'],
|
||||
error: '''
|
||||
Could not find a command named "quylthulg".
|
||||
Run "pub help" to see available commands.
|
||||
''',
|
||||
exitCode: 64);
|
||||
group('help', () {
|
||||
test('shows help for a command', () {
|
||||
runPub(args: ['help', 'install'],
|
||||
output: '''
|
||||
Install the current package's dependencies.
|
||||
|
||||
Usage: pub install
|
||||
''');
|
||||
});
|
||||
|
||||
test('shows help for a command', () {
|
||||
runPub(args: ['help', 'publish'],
|
||||
output: '''
|
||||
Publish the current package to pub.dartlang.org.
|
||||
|
||||
Usage: pub publish [options]
|
||||
--server The package server to which to upload this package
|
||||
(defaults to "https://pub.dartlang.org")
|
||||
''');
|
||||
});
|
||||
|
||||
test('an unknown help command displays an error message', () {
|
||||
runPub(args: ['help', 'quylthulg'],
|
||||
error: '''
|
||||
Could not find a command named "quylthulg".
|
||||
Run "pub help" to see available commands.
|
||||
''',
|
||||
exitCode: 64);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('displays the current version', () =>
|
||||
|
|
Loading…
Reference in a new issue