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

Unified Diff: sdk/lib/_internal/pub/lib/src/command/global_run.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
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) {
+ 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);
+ }
+}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command/global.dart ('k') | sdk/lib/_internal/pub/lib/src/command/list_package_dirs.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698