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

Unified Diff: sdk/lib/_internal/pub/lib/src/command.dart

Issue 354763006: Add a "pub global run" command. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise! Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/command/global.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/command.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command.dart b/sdk/lib/_internal/pub/lib/src/command.dart
index 6b043547bcb6f5c17b2fc2bfc80a286167696f25..6bc10b0e2fc99d0349bb09569da759bee37b57a4 100644
--- a/sdk/lib/_internal/pub/lib/src/command.dart
+++ b/sdk/lib/_internal/pub/lib/src/command.dart
@@ -25,7 +25,6 @@ import 'command/uploader.dart';
import 'command/version.dart';
import 'entrypoint.dart';
import 'exceptions.dart';
-import 'exit_codes.dart' as exit_codes;
import 'log.dart' as log;
import 'global_packages.dart';
import 'system_cache.dart';
@@ -68,7 +67,7 @@ abstract class PubCommand {
/// [commands].
static void usageErrorWithCommands(Map<String, PubCommand> commands,
String message) {
- throw new UsageException(message, _listCommands(commands));
+ throw new UsageException(message)..bindUsage(_listCommands(commands));
}
/// Writes [commands] in a nicely formatted list to [buffer].
@@ -191,7 +190,10 @@ abstract class PubCommand {
entrypoint = new Entrypoint(path.current, cache);
}
- return syncFuture(onRun);
+ return syncFuture(onRun).catchError((error) {
+ if (error is UsageException) error.bindUsage(_getUsage());
+ throw error;
+ });
}
/// Override this to perform the specific command.
@@ -214,13 +216,6 @@ abstract class PubCommand {
log.message('$description\n\n${_getUsage()}');
}
- // TODO(rnystrom): Use this in other places handle usage failures.
- /// Throw a [UsageException] for a usage error of this command with
- /// [message].
- void usageError(String message) {
- throw new UsageException(message, _getUsage());
- }
-
/// Parses a user-supplied integer [intString] named [name].
///
/// If the parsing fails, prints a usage message and exits.
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/command/global.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698