| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library pub.command.global_deactivate; | 5 library pub.command.global_deactivate; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../command.dart'; | 9 import '../command.dart'; |
| 10 import '../log.dart' as log; |
| 10 import '../utils.dart'; | 11 import '../utils.dart'; |
| 11 | 12 |
| 12 /// Handles the `global deactivate` pub command. | 13 /// Handles the `global deactivate` pub command. |
| 13 class GlobalDeactivateCommand extends PubCommand { | 14 class GlobalDeactivateCommand extends PubCommand { |
| 14 String get description => "Remove a previously activated package."; | 15 String get description => "Remove a previously activated package."; |
| 15 String get usage => "pub global deactivate <package>"; | 16 String get usage => "pub global deactivate <package>"; |
| 16 bool get takesArguments => true; | 17 bool get takesArguments => true; |
| 17 | 18 |
| 18 Future onRun() { | 19 Future onRun() { |
| 19 // Make sure there is a package. | 20 // Make sure there is a package. |
| 20 if (commandOptions.rest.isEmpty) { | 21 if (commandOptions.rest.isEmpty) { |
| 21 usageError("No package to deactivate given."); | 22 usageError("No package to deactivate given."); |
| 22 } | 23 } |
| 23 | 24 |
| 24 // Don't allow extra arguments. | 25 // Don't allow extra arguments. |
| 25 if (commandOptions.rest.length > 1) { | 26 if (commandOptions.rest.length > 1) { |
| 26 var unexpected = commandOptions.rest.skip(1).map((arg) => '"$arg"'); | 27 var unexpected = commandOptions.rest.skip(1).map((arg) => '"$arg"'); |
| 27 var arguments = pluralize("argument", unexpected.length); | 28 var arguments = pluralize("argument", unexpected.length); |
| 28 usageError("Unexpected $arguments ${toSentence(unexpected)}."); | 29 usageError("Unexpected $arguments ${toSentence(unexpected)}."); |
| 29 } | 30 } |
| 30 | 31 |
| 31 globals.deactivate(commandOptions.rest.first); | 32 var name = commandOptions.rest.first; |
| 33 if (!globals.deactivate(name, logDeletion: true)) { |
| 34 dataError("No active package ${log.bold(name)}."); |
| 35 } |
| 32 return null; | 36 return null; |
| 33 } | 37 } |
| 34 } | 38 } |
| OLD | NEW |