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 |
| 28 argParser.addFlag('packages-dir', |
| 29 negatable: true, defaultsTo: true, |
| 30 help: "Generate a packages/ directory when installing packages."); |
27 } | 31 } |
28 | 32 |
29 Future run() async { | 33 Future run() async { |
30 var dryRun = argResults['dry-run']; | 34 var dryRun = argResults['dry-run']; |
31 await entrypoint.acquireDependencies(SolveType.DOWNGRADE, | 35 await entrypoint.acquireDependencies(SolveType.DOWNGRADE, |
32 useLatest: argResults.rest, dryRun: dryRun); | 36 useLatest: argResults.rest, |
| 37 dryRun: dryRun, |
| 38 packagesDir: argResults['packages-dir']); |
| 39 |
33 if (isOffline) { | 40 if (isOffline) { |
34 log.warning("Warning: Downgrading when offline may not update you to " | 41 log.warning("Warning: Downgrading when offline may not update you to " |
35 "the oldest versions of your dependencies."); | 42 "the oldest versions of your dependencies."); |
36 } | 43 } |
37 } | 44 } |
38 } | 45 } |
OLD | NEW |