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

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

Issue 331593012: Add a "global activate" command to pub. (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_activate.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/global_activate.dart b/sdk/lib/_internal/pub/lib/src/command/global_activate.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5c3e523702551ccd4af9ca58761d92652ded93c0
--- /dev/null
+++ b/sdk/lib/_internal/pub/lib/src/command/global_activate.dart
@@ -0,0 +1,47 @@
+// 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_activate;
+
+import 'dart:async';
+
+import '../command.dart';
+import '../utils.dart';
+import '../version.dart';
+
+/// Handles the `global activate` pub command.
+class GlobalActivateCommand extends PubCommand {
+ String get description => "Make a package's executables globally available.";
+ String get usage => "pub global activate <package> [version]";
+ bool get requiresEntrypoint => false;
+ bool get takesArguments => true;
+
+ Future onRun() {
+ // Make sure there is a package.
+ if (commandOptions.rest.isEmpty) {
+ usageError("No package to activate given.");
+ }
+
+ // Don't allow extra arguments.
+ if (commandOptions.rest.length > 2) {
+ var unexpected = commandOptions.rest.skip(2).map((arg) => '"$arg"');
+ var arguments = pluralize("argument", unexpected.length);
+ usageError("Unexpected $arguments ${toSentence(unexpected)}.");
+ }
+
+ var package = commandOptions.rest.first;
+
+ // Parse the version constraint, if there is one.
+ var constraint = VersionConstraint.any;
+ if (commandOptions.rest.length == 2) {
+ try {
+ constraint = new VersionConstraint.parse(commandOptions.rest[1]);
+ } on FormatException catch (error) {
+ usageError(error.message);
+ }
+ }
+
+ return globals.activate(package, constraint);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698