Index: sdk/lib/_internal/pub/lib/src/command/global_run.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/command/global_run.dart b/sdk/lib/_internal/pub/lib/src/command/global_run.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bdffb93990544c3f812d8c2ca974f5448c108b8f |
--- /dev/null |
+++ b/sdk/lib/_internal/pub/lib/src/command/global_run.dart |
@@ -0,0 +1,49 @@ |
+// 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.global_run; |
+ |
+import 'dart:async'; |
+import 'dart:io'; |
+ |
+import 'package:barback/barback.dart'; |
+import 'package:path/path.dart' as path; |
+import 'package:stack_trace/stack_trace.dart'; |
+ |
+import '../barback/asset_environment.dart'; |
+import '../command.dart'; |
+import '../entrypoint.dart'; |
+import '../executable.dart'; |
+import '../exit_codes.dart' as exit_codes; |
+import '../io.dart'; |
+import '../log.dart' as log; |
+import '../utils.dart'; |
+ |
+/// Handles the `global run` pub command. |
+class GlobalRunCommand extends PubCommand { |
+ bool get requiresEntrypoint => false; |
+ bool get takesArguments => true; |
+ bool get allowTrailingOptions => false; |
+ String get description => |
+ "Run an executable from a globally activated package."; |
+ String get usage => "pub global run <package> <executable> [args...]"; |
+ |
+ Future onRun() { |
+ if (commandOptions.rest.isEmpty) { |
nweiz
2014/07/02 00:12:02
I had assumed that "pub global run" would use the
Bob Nystrom
2014/07/02 18:00:52
I wanted something simpler and more explicit for t
nweiz
2014/07/02 19:57:50
I think this behavior is fine, it just took me by
|
+ usageError("Must specify a package and executable to run."); |
+ } |
+ |
+ if (commandOptions.rest.length == 1) { |
+ usageError("Must specify an executable to run."); |
+ } |
+ |
+ var package = commandOptions.rest[0]; |
+ var executable = commandOptions.rest[1]; |
+ var args = commandOptions.rest.skip(2); |
+ |
+ return globals.find(package).then((entrypoint) { |
+ return runExecutable(entrypoint, package, executable, args); |
+ }).then(flushThenExit); |
+ } |
+} |