Skip to content

Commit c589a0c

Browse files
authored
Revert "[flutter_tools] show only supported sub commands (flutter#85125)" (flutter#86131)
This reverts commit 84e5767.
1 parent 456fe1a commit c589a0c

File tree

10 files changed

+22
-53
lines changed

10 files changed

+22
-53
lines changed

packages/flutter_tools/lib/src/commands/build.dart

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,25 @@ import 'build_winuwp.dart';
2424

2525
class BuildCommand extends FlutterCommand {
2626
BuildCommand({ bool verboseHelp = false }) {
27-
_addSubcommand(BuildAarCommand(verboseHelp: verboseHelp));
28-
_addSubcommand(BuildApkCommand(verboseHelp: verboseHelp));
29-
_addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp));
30-
_addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp));
31-
_addSubcommand(BuildIOSFrameworkCommand(
27+
addSubcommand(BuildAarCommand(verboseHelp: verboseHelp));
28+
addSubcommand(BuildApkCommand(verboseHelp: verboseHelp));
29+
addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp));
30+
addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp));
31+
addSubcommand(BuildIOSFrameworkCommand(
3232
buildSystem: globals.buildSystem,
3333
verboseHelp: verboseHelp,
3434
));
35-
_addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp));
36-
_addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
37-
_addSubcommand(BuildWebCommand(verboseHelp: verboseHelp));
38-
_addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp));
39-
_addSubcommand(BuildLinuxCommand(
35+
addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp));
36+
addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
37+
addSubcommand(BuildWebCommand(verboseHelp: verboseHelp));
38+
addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp));
39+
addSubcommand(BuildLinuxCommand(
4040
operatingSystemUtils: globals.os,
4141
verboseHelp: verboseHelp
4242
));
43-
_addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp));
44-
_addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp));
45-
_addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp));
46-
}
47-
48-
void _addSubcommand(BuildSubCommand command) {
49-
if (command.supported) {
50-
addSubcommand(command);
51-
}
43+
addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp));
44+
addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp));
45+
addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp));
5246
}
5347

5448
@override
@@ -69,8 +63,6 @@ abstract class BuildSubCommand extends FlutterCommand {
6963
@override
7064
bool get reportNullSafety => true;
7165

72-
bool get supported => true;
73-
7466
/// Display a message describing the current null safety runtime mode
7567
/// that was selected.
7668
///

packages/flutter_tools/lib/src/commands/build_fuchsia.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ class BuildFuchsiaCommand extends BuildSubCommand {
5858
@override
5959
String get description => 'Build the Fuchsia target (Experimental).';
6060

61-
@override
62-
bool get supported => globals.platform.isLinux || globals.platform.isMacOS;
63-
6461
@override
6562
Future<FlutterCommandResult> runCommand() async {
6663
if (!featureFlags.isFuchsiaEnabled) {
@@ -71,7 +68,7 @@ class BuildFuchsiaCommand extends BuildSubCommand {
7168
}
7269
final BuildInfo buildInfo = await getBuildInfo();
7370
final FlutterProject flutterProject = FlutterProject.current();
74-
if (!supported) {
71+
if (!globals.platform.isLinux && !globals.platform.isMacOS) {
7572
throwToolExit('"build fuchsia" is only supported on Linux and MacOS hosts.');
7673
}
7774
if (!flutterProject.fuchsia.existsSync()) {

packages/flutter_tools/lib/src/commands/build_ios.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,12 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
224224

225225
Directory _outputAppDirectory(String xcodeResultOutput);
226226

227-
@override
228-
bool get supported => globals.platform.isMacOS;
229-
230227
@override
231228
Future<FlutterCommandResult> runCommand() async {
232229
defaultBuildMode = forSimulator ? BuildMode.debug : BuildMode.release;
233230
final BuildInfo buildInfo = await getBuildInfo();
234231

235-
if (!supported) {
232+
if (!globals.platform.isMacOS) {
236233
throwToolExit('Building for iOS is only supported on macOS.');
237234
}
238235
if (forSimulator && !buildInfo.supportsSimulator) {

packages/flutter_tools/lib/src/commands/build_ios_framework.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,11 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
141141
return buildInfos;
142142
}
143143

144-
@override
145-
bool get supported => _platform.isMacOS;
146-
147144
@override
148145
Future<void> validateCommand() async {
149146
await super.validateCommand();
150147
_project = FlutterProject.current();
151-
if (!supported) {
148+
if (!_platform.isMacOS) {
152149
throwToolExit('Building frameworks for iOS is only supported on the Mac.');
153150
}
154151

packages/flutter_tools/lib/src/commands/build_macos.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,14 @@ class BuildMacosCommand extends BuildSubCommand {
3939
@override
4040
String get description => 'Build a macOS desktop application.';
4141

42-
@override
43-
bool get supported => globals.platform.isMacOS;
44-
4542
@override
4643
Future<FlutterCommandResult> runCommand() async {
4744
final BuildInfo buildInfo = await getBuildInfo();
4845
final FlutterProject flutterProject = FlutterProject.current();
4946
if (!featureFlags.isMacOSEnabled) {
5047
throwToolExit('"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".');
5148
}
52-
if (!supported) {
49+
if (!globals.platform.isMacOS) {
5350
throwToolExit('"build macos" only supported on macOS hosts.');
5451
}
5552
displayNullSafetyMode(buildInfo);

packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// @dart = 2.8
66

7-
import 'package:args/command_runner.dart';
87
import 'package:file/memory.dart';
98
import 'package:file_testing/file_testing.dart';
109
import 'package:flutter_tools/src/base/file_system.dart';
@@ -112,7 +111,7 @@ void main() {
112111

113112
expect(
114113
createTestCommandRunner(command).run(const <String>['build', 'fuchsia']),
115-
throwsA(isA<UsageException>()),
114+
throwsToolExit(),
116115
);
117116
}, overrides: <Type, Generator>{
118117
Platform: () => windowsPlatform,

packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// @dart = 2.8
66

7-
import 'package:args/command_runner.dart';
87
import 'package:file/memory.dart';
98
import 'package:flutter_tools/src/base/file_system.dart';
109
import 'package:flutter_tools/src/base/platform.dart';
@@ -163,7 +162,7 @@ void main() {
163162

164163
expect(createTestCommandRunner(command).run(
165164
const <String>['build', 'ios', '--no-pub']
166-
), throwsA(isA<UsageException>()));
165+
), throwsToolExit());
167166
}, overrides: <Type, Generator>{
168167
Platform: () => notMacosPlatform,
169168
FileSystem: () => fileSystem,

packages/flutter_tools/test/commands.shard/hermetic/build_ipa_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// @dart = 2.8
66

7-
import 'package:args/command_runner.dart';
87
import 'package:file/memory.dart';
98
import 'package:flutter_tools/src/base/file_system.dart';
109
import 'package:flutter_tools/src/base/logger.dart';
@@ -158,7 +157,7 @@ void main() {
158157

159158
expect(createTestCommandRunner(command).run(
160159
const <String>['build', 'ipa', '--no-pub']
161-
), throwsA(isA<UsageException>()));
160+
), throwsToolExit());
162161
}, overrides: <Type, Generator>{
163162
Platform: () => notMacosPlatform,
164163
FileSystem: () => fileSystem,

packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void main() {
149149

150150
expect(createTestCommandRunner(command).run(
151151
const <String>['build', 'macos', '--no-pub']
152-
), throwsA(isA<UsageException>()));
152+
), throwsToolExit(message: '"build macos" only supported on macOS hosts.'));
153153
}, overrides: <Type, Generator>{
154154
Platform: () => notMacosPlatform,
155155
FileSystem: () => fileSystem,
@@ -391,7 +391,7 @@ void main() {
391391
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
392392

393393
expect(() => runner.run(<String>['build', 'macos', '--no-pub']),
394-
throwsA(isA<UsageException>()));
394+
throwsToolExit());
395395
}, overrides: <Type, Generator>{
396396
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
397397
});

packages/flutter_tools/test/general.shard/commands/build_test.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// @dart = 2.8
66

77
import 'package:args/args.dart';
8-
import 'package:args/command_runner.dart';
98
import 'package:flutter_tools/src/build_info.dart';
109
import 'package:flutter_tools/src/commands/attach.dart';
1110
import 'package:flutter_tools/src/commands/build.dart';
@@ -76,13 +75,6 @@ void main() {
7675
FakeBuildSubCommand().test(sound);
7776
expect(testLogger.statusText, contains('💪 Building with sound null safety 💪'));
7877
});
79-
80-
testUsingContext('Include only supported sub commands', () {
81-
final BuildCommand command = BuildCommand();
82-
for (final Command<void> x in command.subcommands.values) {
83-
expect((x as BuildSubCommand).supported, isTrue);
84-
}
85-
});
8678
}
8779

8880
class FakeBuildSubCommand extends BuildSubCommand {

0 commit comments

Comments
 (0)