|
4 | 4 |
|
5 | 5 | import 'package:args/args.dart';
|
6 | 6 |
|
7 |
| -import '../artifacts.dart'; |
8 | 7 | import '../base/common.dart';
|
9 |
| -import '../globals.dart' as globals; |
10 | 8 | import '../runner/flutter_command.dart';
|
11 | 9 |
|
12 | 10 | class FormatCommand extends FlutterCommand {
|
13 |
| - FormatCommand({required this.verboseHelp}); |
| 11 | + FormatCommand(); |
14 | 12 |
|
15 | 13 | @override
|
16 | 14 | ArgParser argParser = ArgParser.allowAnything();
|
17 | 15 |
|
18 |
| - final bool verboseHelp; |
19 |
| - |
20 | 16 | @override
|
21 | 17 | final String name = 'format';
|
22 | 18 |
|
23 | 19 | @override
|
24 | 20 | List<String> get aliases => const <String>['dartfmt'];
|
25 | 21 |
|
26 | 22 | @override
|
27 |
| - final String description = 'Format one or more Dart files.'; |
28 |
| - |
29 |
| - @override |
30 |
| - String get category => FlutterCommandCategory.project; |
| 23 | + String get description => deprecationWarning; |
31 | 24 |
|
32 | 25 | @override
|
33 |
| - String get invocation => '${runner?.executableName} $name <one or more paths>'; |
34 |
| - |
35 |
| - @override |
36 |
| - final bool deprecated = true; |
| 26 | + final bool hidden = true; |
37 | 27 |
|
38 | 28 | @override
|
39 | 29 | String get deprecationWarning {
|
40 |
| - return '${globals.logger.terminal.warningMark} The "format" command is ' |
41 |
| - 'deprecated and will be removed in a future version of Flutter. ' |
42 |
| - 'Please use the "dart format" sub-command instead, which takes all ' |
43 |
| - 'of the same command-line arguments as "flutter format".\n'; |
| 30 | + return 'The "format" command is deprecated. Please use the "dart format" ' |
| 31 | + 'sub-command instead, which has the same command-line usage as ' |
| 32 | + '"flutter format".\n'; |
44 | 33 | }
|
45 | 34 |
|
46 | 35 | @override
|
47 | 36 | Future<FlutterCommandResult> runCommand() async {
|
48 |
| - final String dartBinary = globals.artifacts!.getArtifactPath(Artifact.engineDartBinary); |
49 |
| - final List<String> command = <String>[ |
50 |
| - dartBinary, |
51 |
| - 'format', |
52 |
| - ]; |
53 |
| - final List<String> rest = argResults?.rest ?? <String>[]; |
54 |
| - if (rest.isEmpty) { |
55 |
| - globals.printError( |
56 |
| - 'No files specified to be formatted.' |
57 |
| - ); |
58 |
| - command.add('-h'); |
59 |
| - } else { |
60 |
| - command.addAll(<String>[ |
61 |
| - for (String arg in rest) |
62 |
| - if (arg == '--dry-run' || arg == '-n') |
63 |
| - '--output=none' |
64 |
| - else |
65 |
| - arg, |
66 |
| - ]); |
67 |
| - } |
68 |
| - |
69 |
| - final int result = await globals.processUtils.stream(command); |
70 |
| - if (result != 0) { |
71 |
| - throwToolExit('Formatting failed: $result', exitCode: result); |
72 |
| - } |
73 |
| - |
74 |
| - return FlutterCommandResult.success(); |
| 37 | + throwToolExit(deprecationWarning); |
75 | 38 | }
|
76 | 39 | }
|
0 commit comments