Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library pub.command.global_activate; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import '../command.dart'; | |
| 10 import '../utils.dart'; | |
| 11 import '../version.dart'; | |
| 12 | |
| 13 /// Handles the `global activate` pub command. | |
| 14 class GlobalActivateCommand extends PubCommand { | |
| 15 String get description => "Make a package globally available."; | |
|
nweiz
2014/06/26 22:43:25
"a package's executables"
We're going to have to
Bob Nystrom
2014/06/27 00:30:23
Yeah, reworded.
| |
| 16 String get usage => "pub global activate <package> [version]"; | |
| 17 bool get requiresEntrypoint => false; | |
| 18 bool get takesArguments => true; | |
| 19 | |
| 20 Future onRun() { | |
| 21 // Make sure there is a package. | |
| 22 if (commandOptions.rest.isEmpty) { | |
| 23 usageError("No package to activate given."); | |
| 24 } | |
| 25 | |
| 26 // Don't allow extra arguments. | |
| 27 if (commandOptions.rest.length > 2) { | |
| 28 var unexpected = commandOptions.rest.skip(2).map((arg) => '"$arg"'); | |
| 29 var arguments = pluralize("argument", unexpected.length); | |
| 30 usageError("Unexpected $arguments ${toSentence(unexpected)}."); | |
| 31 } | |
| 32 | |
| 33 var package = commandOptions.rest.first; | |
| 34 | |
| 35 // Parse the version constraint, if there is one. | |
| 36 var constraint = VersionConstraint.any; | |
| 37 if (commandOptions.rest.length == 2) { | |
| 38 try { | |
| 39 constraint = new VersionConstraint.parse(commandOptions.rest[1]); | |
| 40 } on FormatException catch (error) { | |
| 41 usageError(error.message); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 return globals.activate(package, constraint); | |
| 46 } | |
| 47 } | |
| OLD | NEW |