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

Unified Diff: utils/pub/pub.dart

Issue 11416222: Add support for pub command aliases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/command_lish.dart ('k') | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/pub.dart
diff --git a/utils/pub/pub.dart b/utils/pub/pub.dart
index 3ce10b462734f7402f18a4ffe2bb21317271d1c2..df40c064e4e92954fbf3e83c9b3ad327dd12aaa1 100644
--- a/utils/pub/pub.dart
+++ b/utils/pub/pub.dart
@@ -34,13 +34,21 @@ Version get pubVersion => new Version(0, 0, 0);
/**
* The commands that Pub understands.
*/
-Map<String, PubCommand> get pubCommands => {
- 'help': new HelpCommand(),
- 'install': new InstallCommand(),
- 'lish': new LishCommand(),
- 'update': new UpdateCommand(),
- 'version': new VersionCommand()
-};
+Map<String, PubCommand> get pubCommands {
+ var commands = {
+ 'help': new HelpCommand(),
+ 'install': new InstallCommand(),
+ 'publish': new LishCommand(),
+ 'update': new UpdateCommand(),
+ 'version': new VersionCommand()
+ };
+ for (var command in commands.values) {
+ for (var alias in command.aliases) {
+ commands[alias] = command;
+ }
+ }
+ return commands;
+}
/**
* The parser for arguments that are global to Pub rather than specific to a
@@ -164,7 +172,11 @@ abstract class PubCommand {
/// Whether or not this command requires [entrypoint] to be defined. If false,
/// Pub won't look for a pubspec and [entrypoint] will be null when the
/// command runs.
- bool get requiresEntrypoint => true;
+ final requiresEntrypoint = true;
+
+ /// Alternate names for this command. These names won't be used in the
+ /// documentation, but they will work when invoked on the command line.
+ final aliases = const <String>[];
/**
* Override this to define command-specific options. The results will be made
« no previous file with comments | « utils/pub/command_lish.dart ('k') | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698