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 `upgrade` pub command. | 11 /// Handles the `upgrade` pub command. |
12 class UpgradeCommand extends PubCommand { | 12 class UpgradeCommand extends PubCommand { |
13 String get name => "upgrade"; | 13 String get name => "upgrade"; |
14 String get description => | 14 String get description => |
15 "Upgrade the current package's dependencies to latest versions."; | 15 "Upgrade the current package's dependencies to latest versions."; |
16 String get invocation => "pub upgrade [dependencies...]"; | 16 String get invocation => "pub upgrade [dependencies...]"; |
17 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-upgrade.html"; | 17 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-upgrade.html"; |
18 List<String> get aliases => const ["update"]; | 18 List<String> get aliases => const ["update"]; |
19 | 19 |
20 bool get isOffline => argResults['offline']; | 20 bool get isOffline => argResults['offline']; |
21 | 21 |
22 UpgradeCommand() { | 22 UpgradeCommand() { |
23 argParser.addFlag('offline', | 23 argParser.addFlag('offline', |
24 help: 'Use cached packages instead of accessing the network.'); | 24 help: 'Use cached packages instead of accessing the network.'); |
25 | 25 |
26 argParser.addFlag('dry-run', abbr: 'n', negatable: false, | 26 argParser.addFlag('dry-run', abbr: 'n', negatable: false, |
27 help: "Report what dependencies would change but don't change any."); | 27 help: "Report what dependencies would change but don't change any."); |
| 28 |
| 29 argParser.addFlag('precompile', defaultsTo: true, |
| 30 help: "Precompile executables and transformed dependencies."); |
28 } | 31 } |
29 | 32 |
30 Future run() async { | 33 Future run() async { |
31 var dryRun = argResults['dry-run']; | |
32 await entrypoint.acquireDependencies(SolveType.UPGRADE, | 34 await entrypoint.acquireDependencies(SolveType.UPGRADE, |
33 useLatest: argResults.rest, dryRun: dryRun); | 35 useLatest: argResults.rest, |
| 36 dryRun: argResults['dry-run'], |
| 37 precompile: argResults['precompile']); |
| 38 |
34 if (isOffline) { | 39 if (isOffline) { |
35 log.warning("Warning: Upgrading when offline may not update you to the " | 40 log.warning("Warning: Upgrading when offline may not update you to the " |
36 "latest versions of your dependencies."); | 41 "latest versions of your dependencies."); |
37 } | 42 } |
38 } | 43 } |
39 } | 44 } |
OLD | NEW |