| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import '../command.dart'; | 7 import '../command.dart'; |
| 8 import '../log.dart' as log; | 8 import '../log.dart' as log; |
| 9 import '../solver/version_solver.dart'; | 9 import '../solver/version_solver.dart'; |
| 10 | 10 |
| 11 /// Handles the `downgrade` pub command. | 11 /// Handles the `downgrade` pub command. |
| 12 class DowngradeCommand extends PubCommand { | 12 class DowngradeCommand extends PubCommand { |
| 13 String get name => "downgrade"; | 13 String get name => "downgrade"; |
| 14 String get description => | 14 String get description => |
| 15 "Downgrade the current package's dependencies to oldest versions.\n\n" | 15 "Downgrade the current package's dependencies to oldest versions.\n\n" |
| 16 "This doesn't modify the lockfile, so it can be reset with \"pub get\"."; | 16 "This doesn't modify the lockfile, so it can be reset with \"pub get\"."; |
| 17 String get invocation => "pub downgrade [dependencies...]"; | 17 String get invocation => "pub downgrade [dependencies...]"; |
| 18 | 18 |
| 19 bool get isOffline => argResults['offline']; | 19 bool get isOffline => argResults['offline']; |
| 20 | 20 |
| 21 DowngradeCommand() { | 21 DowngradeCommand() { |
| 22 argParser.addFlag('offline', | 22 argParser.addFlag('offline', |
| 23 help: 'Use cached packages instead of accessing the network.'); | 23 help: 'Use cached packages instead of accessing the network.'); |
| 24 | 24 |
| 25 argParser.addFlag('dry-run', abbr: 'n', negatable: false, | 25 argParser.addFlag('dry-run', abbr: 'n', negatable: false, |
| 26 help: "Report what dependencies would change but don't change any."); | 26 help: "Report what dependencies would change but don't change any."); |
| 27 | 27 |
| 28 argParser.addFlag('packages-dir', | 28 argParser.addFlag('packages-dir', |
| 29 negatable: true, defaultsTo: true, | 29 negatable: true, |
| 30 help: "Generate a packages/ directory when installing packages."); | 30 help: "Generate a packages/ directory when installing packages."); |
| 31 } | 31 } |
| 32 | 32 |
| 33 Future run() async { | 33 Future run() async { |
| 34 var dryRun = argResults['dry-run']; | 34 var dryRun = argResults['dry-run']; |
| 35 await entrypoint.acquireDependencies(SolveType.DOWNGRADE, | 35 await entrypoint.acquireDependencies(SolveType.DOWNGRADE, |
| 36 useLatest: argResults.rest, | 36 useLatest: argResults.rest, |
| 37 dryRun: dryRun, | 37 dryRun: dryRun, |
| 38 packagesDir: argResults['packages-dir']); | 38 packagesDir: argResults['packages-dir']); |
| 39 | 39 |
| 40 if (isOffline) { | 40 if (isOffline) { |
| 41 log.warning("Warning: Downgrading when offline may not update you to " | 41 log.warning("Warning: Downgrading when offline may not update you to " |
| 42 "the oldest versions of your dependencies."); | 42 "the oldest versions of your dependencies."); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 } | 45 } |
| OLD | NEW |