Unverified Commit 37fc9ed2 authored by Bartek Pacia's avatar Bartek Pacia Committed by GitHub

[flutter_tools] Clean up `boolArgDeprecated` and `stringArgDeprecated` (#122184)

[flutter_tools] Clean up `boolArgDeprecated` and `stringArgDeprecated`
parent d8f7c3d3
...@@ -125,7 +125,7 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -125,7 +125,7 @@ class AnalyzeCommand extends FlutterCommand {
@override @override
bool get shouldRunPub { bool get shouldRunPub {
// If they're not analyzing the current project. // If they're not analyzing the current project.
if (!boolArgDeprecated('current-package')) { if (!boolArg('current-package')) {
return false; return false;
} }
...@@ -135,7 +135,7 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -135,7 +135,7 @@ class AnalyzeCommand extends FlutterCommand {
} }
// Don't run pub if asking for machine output. // Don't run pub if asking for machine output.
if (boolArg('machine') != null && boolArg('machine')!) { if (boolArg('machine')) {
return false; return false;
} }
...@@ -144,12 +144,9 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -144,12 +144,9 @@ class AnalyzeCommand extends FlutterCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final bool? suggestionFlag = boolArg('suggestions'); if (boolArg('suggestions')) {
final bool machineFlag = boolArg('machine') ?? false;
if (suggestionFlag != null && suggestionFlag == true) {
final String directoryPath; final String directoryPath;
final bool? watchFlag = boolArg('watch'); if (boolArg('watch')) {
if (watchFlag != null && watchFlag) {
throwToolExit('flag --watch is not compatible with --suggestions'); throwToolExit('flag --watch is not compatible with --suggestions');
} }
if (workingDirectory == null) { if (workingDirectory == null) {
...@@ -171,9 +168,9 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -171,9 +168,9 @@ class AnalyzeCommand extends FlutterCommand {
allProjectValidators: _allProjectValidators, allProjectValidators: _allProjectValidators,
userPath: directoryPath, userPath: directoryPath,
processManager: _processManager, processManager: _processManager,
machine: machineFlag, machine: boolArg('machine'),
).run(); ).run();
} else if (boolArgDeprecated('watch')) { } else if (boolArg('watch')) {
await AnalyzeContinuously( await AnalyzeContinuously(
argResults!, argResults!,
runner!.getRepoRoots(), runner!.getRepoRoots(),
......
...@@ -209,7 +209,7 @@ class AssembleCommand extends FlutterCommand { ...@@ -209,7 +209,7 @@ class AssembleCommand extends FlutterCommand {
/// The environmental configuration for a build invocation. /// The environmental configuration for a build invocation.
Environment createEnvironment() { Environment createEnvironment() {
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
String? output = stringArgDeprecated('output'); String? output = stringArg('output');
if (output == null) { if (output == null) {
throwToolExit('--output directory is required for assemble.'); throwToolExit('--output directory is required for assemble.');
} }
...@@ -317,7 +317,7 @@ class AssembleCommand extends FlutterCommand { ...@@ -317,7 +317,7 @@ class AssembleCommand extends FlutterCommand {
environment, environment,
buildSystemConfig: BuildSystemConfig( buildSystemConfig: BuildSystemConfig(
resourcePoolSize: argumentResults.wasParsed('resource-pool-size') resourcePoolSize: argumentResults.wasParsed('resource-pool-size')
? int.tryParse(stringArgDeprecated('resource-pool-size')!) ? int.tryParse(stringArg('resource-pool-size')!)
: null, : null,
), ),
); );
...@@ -334,17 +334,17 @@ class AssembleCommand extends FlutterCommand { ...@@ -334,17 +334,17 @@ class AssembleCommand extends FlutterCommand {
globals.printTrace('build succeeded.'); globals.printTrace('build succeeded.');
if (argumentResults.wasParsed('build-inputs')) { if (argumentResults.wasParsed('build-inputs')) {
writeListIfChanged(result.inputFiles, stringArgDeprecated('build-inputs')!); writeListIfChanged(result.inputFiles, stringArg('build-inputs')!);
} }
if (argumentResults.wasParsed('build-outputs')) { if (argumentResults.wasParsed('build-outputs')) {
writeListIfChanged(result.outputFiles, stringArgDeprecated('build-outputs')!); writeListIfChanged(result.outputFiles, stringArg('build-outputs')!);
} }
if (argumentResults.wasParsed('performance-measurement-file')) { if (argumentResults.wasParsed('performance-measurement-file')) {
final File outFile = globals.fs.file(argumentResults['performance-measurement-file']); final File outFile = globals.fs.file(argumentResults['performance-measurement-file']);
writePerformanceData(result.performance.values, outFile); writePerformanceData(result.performance.values, outFile);
} }
if (argumentResults.wasParsed('depfile')) { if (argumentResults.wasParsed('depfile')) {
final File depfileFile = globals.fs.file(stringArgDeprecated('depfile')); final File depfileFile = globals.fs.file(stringArg('depfile'));
final Depfile depfile = Depfile(result.inputFiles, result.outputFiles); final Depfile depfile = Depfile(result.inputFiles, result.outputFiles);
final DepfileService depfileService = DepfileService( final DepfileService depfileService = DepfileService(
fileSystem: globals.fs, fileSystem: globals.fs,
......
...@@ -181,19 +181,20 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -181,19 +181,20 @@ known, it can be explicitly provided to attach via the command-line, e.g.
return null; return null;
} }
try { try {
return int.parse(stringArgDeprecated('debug-port')!); return int.parse(stringArg('debug-port')!);
} on Exception catch (error) { } on Exception catch (error) {
throwToolExit('Invalid port for `--debug-port`: $error'); throwToolExit('Invalid port for `--debug-port`: $error');
} }
} }
Uri? get debugUri { Uri? get debugUri {
if (argResults!['debug-url'] == null) { final String? debugUrl = stringArg('debug-url');
if (debugUrl == null) {
return null; return null;
} }
final Uri? uri = Uri.tryParse(stringArgDeprecated('debug-url')!); final Uri? uri = Uri.tryParse(debugUrl);
if (uri == null) { if (uri == null) {
throwToolExit('Invalid `--debug-url`: ${stringArgDeprecated('debug-url')}'); throwToolExit('Invalid `--debug-url`: $debugUrl');
} }
if (!uri.hasPort) { if (!uri.hasPort) {
throwToolExit('Port not specified for `--debug-url`: $uri'); throwToolExit('Port not specified for `--debug-url`: $uri');
...@@ -201,13 +202,13 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -201,13 +202,13 @@ known, it can be explicitly provided to attach via the command-line, e.g.
return uri; return uri;
} }
bool get serveObservatory => boolArg('serve-observatory') ?? false; bool get serveObservatory => boolArg('serve-observatory');
String? get appId { String? get appId {
return stringArgDeprecated('app-id'); return stringArg('app-id');
} }
String? get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser); String? get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
@override @override
Future<void> validateCommand() async { Future<void> validateCommand() async {
...@@ -268,7 +269,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -268,7 +269,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
Future<void> _attachToDevice(Device device) async { Future<void> _attachToDevice(Device device) async {
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
final Daemon? daemon = boolArgDeprecated('machine') final Daemon? daemon = boolArg('machine')
? Daemon( ? Daemon(
DaemonConnection( DaemonConnection(
daemonStreams: DaemonStreams.fromStdio(_stdio, logger: _logger), daemonStreams: DaemonStreams.fromStdio(_stdio, logger: _logger),
...@@ -290,7 +291,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -290,7 +291,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
if ((debugPort == null && debugUri == null) || isNetworkDevice) { if ((debugPort == null && debugUri == null) || isNetworkDevice) {
if (device is FuchsiaDevice) { if (device is FuchsiaDevice) {
final String? module = stringArgDeprecated('module'); final String? module = stringArg('module');
if (module == null) { if (module == null) {
throwToolExit("'--module' is required for attaching to a Fuchsia device"); throwToolExit("'--module' is required for attaching to a Fuchsia device");
} }
...@@ -428,7 +429,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -428,7 +429,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
appStartedCompleter: appStartedCompleter, appStartedCompleter: appStartedCompleter,
allowExistingDdsInstance: true, allowExistingDdsInstance: true,
enableDevTools: boolArgDeprecated(FlutterCommand.kEnableDevTools), enableDevTools: boolArg(FlutterCommand.kEnableDevTools),
); );
}, },
device, device,
...@@ -460,8 +461,8 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -460,8 +461,8 @@ known, it can be explicitly provided to attach via the command-line, e.g.
terminal: _terminal, terminal: _terminal,
signals: _signals, signals: _signals,
processInfo: _processInfo, processInfo: _processInfo,
reportReady: boolArgDeprecated('report-ready'), reportReady: boolArg('report-ready'),
pidFile: stringArgDeprecated('pid-file'), pidFile: stringArg('pid-file'),
) )
..registerSignalHandlers() ..registerSignalHandlers()
..setupTerminal(); ..setupTerminal();
...@@ -469,7 +470,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -469,7 +470,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
result = await runner.attach( result = await runner.attach(
appStartedCompleter: onAppStart, appStartedCompleter: onAppStart,
allowExistingDdsInstance: true, allowExistingDdsInstance: true,
enableDevTools: boolArgDeprecated(FlutterCommand.kEnableDevTools), enableDevTools: boolArg(FlutterCommand.kEnableDevTools),
); );
if (result != 0) { if (result != 0) {
throwToolExit(null, exitCode: result); throwToolExit(null, exitCode: result);
...@@ -505,7 +506,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -505,7 +506,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
final FlutterDevice flutterDevice = await FlutterDevice.create( final FlutterDevice flutterDevice = await FlutterDevice.create(
device, device,
target: targetFile, target: targetFile,
targetModel: TargetModel(stringArgDeprecated('target-model')!), targetModel: TargetModel(stringArg('target-model')!),
buildInfo: buildInfo, buildInfo: buildInfo,
userIdentifier: userIdentifier, userIdentifier: userIdentifier,
platform: _platform, platform: _platform,
...@@ -526,8 +527,8 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -526,8 +527,8 @@ known, it can be explicitly provided to attach via the command-line, e.g.
target: targetFile, target: targetFile,
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
packagesFilePath: globalResults!['packages'] as String?, packagesFilePath: globalResults!['packages'] as String?,
projectRootPath: stringArgDeprecated('project-root'), projectRootPath: stringArg('project-root'),
dillOutputPath: stringArgDeprecated('output-dill'), dillOutputPath: stringArg('output-dill'),
ipv6: usesIpv6, ipv6: usesIpv6,
flutterProject: flutterProject, flutterProject: flutterProject,
) )
......
...@@ -6,7 +6,6 @@ import '../android/android_builder.dart'; ...@@ -6,7 +6,6 @@ import '../android/android_builder.dart';
import '../android/android_sdk.dart'; import '../android/android_sdk.dart';
import '../android/gradle_utils.dart'; import '../android/gradle_utils.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -113,7 +112,7 @@ class BuildAarCommand extends BuildSubCommand { ...@@ -113,7 +112,7 @@ class BuildAarCommand extends BuildSubCommand {
final Iterable<AndroidArch> targetArchitectures = final Iterable<AndroidArch> targetArchitectures =
stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName); stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName);
final String? buildNumberArg = stringArgDeprecated('build-number'); final String? buildNumberArg = stringArg('build-number');
final String buildNumber = argParser.options.containsKey('build-number') final String buildNumber = argParser.options.containsKey('build-number')
&& buildNumberArg != null && buildNumberArg != null
&& buildNumberArg.isNotEmpty && buildNumberArg.isNotEmpty
...@@ -122,7 +121,7 @@ class BuildAarCommand extends BuildSubCommand { ...@@ -122,7 +121,7 @@ class BuildAarCommand extends BuildSubCommand {
final File targetFile = _fileSystem.file(_fileSystem.path.join('lib', 'main.dart')); final File targetFile = _fileSystem.file(_fileSystem.path.join('lib', 'main.dart'));
for (final String buildMode in const <String>['debug', 'profile', 'release']) { for (final String buildMode in const <String>['debug', 'profile', 'release']) {
if (boolArgDeprecated(buildMode)) { if (boolArg(buildMode)) {
androidBuildInfo.add( androidBuildInfo.add(
AndroidBuildInfo( AndroidBuildInfo(
await getBuildInfo( await getBuildInfo(
......
...@@ -58,9 +58,9 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -58,9 +58,9 @@ class BuildApkCommand extends BuildSubCommand {
final String name = 'apk'; final String name = 'apk';
@override @override
DeprecationBehavior get deprecationBehavior => boolArgDeprecated('ignore-deprecation') ? DeprecationBehavior.ignore : DeprecationBehavior.exit; DeprecationBehavior get deprecationBehavior => boolArg('ignore-deprecation') ? DeprecationBehavior.ignore : DeprecationBehavior.exit;
bool get configOnly => boolArg('config-only') ?? false; bool get configOnly => boolArg('config-only');
@override @override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{ Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
...@@ -80,11 +80,11 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -80,11 +80,11 @@ class BuildApkCommand extends BuildSubCommand {
Future<CustomDimensions> get usageValues async { Future<CustomDimensions> get usageValues async {
String buildMode; String buildMode;
if (boolArgDeprecated('release')) { if (boolArg('release')) {
buildMode = 'release'; buildMode = 'release';
} else if (boolArgDeprecated('debug')) { } else if (boolArg('debug')) {
buildMode = 'debug'; buildMode = 'debug';
} else if (boolArgDeprecated('profile')) { } else if (boolArg('profile')) {
buildMode = 'profile'; buildMode = 'profile';
} else { } else {
// The build defaults to release. // The build defaults to release.
...@@ -94,7 +94,7 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -94,7 +94,7 @@ class BuildApkCommand extends BuildSubCommand {
return CustomDimensions( return CustomDimensions(
commandBuildApkTargetPlatform: stringsArg('target-platform').join(','), commandBuildApkTargetPlatform: stringsArg('target-platform').join(','),
commandBuildApkBuildMode: buildMode, commandBuildApkBuildMode: buildMode,
commandBuildApkSplitPerAbi: boolArgDeprecated('split-per-abi'), commandBuildApkSplitPerAbi: boolArg('split-per-abi'),
); );
} }
...@@ -106,9 +106,9 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -106,9 +106,9 @@ class BuildApkCommand extends BuildSubCommand {
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo( final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo(
buildInfo, buildInfo,
splitPerAbi: boolArgDeprecated('split-per-abi'), splitPerAbi: boolArg('split-per-abi'),
targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName), targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName),
multidexEnabled: boolArgDeprecated('multidex'), multidexEnabled: boolArg('multidex'),
); );
validateBuild(androidBuildInfo); validateBuild(androidBuildInfo);
displayNullSafetyMode(androidBuildInfo.buildInfo); displayNullSafetyMode(androidBuildInfo.buildInfo);
......
...@@ -70,7 +70,7 @@ class BuildAppBundleCommand extends BuildSubCommand { ...@@ -70,7 +70,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
final String name = 'appbundle'; final String name = 'appbundle';
@override @override
DeprecationBehavior get deprecationBehavior => boolArgDeprecated('ignore-deprecation') ? DeprecationBehavior.ignore : DeprecationBehavior.exit; DeprecationBehavior get deprecationBehavior => boolArg('ignore-deprecation') ? DeprecationBehavior.ignore : DeprecationBehavior.exit;
@override @override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{ Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
...@@ -88,11 +88,11 @@ class BuildAppBundleCommand extends BuildSubCommand { ...@@ -88,11 +88,11 @@ class BuildAppBundleCommand extends BuildSubCommand {
Future<CustomDimensions> get usageValues async { Future<CustomDimensions> get usageValues async {
String buildMode; String buildMode;
if (boolArgDeprecated('release')) { if (boolArg('release')) {
buildMode = 'release'; buildMode = 'release';
} else if (boolArgDeprecated('debug')) { } else if (boolArg('debug')) {
buildMode = 'debug'; buildMode = 'debug';
} else if (boolArgDeprecated('profile')) { } else if (boolArg('profile')) {
buildMode = 'profile'; buildMode = 'profile';
} else { } else {
// The build defaults to release. // The build defaults to release.
...@@ -113,12 +113,12 @@ class BuildAppBundleCommand extends BuildSubCommand { ...@@ -113,12 +113,12 @@ class BuildAppBundleCommand extends BuildSubCommand {
final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo(await getBuildInfo(), final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo(await getBuildInfo(),
targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName), targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName),
multidexEnabled: boolArgDeprecated('multidex'), multidexEnabled: boolArg('multidex'),
); );
// Do all setup verification that doesn't involve loading units. Checks that // Do all setup verification that doesn't involve loading units. Checks that
// require generated loading units are done after gen_snapshot in assemble. // require generated loading units are done after gen_snapshot in assemble.
final List<DeferredComponent>? deferredComponents = FlutterProject.current().manifest.deferredComponents; final List<DeferredComponent>? deferredComponents = FlutterProject.current().manifest.deferredComponents;
if (deferredComponents != null && boolArgDeprecated('deferred-components') && boolArgDeprecated('validate-deferred-components') && !boolArgDeprecated('debug')) { if (deferredComponents != null && boolArg('deferred-components') && boolArg('validate-deferred-components') && !boolArg('debug')) {
final DeferredComponentsPrebuildValidator validator = DeferredComponentsPrebuildValidator( final DeferredComponentsPrebuildValidator validator = DeferredComponentsPrebuildValidator(
FlutterProject.current().directory, FlutterProject.current().directory,
globals.logger, globals.logger,
...@@ -154,8 +154,8 @@ class BuildAppBundleCommand extends BuildSubCommand { ...@@ -154,8 +154,8 @@ class BuildAppBundleCommand extends BuildSubCommand {
project: FlutterProject.current(), project: FlutterProject.current(),
target: targetFile, target: targetFile,
androidBuildInfo: androidBuildInfo, androidBuildInfo: androidBuildInfo,
validateDeferredComponents: boolArgDeprecated('validate-deferred-components'), validateDeferredComponents: boolArg('validate-deferred-components'),
deferredComponentsEnabled: boolArgDeprecated('deferred-components') && !boolArgDeprecated('debug'), deferredComponentsEnabled: boolArg('deferred-components') && !boolArg('debug'),
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
......
...@@ -78,14 +78,14 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -78,14 +78,14 @@ class BuildBundleCommand extends BuildSubCommand {
final String projectDir = globals.fs.file(targetFile).parent.parent.path; final String projectDir = globals.fs.file(targetFile).parent.parent.path;
final FlutterProject flutterProject = FlutterProject.fromDirectory(globals.fs.directory(projectDir)); final FlutterProject flutterProject = FlutterProject.fromDirectory(globals.fs.directory(projectDir));
return CustomDimensions( return CustomDimensions(
commandBuildBundleTargetPlatform: stringArgDeprecated('target-platform'), commandBuildBundleTargetPlatform: stringArg('target-platform'),
commandBuildBundleIsModule: flutterProject.isModule, commandBuildBundleIsModule: flutterProject.isModule,
); );
} }
@override @override
Future<void> validateCommand() async { Future<void> validateCommand() async {
if (boolArgDeprecated('tree-shake-icons')) { if (boolArg('tree-shake-icons')) {
throwToolExit('The "--tree-shake-icons" flag is deprecated for "build bundle" and will be removed in a future version of Flutter.'); throwToolExit('The "--tree-shake-icons" flag is deprecated for "build bundle" and will be removed in a future version of Flutter.');
} }
return super.validateCommand(); return super.validateCommand();
...@@ -93,7 +93,7 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -93,7 +93,7 @@ class BuildBundleCommand extends BuildSubCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final String targetPlatform = stringArgDeprecated('target-platform')!; final String targetPlatform = stringArg('target-platform')!;
final TargetPlatform platform = getTargetPlatformForName(targetPlatform); final TargetPlatform platform = getTargetPlatformForName(targetPlatform);
// Check for target platforms that are only allowed via feature flags. // Check for target platforms that are only allowed via feature flags.
switch (platform) { switch (platform) {
...@@ -133,8 +133,8 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -133,8 +133,8 @@ class BuildBundleCommand extends BuildSubCommand {
platform: platform, platform: platform,
buildInfo: buildInfo, buildInfo: buildInfo,
mainPath: targetFile, mainPath: targetFile,
depfilePath: stringArgDeprecated('depfile'), depfilePath: stringArg('depfile'),
assetDirPath: stringArgDeprecated('asset-dir'), assetDirPath: stringArg('asset-dir'),
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
......
...@@ -49,10 +49,10 @@ class BuildIOSCommand extends _BuildIOSSubCommand { ...@@ -49,10 +49,10 @@ class BuildIOSCommand extends _BuildIOSSubCommand {
final XcodeBuildAction xcodeBuildAction = XcodeBuildAction.build; final XcodeBuildAction xcodeBuildAction = XcodeBuildAction.build;
@override @override
EnvironmentType get environmentType => boolArgDeprecated('simulator') ? EnvironmentType.simulator : EnvironmentType.physical; EnvironmentType get environmentType => boolArg('simulator') ? EnvironmentType.simulator : EnvironmentType.physical;
@override @override
bool get configOnly => boolArgDeprecated('config-only'); bool get configOnly => boolArg('config-only');
@override @override
Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs.directory(xcodeResultOutput).parent; Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs.directory(xcodeResultOutput).parent;
...@@ -131,7 +131,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand { ...@@ -131,7 +131,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
@override @override
final bool configOnly = false; final bool configOnly = false;
String? get exportOptionsPlist => stringArgDeprecated('export-options-plist'); String? get exportOptionsPlist => stringArg('export-options-plist');
@override @override
Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs
...@@ -455,7 +455,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand { ...@@ -455,7 +455,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
final String relativeOutputPath = app.ipaOutputPath; final String relativeOutputPath = app.ipaOutputPath;
final String absoluteOutputPath = globals.fs.path.absolute(relativeOutputPath); final String absoluteOutputPath = globals.fs.path.absolute(relativeOutputPath);
final String absoluteArchivePath = globals.fs.path.absolute(app.archiveBundleOutputPath); final String absoluteArchivePath = globals.fs.path.absolute(app.archiveBundleOutputPath);
final String exportMethod = stringArgDeprecated('export-method')!; final String exportMethod = stringArg('export-method')!;
final bool isAppStoreUpload = exportMethod == 'app-store'; final bool isAppStoreUpload = exportMethod == 'app-store';
File? generatedExportPlist; File? generatedExportPlist;
try { try {
...@@ -540,7 +540,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand { ...@@ -540,7 +540,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>method</key> <key>method</key>
<string>${stringArgDeprecated('export-method')}</string> <string>${stringArg('export-method')}</string>
<key>uploadBitcode</key> <key>uploadBitcode</key>
<false/> <false/>
</dict> </dict>
...@@ -596,7 +596,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { ...@@ -596,7 +596,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
EnvironmentType get environmentType; EnvironmentType get environmentType;
bool get configOnly; bool get configOnly;
bool get shouldCodesign => boolArgDeprecated('codesign'); bool get shouldCodesign => boolArg('codesign');
late final Future<BuildInfo> cachedBuildInfo = getBuildInfo(); late final Future<BuildInfo> cachedBuildInfo = getBuildInfo();
......
...@@ -109,13 +109,13 @@ abstract class BuildFrameworkCommand extends BuildSubCommand { ...@@ -109,13 +109,13 @@ abstract class BuildFrameworkCommand extends BuildSubCommand {
Future<List<BuildInfo>> getBuildInfos() async { Future<List<BuildInfo>> getBuildInfos() async {
final List<BuildInfo> buildInfos = <BuildInfo>[]; final List<BuildInfo> buildInfos = <BuildInfo>[];
if (boolArgDeprecated('debug')) { if (boolArg('debug')) {
buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.debug)); buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.debug));
} }
if (boolArgDeprecated('profile')) { if (boolArg('profile')) {
buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.profile)); buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.profile));
} }
if (boolArgDeprecated('release')) { if (boolArg('release')) {
buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.release)); buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.release));
} }
...@@ -216,14 +216,14 @@ class BuildIOSFrameworkCommand extends BuildFrameworkCommand { ...@@ -216,14 +216,14 @@ class BuildIOSFrameworkCommand extends BuildFrameworkCommand {
Future<void> validateCommand() async { Future<void> validateCommand() async {
await super.validateCommand(); await super.validateCommand();
if (boolArgDeprecated('universal')) { if (boolArg('universal')) {
throwToolExit('--universal has been deprecated, only XCFrameworks are supported.'); throwToolExit('--universal has been deprecated, only XCFrameworks are supported.');
} }
} }
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final String outputArgument = stringArgDeprecated('output') final String outputArgument = stringArg('output')
?? globals.fs.path.join(globals.fs.currentDirectory.path, 'build', 'ios', 'framework'); ?? globals.fs.path.join(globals.fs.currentDirectory.path, 'build', 'ios', 'framework');
if (outputArgument.isEmpty) { if (outputArgument.isEmpty) {
...@@ -247,8 +247,8 @@ class BuildIOSFrameworkCommand extends BuildFrameworkCommand { ...@@ -247,8 +247,8 @@ class BuildIOSFrameworkCommand extends BuildFrameworkCommand {
modeDirectory.deleteSync(recursive: true); modeDirectory.deleteSync(recursive: true);
} }
if (boolArgDeprecated('cocoapods')) { if (boolArg('cocoapods')) {
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArgDeprecated('force')); produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force'));
} else { } else {
// Copy Flutter.xcframework. // Copy Flutter.xcframework.
await _produceFlutterFramework(buildInfo, modeDirectory); await _produceFlutterFramework(buildInfo, modeDirectory);
...@@ -496,7 +496,7 @@ end ...@@ -496,7 +496,7 @@ end
'SYMROOT=${iPhoneBuildOutput.path}', 'SYMROOT=${iPhoneBuildOutput.path}',
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures. 'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
if (boolArg('static') ?? false) if (boolArg('static'))
'MACH_O_TYPE=staticlib', 'MACH_O_TYPE=staticlib',
]; ];
...@@ -522,7 +522,7 @@ end ...@@ -522,7 +522,7 @@ end
'SYMROOT=${simulatorBuildOutput.path}', 'SYMROOT=${simulatorBuildOutput.path}',
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures. 'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
if (boolArg('static') ?? false) if (boolArg('static'))
'MACH_O_TYPE=staticlib', 'MACH_O_TYPE=staticlib',
]; ];
......
...@@ -60,7 +60,7 @@ class BuildLinuxCommand extends BuildSubCommand { ...@@ -60,7 +60,7 @@ class BuildLinuxCommand extends BuildSubCommand {
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
final TargetPlatform targetPlatform = final TargetPlatform targetPlatform =
getTargetPlatformForName(stringArgDeprecated('target-platform')!); getTargetPlatformForName(stringArg('target-platform')!);
final bool needCrossBuild = final bool needCrossBuild =
getNameForHostPlatformArch(_operatingSystemUtils.hostPlatform) getNameForHostPlatformArch(_operatingSystemUtils.hostPlatform)
!= getNameForTargetPlatformArch(targetPlatform); != getNameForTargetPlatformArch(targetPlatform);
...@@ -94,7 +94,7 @@ class BuildLinuxCommand extends BuildSubCommand { ...@@ -94,7 +94,7 @@ class BuildLinuxCommand extends BuildSubCommand {
), ),
needCrossBuild: needCrossBuild, needCrossBuild: needCrossBuild,
targetPlatform: targetPlatform, targetPlatform: targetPlatform,
targetSysroot: stringArgDeprecated('target-sysroot')!, targetSysroot: stringArg('target-sysroot')!,
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
......
...@@ -46,7 +46,7 @@ class BuildMacosCommand extends BuildSubCommand { ...@@ -46,7 +46,7 @@ class BuildMacosCommand extends BuildSubCommand {
@override @override
bool get supported => globals.platform.isMacOS; bool get supported => globals.platform.isMacOS;
bool get configOnly => boolArgDeprecated('config-only'); bool get configOnly => boolArg('config-only');
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
......
...@@ -80,8 +80,8 @@ class BuildMacOSFrameworkCommand extends BuildFrameworkCommand { ...@@ -80,8 +80,8 @@ class BuildMacOSFrameworkCommand extends BuildFrameworkCommand {
modeDirectory.deleteSync(recursive: true); modeDirectory.deleteSync(recursive: true);
} }
if (boolArg('cocoapods') ?? false) { if (boolArg('cocoapods')) {
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force') ?? false); produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force'));
} }
// Build aot, create App.framework and copy FlutterMacOS.framework. Make XCFrameworks. // Build aot, create App.framework and copy FlutterMacOS.framework. Make XCFrameworks.
...@@ -240,7 +240,7 @@ end ...@@ -240,7 +240,7 @@ end
final Directory flutterFramework = outputBuildDirectory.childDirectory('FlutterMacOS.framework'); final Directory flutterFramework = outputBuildDirectory.childDirectory('FlutterMacOS.framework');
// If FlutterMacOS.podspec was generated, do not generate XCFramework. // If FlutterMacOS.podspec was generated, do not generate XCFramework.
if (!(boolArg('cocoapods') ?? false)) { if (!boolArg('cocoapods')) {
await BuildFrameworkCommand.produceXCFramework( await BuildFrameworkCommand.produceXCFramework(
<Directory>[flutterFramework], <Directory>[flutterFramework],
'FlutterMacOS', 'FlutterMacOS',
...@@ -269,7 +269,7 @@ end ...@@ -269,7 +269,7 @@ end
'SYMROOT=${buildOutput.path}', 'SYMROOT=${buildOutput.path}',
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures. 'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
if (boolArg('static') ?? false) 'MACH_O_TYPE=staticlib', if (boolArg('static')) 'MACH_O_TYPE=staticlib',
]; ];
final RunResult buildPluginsResult = await globals.processUtils.run( final RunResult buildPluginsResult = await globals.processUtils.run(
......
...@@ -132,18 +132,18 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -132,18 +132,18 @@ class BuildWebCommand extends BuildSubCommand {
throwToolExit('"build web" is not currently supported. To enable, run "flutter config --enable-web".'); throwToolExit('"build web" is not currently supported. To enable, run "flutter config --enable-web".');
} }
final bool wasmRequested = boolArg('wasm')!; final bool wasmRequested = boolArg('wasm');
if (wasmRequested && !featureFlags.isFlutterWebWasmEnabled) { if (wasmRequested && !featureFlags.isFlutterWebWasmEnabled) {
throwToolExit('Compiling to WebAssembly (wasm) is only available on the master channel.'); throwToolExit('Compiling to WebAssembly (wasm) is only available on the master channel.');
} }
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
final String target = stringArgDeprecated('target')!; final String target = stringArg('target')!;
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
if (buildInfo.isDebug) { if (buildInfo.isDebug) {
throwToolExit('debug builds cannot be built directly for the web. Try using "flutter run"'); throwToolExit('debug builds cannot be built directly for the web. Try using "flutter run"');
} }
final String? baseHref = stringArgDeprecated('base-href'); final String? baseHref = stringArg('base-href');
if (baseHref != null && !(baseHref.startsWith('/') && baseHref.endsWith('/'))) { if (baseHref != null && !(baseHref.startsWith('/') && baseHref.endsWith('/'))) {
throwToolExit('base-href should start and end with /'); throwToolExit('base-href should start and end with /');
} }
...@@ -171,16 +171,16 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -171,16 +171,16 @@ class BuildWebCommand extends BuildSubCommand {
flutterProject, flutterProject,
target, target,
buildInfo, buildInfo,
boolArgDeprecated('csp'), boolArg('csp'),
stringArgDeprecated('pwa-strategy')!, stringArg('pwa-strategy')!,
boolArgDeprecated('source-maps'), boolArg('source-maps'),
boolArgDeprecated('native-null-assertions'), boolArg('native-null-assertions'),
wasmRequested, wasmRequested,
baseHref: baseHref, baseHref: baseHref,
dart2jsOptimization: stringArgDeprecated('dart2js-optimization') ?? kDart2jsDefaultOptimizationLevel, dart2jsOptimization: stringArg('dart2js-optimization') ?? kDart2jsDefaultOptimizationLevel,
outputDirectoryPath: outputDirectoryPath, outputDirectoryPath: outputDirectoryPath,
dumpInfo: boolArgDeprecated('dump-info'), dumpInfo: boolArg('dump-info'),
noFrequencyBasedMinification: boolArgDeprecated('no-frequency-based-minification'), noFrequencyBasedMinification: boolArg('no-frequency-based-minification'),
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
......
...@@ -39,7 +39,7 @@ class ChannelCommand extends FlutterCommand { ...@@ -39,7 +39,7 @@ class ChannelCommand extends FlutterCommand {
switch (rest.length) { switch (rest.length) {
case 0: case 0:
await _listChannels( await _listChannels(
showAll: boolArgDeprecated('all'), showAll: boolArg('all'),
verbose: globalResults?['verbose'] == true, verbose: globalResults?['verbose'] == true,
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
......
...@@ -111,12 +111,12 @@ class ConfigCommand extends FlutterCommand { ...@@ -111,12 +111,12 @@ class ConfigCommand extends FlutterCommand {
' flutter config --android-studio-dir "/opt/Android Studio"'); ' flutter config --android-studio-dir "/opt/Android Studio"');
} }
if (boolArgDeprecated('machine')) { if (boolArg('machine')) {
await handleMachine(); await handleMachine();
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
if (boolArgDeprecated('clear-features')) { if (boolArg('clear-features')) {
for (final Feature feature in allFeatures) { for (final Feature feature in allFeatures) {
final String? configSetting = feature.configSetting; final String? configSetting = feature.configSetting;
if (configSetting != null) { if (configSetting != null) {
...@@ -127,7 +127,7 @@ class ConfigCommand extends FlutterCommand { ...@@ -127,7 +127,7 @@ class ConfigCommand extends FlutterCommand {
} }
if (argResults?.wasParsed('analytics') ?? false) { if (argResults?.wasParsed('analytics') ?? false) {
final bool value = boolArgDeprecated('analytics'); final bool value = boolArg('analytics');
// The tool sends the analytics event *before* toggling the flag // The tool sends the analytics event *before* toggling the flag
// intentionally to be sure that opt-out events are sent correctly. // intentionally to be sure that opt-out events are sent correctly.
AnalyticsConfigEvent(enabled: value).send(); AnalyticsConfigEvent(enabled: value).send();
...@@ -142,11 +142,11 @@ class ConfigCommand extends FlutterCommand { ...@@ -142,11 +142,11 @@ class ConfigCommand extends FlutterCommand {
} }
if (argResults?.wasParsed('android-sdk') ?? false) { if (argResults?.wasParsed('android-sdk') ?? false) {
_updateConfig('android-sdk', stringArgDeprecated('android-sdk')!); _updateConfig('android-sdk', stringArg('android-sdk')!);
} }
if (argResults?.wasParsed('android-studio-dir') ?? false) { if (argResults?.wasParsed('android-studio-dir') ?? false) {
_updateConfig('android-studio-dir', stringArgDeprecated('android-studio-dir')!); _updateConfig('android-studio-dir', stringArg('android-studio-dir')!);
} }
if (argResults?.wasParsed('clear-ios-signing-cert') ?? false) { if (argResults?.wasParsed('clear-ios-signing-cert') ?? false) {
...@@ -154,7 +154,7 @@ class ConfigCommand extends FlutterCommand { ...@@ -154,7 +154,7 @@ class ConfigCommand extends FlutterCommand {
} }
if (argResults?.wasParsed('build-dir') ?? false) { if (argResults?.wasParsed('build-dir') ?? false) {
final String buildDir = stringArgDeprecated('build-dir')!; final String buildDir = stringArg('build-dir')!;
if (globals.fs.path.isAbsolute(buildDir)) { if (globals.fs.path.isAbsolute(buildDir)) {
throwToolExit('build-dir should be a relative path'); throwToolExit('build-dir should be a relative path');
} }
...@@ -167,7 +167,7 @@ class ConfigCommand extends FlutterCommand { ...@@ -167,7 +167,7 @@ class ConfigCommand extends FlutterCommand {
continue; continue;
} }
if (argResults?.wasParsed(configSetting) ?? false) { if (argResults?.wasParsed(configSetting) ?? false) {
final bool keyValue = boolArgDeprecated(configSetting); final bool keyValue = boolArg(configSetting);
globals.config.setValue(configSetting, keyValue); globals.config.setValue(configSetting, keyValue);
globals.printStatus('Setting "$configSetting" value to "$keyValue".'); globals.printStatus('Setting "$configSetting" value to "$keyValue".');
} }
......
...@@ -95,9 +95,9 @@ class CreateCommand extends CreateBase { ...@@ -95,9 +95,9 @@ class CreateCommand extends CreateBase {
@override @override
Future<CustomDimensions> get usageValues async { Future<CustomDimensions> get usageValues async {
return CustomDimensions( return CustomDimensions(
commandCreateProjectType: stringArgDeprecated('template'), commandCreateProjectType: stringArg('template'),
commandCreateAndroidLanguage: stringArgDeprecated('android-language'), commandCreateAndroidLanguage: stringArg('android-language'),
commandCreateIosLanguage: stringArgDeprecated('ios-language'), commandCreateIosLanguage: stringArg('ios-language'),
); );
} }
...@@ -207,7 +207,7 @@ class CreateCommand extends CreateBase { ...@@ -207,7 +207,7 @@ class CreateCommand extends CreateBase {
validateOutputDirectoryArg(); validateOutputDirectoryArg();
String? sampleCode; String? sampleCode;
final String? sampleArgument = stringArg('sample'); final String? sampleArgument = stringArg('sample');
final bool emptyArgument = boolArg('empty') ?? false; final bool emptyArgument = boolArg('empty');
if (sampleArgument != null) { if (sampleArgument != null) {
final String? templateArgument = stringArg('template'); final String? templateArgument = stringArg('template');
if (templateArgument != null && stringToProjectType(templateArgument) != FlutterProjectType.app) { if (templateArgument != null && stringToProjectType(templateArgument) != FlutterProjectType.app) {
...@@ -256,10 +256,10 @@ class CreateCommand extends CreateBase { ...@@ -256,10 +256,10 @@ class CreateCommand extends CreateBase {
final String organization = await getOrganization(); final String organization = await getOrganization();
final bool overwrite = boolArgDeprecated('overwrite'); final bool overwrite = boolArg('overwrite');
validateProjectDir(overwrite: overwrite); validateProjectDir(overwrite: overwrite);
if (boolArgDeprecated('with-driver-test')) { if (boolArg('with-driver-test')) {
globals.printWarning( globals.printWarning(
'The "--with-driver-test" argument has been deprecated and will no longer add a flutter ' 'The "--with-driver-test" argument has been deprecated and will no longer add a flutter '
'driver template. Instead, learn how to use package:integration_test by ' 'driver template. Instead, learn how to use package:integration_test by '
...@@ -309,13 +309,13 @@ class CreateCommand extends CreateBase { ...@@ -309,13 +309,13 @@ class CreateCommand extends CreateBase {
organization: organization, organization: organization,
projectName: projectName, projectName: projectName,
titleCaseProjectName: titleCaseProjectName, titleCaseProjectName: titleCaseProjectName,
projectDescription: stringArgDeprecated('description'), projectDescription: stringArg('description'),
flutterRoot: flutterRoot, flutterRoot: flutterRoot,
withPlatformChannelPluginHook: generateMethodChannelsPlugin, withPlatformChannelPluginHook: generateMethodChannelsPlugin,
withFfiPluginHook: generateFfiPlugin, withFfiPluginHook: generateFfiPlugin,
withEmptyMain: emptyArgument, withEmptyMain: emptyArgument,
androidLanguage: stringArgDeprecated('android-language'), androidLanguage: stringArg('android-language'),
iosLanguage: stringArgDeprecated('ios-language'), iosLanguage: stringArg('ios-language'),
iosDevelopmentTeam: developmentTeam, iosDevelopmentTeam: developmentTeam,
ios: includeIos, ios: includeIos,
android: includeAndroid, android: includeAndroid,
...@@ -324,7 +324,7 @@ class CreateCommand extends CreateBase { ...@@ -324,7 +324,7 @@ class CreateCommand extends CreateBase {
macos: includeMacos, macos: includeMacos,
windows: includeWindows, windows: includeWindows,
dartSdkVersionBounds: "'>=$dartSdk <4.0.0'", dartSdkVersionBounds: "'>=$dartSdk <4.0.0'",
implementationTests: boolArgDeprecated('implementation-tests'), implementationTests: boolArg('implementation-tests'),
agpVersion: gradle.templateAndroidGradlePluginVersion, agpVersion: gradle.templateAndroidGradlePluginVersion,
kotlinVersion: gradle.templateKotlinGradlePluginVersion, kotlinVersion: gradle.templateKotlinGradlePluginVersion,
gradleVersion: gradle.templateDefaultGradleVersion, gradleVersion: gradle.templateDefaultGradleVersion,
...@@ -408,12 +408,12 @@ class CreateCommand extends CreateBase { ...@@ -408,12 +408,12 @@ class CreateCommand extends CreateBase {
break; break;
} }
if (boolArgDeprecated('pub')) { if (boolArg('pub')) {
final FlutterProject project = FlutterProject.fromDirectory(relativeDir); final FlutterProject project = FlutterProject.fromDirectory(relativeDir);
await pub.get( await pub.get(
context: pubContext, context: pubContext,
project: project, project: project,
offline: boolArgDeprecated('offline'), offline: boolArg('offline'),
outputMode: PubOutputMode.summaryOnly, outputMode: PubOutputMode.summaryOnly,
); );
await project.ensureReadyForPlatformSpecificTooling( await project.ensureReadyForPlatformSpecificTooling(
...@@ -505,7 +505,7 @@ Your $application code is in $relativeAppMain. ...@@ -505,7 +505,7 @@ Your $application code is in $relativeAppMain.
}) async { }) async {
int generatedCount = 0; int generatedCount = 0;
final String? description = argResults!.wasParsed('description') final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description') ? stringArg('description')
: 'A new Flutter module project.'; : 'A new Flutter module project.';
templateContext['description'] = description; templateContext['description'] = description;
generatedCount += await renderTemplate( generatedCount += await renderTemplate(
...@@ -526,7 +526,7 @@ Your $application code is in $relativeAppMain. ...@@ -526,7 +526,7 @@ Your $application code is in $relativeAppMain.
}) async { }) async {
int generatedCount = 0; int generatedCount = 0;
final String? description = argResults!.wasParsed('description') final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description') ? stringArg('description')
: 'A new Flutter package project.'; : 'A new Flutter package project.';
templateContext['description'] = description; templateContext['description'] = description;
generatedCount += await renderTemplate( generatedCount += await renderTemplate(
...@@ -564,7 +564,7 @@ Your $application code is in $relativeAppMain. ...@@ -564,7 +564,7 @@ Your $application code is in $relativeAppMain.
templateContext['no_platforms'] = !willAddPlatforms; templateContext['no_platforms'] = !willAddPlatforms;
int generatedCount = 0; int generatedCount = 0;
final String? description = argResults!.wasParsed('description') final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description') ? stringArg('description')
: 'A new Flutter plugin project.'; : 'A new Flutter plugin project.';
templateContext['description'] = description; templateContext['description'] = description;
generatedCount += await renderMerged( generatedCount += await renderMerged(
...@@ -634,7 +634,7 @@ Your $application code is in $relativeAppMain. ...@@ -634,7 +634,7 @@ Your $application code is in $relativeAppMain.
templateContext['no_platforms'] = !willAddPlatforms; templateContext['no_platforms'] = !willAddPlatforms;
int generatedCount = 0; int generatedCount = 0;
final String? description = argResults!.wasParsed('description') final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description') ? stringArg('description')
: 'A new Flutter FFI plugin project.'; : 'A new Flutter FFI plugin project.';
templateContext['description'] = description; templateContext['description'] = description;
generatedCount += await renderMerged( generatedCount += await renderMerged(
......
...@@ -253,7 +253,7 @@ abstract class CreateBase extends FlutterCommand { ...@@ -253,7 +253,7 @@ abstract class CreateBase extends FlutterCommand {
/// If `--org` is not specified, returns the organization from the existing project. /// If `--org` is not specified, returns the organization from the existing project.
@protected @protected
Future<String> getOrganization() async { Future<String> getOrganization() async {
String? organization = stringArgDeprecated('org'); String? organization = stringArg('org');
if (!argResults!.wasParsed('org')) { if (!argResults!.wasParsed('org')) {
final FlutterProject project = FlutterProject.fromDirectory(projectDir); final FlutterProject project = FlutterProject.fromDirectory(projectDir);
final Set<String> existingOrganizations = await project.organizationNames; final Set<String> existingOrganizations = await project.organizationNames;
...@@ -326,8 +326,8 @@ abstract class CreateBase extends FlutterCommand { ...@@ -326,8 +326,8 @@ abstract class CreateBase extends FlutterCommand {
@protected @protected
String get projectName { String get projectName {
final String projectName = final String projectName =
stringArgDeprecated('project-name') ?? globals.fs.path.basename(projectDirPath); stringArg('project-name') ?? globals.fs.path.basename(projectDirPath);
if (!boolArgDeprecated('skip-name-checks')) { if (!boolArg('skip-name-checks')) {
final String? error = _validateProjectName(projectName); final String? error = _validateProjectName(projectName);
if (error != null) { if (error != null) {
throwToolExit(error); throwToolExit(error);
...@@ -527,7 +527,7 @@ abstract class CreateBase extends FlutterCommand { ...@@ -527,7 +527,7 @@ abstract class CreateBase extends FlutterCommand {
final bool windowsPlatform = templateContext['windows'] as bool? ?? false; final bool windowsPlatform = templateContext['windows'] as bool? ?? false;
final bool webPlatform = templateContext['web'] as bool? ?? false; final bool webPlatform = templateContext['web'] as bool? ?? false;
if (boolArgDeprecated('pub')) { if (boolArg('pub')) {
final Environment environment = Environment( final Environment environment = Environment(
artifacts: globals.artifacts!, artifacts: globals.artifacts!,
logger: globals.logger, logger: globals.logger,
...@@ -587,7 +587,7 @@ abstract class CreateBase extends FlutterCommand { ...@@ -587,7 +587,7 @@ abstract class CreateBase extends FlutterCommand {
platforms: platformsForMigrateConfig, platforms: platformsForMigrateConfig,
projectDirectory: directory, projectDirectory: directory,
update: false, update: false,
currentRevision: stringArgDeprecated('initial-create-revision') ?? globals.flutterVersion.frameworkRevision, currentRevision: stringArg('initial-create-revision') ?? globals.flutterVersion.frameworkRevision,
createRevision: globals.flutterVersion.frameworkRevision, createRevision: globals.flutterVersion.frameworkRevision,
logger: globals.logger, logger: globals.logger,
); );
......
...@@ -461,8 +461,8 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -461,8 +461,8 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
/// ///
/// Only check if `--check` is explicitly specified. (Don't check by default) /// Only check if `--check` is explicitly specified. (Don't check by default)
Future<FlutterCommandResult> runNonInteractively() async { Future<FlutterCommandResult> runNonInteractively() async {
final String jsonStr = stringArgDeprecated(_kJson)!; final String jsonStr = stringArg(_kJson)!;
final bool shouldCheck = boolArgDeprecated(_kCheck); final bool shouldCheck = boolArg(_kCheck);
dynamic json; dynamic json;
try { try {
...@@ -570,7 +570,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -570,7 +570,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
/// Run interactively (with user prompts), the target device should be /// Run interactively (with user prompts), the target device should be
/// connected to via ssh. /// connected to via ssh.
Future<FlutterCommandResult> runInteractivelySsh() async { Future<FlutterCommandResult> runInteractivelySsh() async {
final bool shouldCheck = boolArgDeprecated(_kCheck); final bool shouldCheck = boolArg(_kCheck);
// Listen to the keystrokes stream as late as possible, since it's a // Listen to the keystrokes stream as late as possible, since it's a
// single-subscription stream apparently. // single-subscription stream apparently.
...@@ -781,10 +781,10 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -781,10 +781,10 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
checkFeatureEnabled(); checkFeatureEnabled();
if (stringArgDeprecated(_kJson) != null) { if (stringArg(_kJson) != null) {
return runNonInteractively(); return runNonInteractively();
} }
if (boolArgDeprecated(_kSsh) == true) { if (boolArg(_kSsh) == true) {
return runInteractivelySsh(); return runInteractivelySsh();
} }
throw UnsupportedError('Unknown run mode'); throw UnsupportedError('Unknown run mode');
......
...@@ -67,7 +67,7 @@ class DaemonCommand extends FlutterCommand { ...@@ -67,7 +67,7 @@ class DaemonCommand extends FlutterCommand {
if (argResults!['listen-on-tcp-port'] != null) { if (argResults!['listen-on-tcp-port'] != null) {
int? port; int? port;
try { try {
port = int.parse(stringArgDeprecated('listen-on-tcp-port')!); port = int.parse(stringArg('listen-on-tcp-port')!);
} on FormatException catch (error) { } on FormatException catch (error) {
throwToolExit('Invalid port for `--listen-on-tcp-port`: $error'); throwToolExit('Invalid port for `--listen-on-tcp-port`: $error');
} }
......
...@@ -58,7 +58,7 @@ class DebugAdapterCommand extends FlutterCommand { ...@@ -58,7 +58,7 @@ class DebugAdapterCommand extends FlutterCommand {
platform: globals.platform, platform: globals.platform,
ipv6: ipv6 ?? false, ipv6: ipv6 ?? false,
enableDds: enableDds, enableDds: enableDds,
test: boolArgDeprecated('test'), test: boolArg('test'),
onError: (Object? e) { onError: (Object? e) {
globals.printError( globals.printError(
'Input could not be parsed as a Debug Adapter Protocol message.\n' 'Input could not be parsed as a Debug Adapter Protocol message.\n'
......
...@@ -36,7 +36,7 @@ class DevicesCommand extends FlutterCommand { ...@@ -36,7 +36,7 @@ class DevicesCommand extends FlutterCommand {
@override @override
Duration? get deviceDiscoveryTimeout { Duration? get deviceDiscoveryTimeout {
if (argResults?['timeout'] != null) { if (argResults?['timeout'] != null) {
final int? timeoutSeconds = int.tryParse(stringArgDeprecated('timeout')!); final int? timeoutSeconds = int.tryParse(stringArg('timeout')!);
if (timeoutSeconds == null) { if (timeoutSeconds == null) {
throwToolExit('Could not parse -t/--timeout argument. It must be an integer.'); throwToolExit('Could not parse -t/--timeout argument. It must be an integer.');
} }
...@@ -67,7 +67,7 @@ class DevicesCommand extends FlutterCommand { ...@@ -67,7 +67,7 @@ class DevicesCommand extends FlutterCommand {
); );
await output.findAndOutputAllTargetDevices( await output.findAndOutputAllTargetDevices(
machine: boolArgDeprecated('machine'), machine: boolArg('machine'),
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
......
...@@ -35,7 +35,7 @@ class DoctorCommand extends FlutterCommand { ...@@ -35,7 +35,7 @@ class DoctorCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
globals.flutterVersion.fetchTagsAndUpdate(); globals.flutterVersion.fetchTagsAndUpdate();
if (argResults?.wasParsed('check-for-remote-artifacts') ?? false) { if (argResults?.wasParsed('check-for-remote-artifacts') ?? false) {
final String engineRevision = stringArgDeprecated('check-for-remote-artifacts')!; final String engineRevision = stringArg('check-for-remote-artifacts')!;
if (engineRevision.startsWith(RegExp(r'[a-f0-9]{1,40}'))) { if (engineRevision.startsWith(RegExp(r'[a-f0-9]{1,40}'))) {
final bool success = await globals.doctor?.checkRemoteArtifacts(engineRevision) ?? false; final bool success = await globals.doctor?.checkRemoteArtifacts(engineRevision) ?? false;
if (success) { if (success) {
...@@ -48,7 +48,7 @@ class DoctorCommand extends FlutterCommand { ...@@ -48,7 +48,7 @@ class DoctorCommand extends FlutterCommand {
} }
} }
final bool success = await globals.doctor?.diagnose( final bool success = await globals.doctor?.diagnose(
androidLicenses: boolArgDeprecated('android-licenses'), androidLicenses: boolArg('android-licenses'),
verbose: verbose, verbose: verbose,
androidLicenseValidator: androidLicenseValidator, androidLicenseValidator: androidLicenseValidator,
) ?? false; ) ?? false;
......
...@@ -91,7 +91,7 @@ class DowngradeCommand extends FlutterCommand { ...@@ -91,7 +91,7 @@ class DowngradeCommand extends FlutterCommand {
_fileSystem ??= globals.fs; _fileSystem ??= globals.fs;
String workingDirectory = Cache.flutterRoot!; String workingDirectory = Cache.flutterRoot!;
if (argResults!.wasParsed('working-directory')) { if (argResults!.wasParsed('working-directory')) {
workingDirectory = stringArgDeprecated('working-directory')!; workingDirectory = stringArg('working-directory')!;
_flutterVersion = FlutterVersion(workingDirectory: workingDirectory); _flutterVersion = FlutterVersion(workingDirectory: workingDirectory);
} }
...@@ -127,7 +127,7 @@ class DowngradeCommand extends FlutterCommand { ...@@ -127,7 +127,7 @@ class DowngradeCommand extends FlutterCommand {
// If there is a terminal attached, prompt the user to confirm the downgrade. // If there is a terminal attached, prompt the user to confirm the downgrade.
final Stdio stdio = _stdio!; final Stdio stdio = _stdio!;
final Terminal terminal = _terminal!; final Terminal terminal = _terminal!;
if (stdio.hasTerminal && boolArgDeprecated('prompt')) { if (stdio.hasTerminal && boolArg('prompt')) {
terminal.usesTerminalUi = true; terminal.usesTerminalUi = true;
final String result = await terminal.promptForCharInput( final String result = await terminal.promptForCharInput(
const <String>['y', 'n'], const <String>['y', 'n'],
......
...@@ -73,7 +73,6 @@ class DriveCommand extends RunCommandBase { ...@@ -73,7 +73,6 @@ class DriveCommand extends RunCommandBase {
addMultidexOption(); addMultidexOption();
argParser argParser
..addFlag('keep-app-running', ..addFlag('keep-app-running',
defaultsTo: null,
help: 'Will keep the Flutter application running when done testing.\n' help: 'Will keep the Flutter application running when done testing.\n'
'By default, "flutter drive" stops the application after tests are finished, ' 'By default, "flutter drive" stops the application after tests are finished, '
'and "--keep-app-running" overrides this. On the other hand, if "--use-existing-app" ' 'and "--keep-app-running" overrides this. On the other hand, if "--use-existing-app" '
...@@ -171,7 +170,7 @@ class DriveCommand extends RunCommandBase { ...@@ -171,7 +170,7 @@ class DriveCommand extends RunCommandBase {
// specified not to. // specified not to.
@override @override
bool get shouldRunPub { bool get shouldRunPub {
if (argResults!.wasParsed('pub') && !boolArgDeprecated('pub')) { if (argResults!.wasParsed('pub') && !boolArg('pub')) {
return false; return false;
} }
return true; return true;
...@@ -196,9 +195,9 @@ class DriveCommand extends RunCommandBase { ...@@ -196,9 +195,9 @@ class DriveCommand extends RunCommandBase {
@override @override
final List<String> aliases = <String>['driver']; final List<String> aliases = <String>['driver'];
String? get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser); String? get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
String? get screenshot => stringArgDeprecated('screenshot'); String? get screenshot => stringArg('screenshot');
@override @override
bool get startPausedDefault => true; bool get startPausedDefault => true;
...@@ -206,7 +205,7 @@ class DriveCommand extends RunCommandBase { ...@@ -206,7 +205,7 @@ class DriveCommand extends RunCommandBase {
@override @override
bool get cachePubGet => false; bool get cachePubGet => false;
String? get applicationBinaryPath => stringArgDeprecated(FlutterOptions.kUseApplicationBinary); String? get applicationBinaryPath => stringArg(FlutterOptions.kUseApplicationBinary);
Future<Device?> get targetedDevice async { Future<Device?> get targetedDevice async {
return findTargetDevice( return findTargetDevice(
...@@ -226,7 +225,7 @@ class DriveCommand extends RunCommandBase { ...@@ -226,7 +225,7 @@ class DriveCommand extends RunCommandBase {
_logger.printTrace('Network device is being used. Changing `publish-port` to be enabled.'); _logger.printTrace('Network device is being used. Changing `publish-port` to be enabled.');
return false; return false;
} }
return !boolArgDeprecated('publish-port'); return !boolArg('publish-port');
} }
@override @override
...@@ -279,7 +278,7 @@ class DriveCommand extends RunCommandBase { ...@@ -279,7 +278,7 @@ class DriveCommand extends RunCommandBase {
bool screenshotTaken = false; bool screenshotTaken = false;
try { try {
if (stringArgDeprecated('use-existing-app') == null) { if (stringArg('use-existing-app') == null) {
await driverService.start( await driverService.start(
buildInfo, buildInfo,
device, device,
...@@ -294,14 +293,14 @@ class DriveCommand extends RunCommandBase { ...@@ -294,14 +293,14 @@ class DriveCommand extends RunCommandBase {
'trace-startup': traceStartup, 'trace-startup': traceStartup,
if (web) if (web)
'--no-launch-chrome': true, '--no-launch-chrome': true,
if (boolArgDeprecated('multidex')) if (boolArg('multidex'))
'multidex': true, 'multidex': true,
} }
); );
} else { } else {
final Uri? uri = Uri.tryParse(stringArgDeprecated('use-existing-app')!); final Uri? uri = Uri.tryParse(stringArg('use-existing-app')!);
if (uri == null) { if (uri == null) {
throwToolExit('Invalid VM Service URI: ${stringArgDeprecated('use-existing-app')}'); throwToolExit('Invalid VM Service URI: ${stringArg('use-existing-app')}');
} }
await driverService.reuseApplication( await driverService.reuseApplication(
uri, uri,
...@@ -316,16 +315,16 @@ class DriveCommand extends RunCommandBase { ...@@ -316,16 +315,16 @@ class DriveCommand extends RunCommandBase {
stringsArg('test-arguments'), stringsArg('test-arguments'),
<String, String>{}, <String, String>{},
packageConfig, packageConfig,
chromeBinary: stringArgDeprecated('chrome-binary'), chromeBinary: stringArg('chrome-binary'),
headless: boolArgDeprecated('headless'), headless: boolArg('headless'),
webBrowserFlags: stringsArg(FlutterOptions.kWebBrowserFlag), webBrowserFlags: stringsArg(FlutterOptions.kWebBrowserFlag),
browserDimension: stringArgDeprecated('browser-dimension')!.split(','), browserDimension: stringArg('browser-dimension')!.split(','),
browserName: stringArgDeprecated('browser-name'), browserName: stringArg('browser-name'),
driverPort: stringArgDeprecated('driver-port') != null driverPort: stringArg('driver-port') != null
? int.tryParse(stringArgDeprecated('driver-port')!) ? int.tryParse(stringArg('driver-port')!)
: null, : null,
androidEmulator: boolArgDeprecated('android-emulator'), androidEmulator: boolArg('android-emulator'),
profileMemory: stringArgDeprecated('profile-memory'), profileMemory: stringArg('profile-memory'),
); );
// If the test is sent a signal or times out, take a screenshot // If the test is sent a signal or times out, take a screenshot
...@@ -344,11 +343,11 @@ class DriveCommand extends RunCommandBase { ...@@ -344,11 +343,11 @@ class DriveCommand extends RunCommandBase {
screenshotTaken = true; screenshotTaken = true;
} }
if (boolArgDeprecated('keep-app-running')) { if (boolArg('keep-app-running')) {
_logger.printStatus('Leaving the application running.'); _logger.printStatus('Leaving the application running.');
} else { } else {
final File? skslFile = stringArgDeprecated('write-sksl-on-exit') != null final File? skslFile = stringArg('write-sksl-on-exit') != null
? _fileSystem.file(stringArgDeprecated('write-sksl-on-exit')) ? _fileSystem.file(stringArg('write-sksl-on-exit'))
: null; : null;
await driverService.stop(userIdentifier: userIdentifier, writeSkslOnExit: skslFile); await driverService.stop(userIdentifier: userIdentifier, writeSkslOnExit: skslFile);
} }
...@@ -422,7 +421,7 @@ class DriveCommand extends RunCommandBase { ...@@ -422,7 +421,7 @@ class DriveCommand extends RunCommandBase {
String? _getTestFile() { String? _getTestFile() {
if (argResults!['driver'] != null) { if (argResults!['driver'] != null) {
return stringArgDeprecated('driver'); return stringArg('driver');
} }
// If the --driver argument wasn't provided, then derive the value from // If the --driver argument wasn't provided, then derive the value from
......
...@@ -48,9 +48,9 @@ class EmulatorsCommand extends FlutterCommand { ...@@ -48,9 +48,9 @@ class EmulatorsCommand extends FlutterCommand {
final ArgResults argumentResults = argResults!; final ArgResults argumentResults = argResults!;
if (argumentResults.wasParsed('launch')) { if (argumentResults.wasParsed('launch')) {
final bool coldBoot = argumentResults.wasParsed('cold'); final bool coldBoot = argumentResults.wasParsed('cold');
await _launchEmulator(stringArgDeprecated('launch')!, coldBoot: coldBoot); await _launchEmulator(stringArg('launch')!, coldBoot: coldBoot);
} else if (argumentResults.wasParsed('create')) { } else if (argumentResults.wasParsed('create')) {
await _createEmulator(name: stringArgDeprecated('name')); await _createEmulator(name: stringArg('name'));
} else { } else {
final String? searchText = final String? searchText =
argumentResults.rest.isNotEmpty argumentResults.rest.isNotEmpty
......
...@@ -226,7 +226,7 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -226,7 +226,7 @@ class GenerateLocalizationsCommand extends FlutterCommand {
final List<String> outputFileList; final List<String> outputFileList;
File? untranslatedMessagesFile; File? untranslatedMessagesFile;
bool format = boolArg('format') ?? false; bool format = boolArg('format');
if (_fileSystem.file('l10n.yaml').existsSync()) { if (_fileSystem.file('l10n.yaml').existsSync()) {
final LocalizationOptions options = parseLocalizationsOptions( final LocalizationOptions options = parseLocalizationsOptions(
...@@ -249,23 +249,23 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -249,23 +249,23 @@ class GenerateLocalizationsCommand extends FlutterCommand {
untranslatedMessagesFile = generator.untranslatedMessagesFile; untranslatedMessagesFile = generator.untranslatedMessagesFile;
format = format || options.format; format = format || options.format;
} else { } else {
final String inputPathString = stringArgDeprecated('arb-dir')!; // Has default value, cannot be null. final String inputPathString = stringArg('arb-dir')!; // Has default value, cannot be null.
final String? outputPathString = stringArgDeprecated('output-dir'); final String? outputPathString = stringArg('output-dir');
final String outputFileString = stringArgDeprecated('output-localization-file')!; // Has default value, cannot be null. final String outputFileString = stringArg('output-localization-file')!; // Has default value, cannot be null.
final String templateArbFileName = stringArgDeprecated('template-arb-file')!; // Has default value, cannot be null. final String templateArbFileName = stringArg('template-arb-file')!; // Has default value, cannot be null.
final String? untranslatedMessagesFilePath = stringArgDeprecated('untranslated-messages-file'); final String? untranslatedMessagesFilePath = stringArg('untranslated-messages-file');
final String classNameString = stringArgDeprecated('output-class')!; // Has default value, cannot be null. final String classNameString = stringArg('output-class')!; // Has default value, cannot be null.
final List<String> preferredSupportedLocales = stringsArg('preferred-supported-locales'); final List<String> preferredSupportedLocales = stringsArg('preferred-supported-locales');
final String? headerString = stringArgDeprecated('header'); final String? headerString = stringArg('header');
final String? headerFile = stringArgDeprecated('header-file'); final String? headerFile = stringArg('header-file');
final bool useDeferredLoading = boolArgDeprecated('use-deferred-loading'); final bool useDeferredLoading = boolArg('use-deferred-loading');
final String? inputsAndOutputsListPath = stringArgDeprecated('gen-inputs-and-outputs-list'); final String? inputsAndOutputsListPath = stringArg('gen-inputs-and-outputs-list');
final bool useSyntheticPackage = boolArgDeprecated('synthetic-package'); final bool useSyntheticPackage = boolArg('synthetic-package');
final String? projectPathString = stringArgDeprecated('project-dir'); final String? projectPathString = stringArg('project-dir');
final bool areResourceAttributesRequired = boolArgDeprecated('required-resource-attributes'); final bool areResourceAttributesRequired = boolArg('required-resource-attributes');
final bool usesNullableGetter = boolArgDeprecated('nullable-getter'); final bool usesNullableGetter = boolArg('nullable-getter');
final bool useEscaping = boolArgDeprecated('use-escaping'); final bool useEscaping = boolArg('use-escaping');
final bool suppressWarnings = boolArgDeprecated('suppress-warnings'); final bool suppressWarnings = boolArg('suppress-warnings');
precacheLanguageAndRegionTags(); precacheLanguageAndRegionTags();
......
...@@ -153,7 +153,7 @@ class IdeConfigCommand extends FlutterCommand { ...@@ -153,7 +153,7 @@ class IdeConfigCommand extends FlutterCommand {
manifest.add('$relativePath${Template.copyTemplateExtension}'); manifest.add('$relativePath${Template.copyTemplateExtension}');
continue; continue;
} }
if (boolArgDeprecated('overwrite')) { if (boolArg('overwrite')) {
finalDestinationFile.deleteSync(); finalDestinationFile.deleteSync();
globals.printStatus(' $relativeDestination (overwritten)'); globals.printStatus(' $relativeDestination (overwritten)');
} else { } else {
...@@ -174,7 +174,7 @@ class IdeConfigCommand extends FlutterCommand { ...@@ -174,7 +174,7 @@ class IdeConfigCommand extends FlutterCommand {
} }
// If we're not overwriting, then we're not going to remove missing items either. // If we're not overwriting, then we're not going to remove missing items either.
if (!boolArgDeprecated('overwrite')) { if (!boolArg('overwrite')) {
return; return;
} }
...@@ -213,7 +213,7 @@ class IdeConfigCommand extends FlutterCommand { ...@@ -213,7 +213,7 @@ class IdeConfigCommand extends FlutterCommand {
throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2); throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2);
} }
if (boolArgDeprecated('update-templates')) { if (boolArg('update-templates')) {
_handleTemplateUpdate(); _handleTemplateUpdate();
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
...@@ -231,7 +231,7 @@ class IdeConfigCommand extends FlutterCommand { ...@@ -231,7 +231,7 @@ class IdeConfigCommand extends FlutterCommand {
globals.printStatus('Updating IDE configuration for Flutter tree at $dirPath...'); globals.printStatus('Updating IDE configuration for Flutter tree at $dirPath...');
int generatedCount = 0; int generatedCount = 0;
generatedCount += _renderTemplate(_ideName, dirPath, <String, Object>{ generatedCount += _renderTemplate(_ideName, dirPath, <String, Object>{
'withRootModule': boolArgDeprecated('with-root-module'), 'withRootModule': boolArg('with-root-module'),
'android': true, 'android': true,
}); });
...@@ -254,7 +254,7 @@ class IdeConfigCommand extends FlutterCommand { ...@@ -254,7 +254,7 @@ class IdeConfigCommand extends FlutterCommand {
return template.render( return template.render(
globals.fs.directory(dirPath), globals.fs.directory(dirPath),
context, context,
overwriteExisting: boolArgDeprecated('overwrite'), overwriteExisting: boolArg('overwrite'),
); );
} }
} }
......
...@@ -37,10 +37,10 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts ...@@ -37,10 +37,10 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
Device? device; Device? device;
bool get uninstallOnly => boolArgDeprecated('uninstall-only'); bool get uninstallOnly => boolArg('uninstall-only');
String? get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser); String? get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
String? get _applicationBinaryPath => stringArgDeprecated(FlutterOptions.kUseApplicationBinary); String? get _applicationBinaryPath => stringArg(FlutterOptions.kUseApplicationBinary);
File? get _applicationBinary => _applicationBinaryPath == null ? null : globals.fs.file(_applicationBinaryPath); File? get _applicationBinary => _applicationBinaryPath == null ? null : globals.fs.file(_applicationBinaryPath);
@override @override
......
...@@ -46,7 +46,7 @@ class LogsCommand extends FlutterCommand { ...@@ -46,7 +46,7 @@ class LogsCommand extends FlutterCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final Device cachedDevice = device!; final Device cachedDevice = device!;
if (boolArgDeprecated('clear')) { if (boolArg('clear')) {
cachedDevice.clearLogs(); cachedDevice.clearLogs();
} }
......
...@@ -102,7 +102,7 @@ class PrecacheCommand extends FlutterCommand { ...@@ -102,7 +102,7 @@ class PrecacheCommand extends FlutterCommand {
Set<String> _explicitArtifactSelections() { Set<String> _explicitArtifactSelections() {
final Map<String, String> umbrellaForArtifact = _umbrellaForArtifactMap(); final Map<String, String> umbrellaForArtifact = _umbrellaForArtifactMap();
final Set<String> selections = <String>{}; final Set<String> selections = <String>{};
bool explicitlySelected(String name) => boolArgDeprecated(name) && argResults!.wasParsed(name); bool explicitlySelected(String name) => boolArg(name) && argResults!.wasParsed(name);
for (final DevelopmentArtifact artifact in DevelopmentArtifact.values) { for (final DevelopmentArtifact artifact in DevelopmentArtifact.values) {
final String? umbrellaName = umbrellaForArtifact[artifact.name]; final String? umbrellaName = umbrellaForArtifact[artifact.name];
if (explicitlySelected(artifact.name) || if (explicitlySelected(artifact.name) ||
...@@ -135,15 +135,15 @@ class PrecacheCommand extends FlutterCommand { ...@@ -135,15 +135,15 @@ class PrecacheCommand extends FlutterCommand {
if (_platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') { if (_platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') {
await _cache.lock(); await _cache.lock();
} }
if (boolArgDeprecated('force')) { if (boolArg('force')) {
_cache.clearStampFiles(); _cache.clearStampFiles();
} }
final bool includeAllPlatforms = boolArgDeprecated('all-platforms'); final bool includeAllPlatforms = boolArg('all-platforms');
if (includeAllPlatforms) { if (includeAllPlatforms) {
_cache.includeAllPlatforms = true; _cache.includeAllPlatforms = true;
} }
if (boolArgDeprecated('use-unsigned-mac-binaries')) { if (boolArg('use-unsigned-mac-binaries')) {
_cache.useUnsignedMacBinaries = true; _cache.useUnsignedMacBinaries = true;
} }
final Set<String> explicitlyEnabled = _explicitArtifactSelections(); final Set<String> explicitlyEnabled = _explicitArtifactSelections();
...@@ -160,7 +160,7 @@ class PrecacheCommand extends FlutterCommand { ...@@ -160,7 +160,7 @@ class PrecacheCommand extends FlutterCommand {
} }
final String argumentName = umbrellaForArtifact[artifact.name] ?? artifact.name; final String argumentName = umbrellaForArtifact[artifact.name] ?? artifact.name;
if (includeAllPlatforms || boolArgDeprecated(argumentName) || downloadDefaultArtifacts) { if (includeAllPlatforms || boolArg(argumentName) || downloadDefaultArtifacts) {
requiredArtifacts.add(artifact); requiredArtifacts.add(artifact);
} }
} }
......
...@@ -186,18 +186,18 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -186,18 +186,18 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
addEnableEmbedderApiFlag(verboseHelp: verboseHelp); addEnableEmbedderApiFlag(verboseHelp: verboseHelp);
} }
bool get traceStartup => boolArgDeprecated('trace-startup'); bool get traceStartup => boolArg('trace-startup');
bool get enableDartProfiling => boolArgDeprecated('enable-dart-profiling'); bool get enableDartProfiling => boolArg('enable-dart-profiling');
bool get cacheSkSL => boolArgDeprecated('cache-sksl'); bool get cacheSkSL => boolArg('cache-sksl');
bool get dumpSkpOnShaderCompilation => boolArgDeprecated('dump-skp-on-shader-compilation'); bool get dumpSkpOnShaderCompilation => boolArg('dump-skp-on-shader-compilation');
bool get purgePersistentCache => boolArgDeprecated('purge-persistent-cache'); bool get purgePersistentCache => boolArg('purge-persistent-cache');
bool get disableServiceAuthCodes => boolArgDeprecated('disable-service-auth-codes'); bool get disableServiceAuthCodes => boolArg('disable-service-auth-codes');
bool get cacheStartupProfile => boolArgDeprecated('cache-startup-profile'); bool get cacheStartupProfile => boolArg('cache-startup-profile');
bool get runningWithPrebuiltApplication => argResults![FlutterOptions.kUseApplicationBinary] != null; bool get runningWithPrebuiltApplication => argResults![FlutterOptions.kUseApplicationBinary] != null;
bool get trackWidgetCreation => boolArgDeprecated('track-widget-creation'); bool get trackWidgetCreation => boolArg('track-widget-creation');
bool get enableImpeller => boolArgDeprecated('enable-impeller'); bool get enableImpeller => boolArg('enable-impeller');
bool get uninstallFirst => boolArgDeprecated('uninstall-first'); bool get uninstallFirst => boolArg('uninstall-first');
bool get enableEmbedderApi => boolArgDeprecated('enable-embedder-api'); bool get enableEmbedderApi => boolArg('enable-embedder-api');
@override @override
bool get reportNullSafety => true; bool get reportNullSafety => true;
...@@ -205,9 +205,9 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -205,9 +205,9 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
/// Whether to start the application paused by default. /// Whether to start the application paused by default.
bool get startPausedDefault; bool get startPausedDefault;
String? get route => stringArgDeprecated('route'); String? get route => stringArg('route');
String? get traceAllowlist => stringArgDeprecated('trace-allowlist'); String? get traceAllowlist => stringArg('trace-allowlist');
/// Create a debugging options instance for the current `run` or `drive` invocation. /// Create a debugging options instance for the current `run` or `drive` invocation.
@visibleForTesting @visibleForTesting
...@@ -215,7 +215,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -215,7 +215,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
Future<DebuggingOptions> createDebuggingOptions(bool webMode) async { Future<DebuggingOptions> createDebuggingOptions(bool webMode) async {
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
final int? webBrowserDebugPort = featureFlags.isWebEnabled && argResults!.wasParsed('web-browser-debug-port') final int? webBrowserDebugPort = featureFlags.isWebEnabled && argResults!.wasParsed('web-browser-debug-port')
? int.parse(stringArgDeprecated('web-browser-debug-port')!) ? int.parse(stringArg('web-browser-debug-port')!)
: null; : null;
final List<String> webBrowserFlags = featureFlags.isWebEnabled final List<String> webBrowserFlags = featureFlags.isWebEnabled
? stringsArg(FlutterOptions.kWebBrowserFlag) ? stringsArg(FlutterOptions.kWebBrowserFlag)
...@@ -224,13 +224,13 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -224,13 +224,13 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
return DebuggingOptions.disabled( return DebuggingOptions.disabled(
buildInfo, buildInfo,
dartEntrypointArgs: stringsArg('dart-entrypoint-args'), dartEntrypointArgs: stringsArg('dart-entrypoint-args'),
hostname: featureFlags.isWebEnabled ? stringArgDeprecated('web-hostname') : '', hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '',
port: featureFlags.isWebEnabled ? stringArgDeprecated('web-port') : '', port: featureFlags.isWebEnabled ? stringArg('web-port') : '',
webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-protocol') == 'sse', webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArg('web-server-debug-protocol') == 'sse',
webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-backend-protocol') == 'sse', webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArg('web-server-debug-backend-protocol') == 'sse',
webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-injected-client-protocol') == 'sse', webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArg('web-server-debug-injected-client-protocol') == 'sse',
webEnableExposeUrl: featureFlags.isWebEnabled && boolArgDeprecated('web-allow-expose-url'), webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'),
webRunHeadless: featureFlags.isWebEnabled && boolArgDeprecated('web-run-headless'), webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
webBrowserDebugPort: webBrowserDebugPort, webBrowserDebugPort: webBrowserDebugPort,
webBrowserFlags: webBrowserFlags, webBrowserFlags: webBrowserFlags,
enableImpeller: enableImpeller, enableImpeller: enableImpeller,
...@@ -241,20 +241,20 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -241,20 +241,20 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
} else { } else {
return DebuggingOptions.enabled( return DebuggingOptions.enabled(
buildInfo, buildInfo,
startPaused: boolArgDeprecated('start-paused'), startPaused: boolArg('start-paused'),
disableServiceAuthCodes: boolArgDeprecated('disable-service-auth-codes'), disableServiceAuthCodes: boolArg('disable-service-auth-codes'),
cacheStartupProfile: cacheStartupProfile, cacheStartupProfile: cacheStartupProfile,
enableDds: enableDds, enableDds: enableDds,
dartEntrypointArgs: stringsArg('dart-entrypoint-args'), dartEntrypointArgs: stringsArg('dart-entrypoint-args'),
dartFlags: stringArgDeprecated('dart-flags') ?? '', dartFlags: stringArg('dart-flags') ?? '',
useTestFonts: argParser.options.containsKey('use-test-fonts') && boolArgDeprecated('use-test-fonts'), useTestFonts: argParser.options.containsKey('use-test-fonts') && boolArg('use-test-fonts'),
enableSoftwareRendering: argParser.options.containsKey('enable-software-rendering') && boolArgDeprecated('enable-software-rendering'), enableSoftwareRendering: argParser.options.containsKey('enable-software-rendering') && boolArg('enable-software-rendering'),
skiaDeterministicRendering: argParser.options.containsKey('skia-deterministic-rendering') && boolArgDeprecated('skia-deterministic-rendering'), skiaDeterministicRendering: argParser.options.containsKey('skia-deterministic-rendering') && boolArg('skia-deterministic-rendering'),
traceSkia: boolArgDeprecated('trace-skia'), traceSkia: boolArg('trace-skia'),
traceAllowlist: traceAllowlist, traceAllowlist: traceAllowlist,
traceSkiaAllowlist: stringArgDeprecated('trace-skia-allowlist'), traceSkiaAllowlist: stringArg('trace-skia-allowlist'),
traceSystrace: boolArgDeprecated('trace-systrace'), traceSystrace: boolArg('trace-systrace'),
endlessTraceBuffer: boolArgDeprecated('endless-trace-buffer'), endlessTraceBuffer: boolArg('endless-trace-buffer'),
dumpSkpOnShaderCompilation: dumpSkpOnShaderCompilation, dumpSkpOnShaderCompilation: dumpSkpOnShaderCompilation,
cacheSkSL: cacheSkSL, cacheSkSL: cacheSkSL,
purgePersistentCache: purgePersistentCache, purgePersistentCache: purgePersistentCache,
...@@ -263,27 +263,27 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -263,27 +263,27 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
disablePortPublication: await disablePortPublication, disablePortPublication: await disablePortPublication,
ddsPort: ddsPort, ddsPort: ddsPort,
devToolsServerAddress: devToolsServerAddress, devToolsServerAddress: devToolsServerAddress,
verboseSystemLogs: boolArgDeprecated('verbose-system-logs'), verboseSystemLogs: boolArg('verbose-system-logs'),
hostname: featureFlags.isWebEnabled ? stringArgDeprecated('web-hostname') : '', hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '',
port: featureFlags.isWebEnabled ? stringArgDeprecated('web-port') : '', port: featureFlags.isWebEnabled ? stringArg('web-port') : '',
webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-protocol') == 'sse', webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArg('web-server-debug-protocol') == 'sse',
webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-backend-protocol') == 'sse', webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArg('web-server-debug-backend-protocol') == 'sse',
webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-injected-client-protocol') == 'sse', webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArg('web-server-debug-injected-client-protocol') == 'sse',
webEnableExposeUrl: featureFlags.isWebEnabled && boolArgDeprecated('web-allow-expose-url'), webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'),
webRunHeadless: featureFlags.isWebEnabled && boolArgDeprecated('web-run-headless'), webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
webBrowserDebugPort: webBrowserDebugPort, webBrowserDebugPort: webBrowserDebugPort,
webBrowserFlags: webBrowserFlags, webBrowserFlags: webBrowserFlags,
webEnableExpressionEvaluation: featureFlags.isWebEnabled && boolArgDeprecated('web-enable-expression-evaluation'), webEnableExpressionEvaluation: featureFlags.isWebEnabled && boolArg('web-enable-expression-evaluation'),
webLaunchUrl: featureFlags.isWebEnabled ? stringArgDeprecated('web-launch-url') : null, webLaunchUrl: featureFlags.isWebEnabled ? stringArg('web-launch-url') : null,
vmserviceOutFile: stringArgDeprecated('vmservice-out-file'), vmserviceOutFile: stringArg('vmservice-out-file'),
fastStart: argParser.options.containsKey('fast-start') fastStart: argParser.options.containsKey('fast-start')
&& boolArgDeprecated('fast-start') && boolArg('fast-start')
&& !runningWithPrebuiltApplication, && !runningWithPrebuiltApplication,
nullAssertions: boolArgDeprecated('null-assertions'), nullAssertions: boolArg('null-assertions'),
nativeNullAssertions: boolArgDeprecated('native-null-assertions'), nativeNullAssertions: boolArg('native-null-assertions'),
enableImpeller: enableImpeller, enableImpeller: enableImpeller,
uninstallFirst: uninstallFirst, uninstallFirst: uninstallFirst,
serveObservatory: boolArgDeprecated('serve-observatory'), serveObservatory: boolArg('serve-observatory'),
enableDartProfiling: enableDartProfiling, enableDartProfiling: enableDartProfiling,
enableEmbedderApi: enableEmbedderApi, enableEmbedderApi: enableEmbedderApi,
); );
...@@ -379,7 +379,7 @@ class RunCommand extends RunCommandBase { ...@@ -379,7 +379,7 @@ class RunCommand extends RunCommandBase {
final String name = 'run'; final String name = 'run';
@override @override
DeprecationBehavior get deprecationBehavior => boolArgDeprecated('ignore-deprecation') ? DeprecationBehavior.ignore : _deviceDeprecationBehavior; DeprecationBehavior get deprecationBehavior => boolArg('ignore-deprecation') ? DeprecationBehavior.ignore : _deviceDeprecationBehavior;
DeprecationBehavior _deviceDeprecationBehavior = DeprecationBehavior.none; DeprecationBehavior _deviceDeprecationBehavior = DeprecationBehavior.none;
@override @override
...@@ -391,7 +391,7 @@ class RunCommand extends RunCommandBase { ...@@ -391,7 +391,7 @@ class RunCommand extends RunCommandBase {
List<Device>? devices; List<Device>? devices;
bool webMode = false; bool webMode = false;
String? get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser); String? get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
@override @override
bool get startPausedDefault => false; bool get startPausedDefault => false;
...@@ -500,13 +500,13 @@ class RunCommand extends RunCommandBase { ...@@ -500,13 +500,13 @@ class RunCommand extends RunCommandBase {
} }
bool shouldUseHotMode(BuildInfo buildInfo) { bool shouldUseHotMode(BuildInfo buildInfo) {
final bool hotArg = boolArgDeprecated('hot'); final bool hotArg = boolArg('hot');
final bool shouldUseHotMode = hotArg && !traceStartup; final bool shouldUseHotMode = hotArg && !traceStartup;
return buildInfo.isDebug && shouldUseHotMode; return buildInfo.isDebug && shouldUseHotMode;
} }
bool get stayResident => boolArgDeprecated('resident'); bool get stayResident => boolArg('resident');
bool get awaitFirstFrameWhenTracing => boolArgDeprecated('await-first-frame-when-tracing'); bool get awaitFirstFrameWhenTracing => boolArg('await-first-frame-when-tracing');
@override @override
Future<void> validateCommand() async { Future<void> validateCommand() async {
...@@ -553,15 +553,15 @@ class RunCommand extends RunCommandBase { ...@@ -553,15 +553,15 @@ class RunCommand extends RunCommandBase {
flutterDevices, flutterDevices,
target: targetFile, target: targetFile,
debuggingOptions: await createDebuggingOptions(webMode), debuggingOptions: await createDebuggingOptions(webMode),
benchmarkMode: boolArgDeprecated('benchmark'), benchmarkMode: boolArg('benchmark'),
applicationBinary: applicationBinaryPath == null applicationBinary: applicationBinaryPath == null
? null ? null
: globals.fs.file(applicationBinaryPath), : globals.fs.file(applicationBinaryPath),
projectRootPath: stringArgDeprecated('project-root'), projectRootPath: stringArg('project-root'),
dillOutputPath: stringArgDeprecated('output-dill'), dillOutputPath: stringArg('output-dill'),
stayResident: stayResident, stayResident: stayResident,
ipv6: ipv6 ?? false, ipv6: ipv6 ?? false,
multidexEnabled: boolArgDeprecated('multidex'), multidexEnabled: boolArg('multidex'),
); );
} else if (webMode) { } else if (webMode) {
return webRunnerFactory!.createWebRunner( return webRunnerFactory!.createWebRunner(
...@@ -588,7 +588,7 @@ class RunCommand extends RunCommandBase { ...@@ -588,7 +588,7 @@ class RunCommand extends RunCommandBase {
: globals.fs.file(applicationBinaryPath), : globals.fs.file(applicationBinaryPath),
ipv6: ipv6 ?? false, ipv6: ipv6 ?? false,
stayResident: stayResident, stayResident: stayResident,
multidexEnabled: boolArgDeprecated('multidex'), multidexEnabled: boolArg('multidex'),
); );
} }
...@@ -613,9 +613,9 @@ class RunCommand extends RunCommandBase { ...@@ -613,9 +613,9 @@ class RunCommand extends RunCommandBase {
// debug mode. // debug mode.
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
final bool hotMode = shouldUseHotMode(buildInfo); final bool hotMode = shouldUseHotMode(buildInfo);
final String? applicationBinaryPath = stringArgDeprecated(FlutterOptions.kUseApplicationBinary); final String? applicationBinaryPath = stringArg(FlutterOptions.kUseApplicationBinary);
if (boolArgDeprecated('machine')) { if (boolArg('machine')) {
if (devices!.length > 1) { if (devices!.length > 1) {
throwToolExit('"--machine" does not support "-d all".'); throwToolExit('"--machine" does not support "-d all".');
} }
...@@ -629,13 +629,13 @@ class RunCommand extends RunCommandBase { ...@@ -629,13 +629,13 @@ class RunCommand extends RunCommandBase {
? null ? null
: globals.fs.file(applicationBinaryPath), : globals.fs.file(applicationBinaryPath),
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
projectRootPath: stringArgDeprecated('project-root'), projectRootPath: stringArg('project-root'),
packagesFilePath: globalResults!['packages'] as String?, packagesFilePath: globalResults!['packages'] as String?,
dillOutputPath: stringArgDeprecated('output-dill'), dillOutputPath: stringArg('output-dill'),
ipv6: ipv6 ?? false, ipv6: ipv6 ?? false,
multidexEnabled: boolArgDeprecated('multidex'), multidexEnabled: boolArg('multidex'),
userIdentifier: userIdentifier, userIdentifier: userIdentifier,
enableDevTools: boolArgDeprecated(FlutterCommand.kEnableDevTools), enableDevTools: boolArg(FlutterCommand.kEnableDevTools),
); );
} on Exception catch (error) { } on Exception catch (error) {
throwToolExit(error.toString()); throwToolExit(error.toString());
...@@ -667,7 +667,7 @@ class RunCommand extends RunCommandBase { ...@@ -667,7 +667,7 @@ class RunCommand extends RunCommandBase {
} }
} }
if (await device.isLocalEmulator && await device.supportsHardwareRendering) { if (await device.isLocalEmulator && await device.supportsHardwareRendering) {
if (boolArgDeprecated('enable-software-rendering')) { if (boolArg('enable-software-rendering')) {
globals.printStatus( globals.printStatus(
'Using software rendering with device ${device.name}. You may get better performance ' 'Using software rendering with device ${device.name}. You may get better performance '
'with hardware mode by configuring hardware rendering for your device.' 'with hardware mode by configuring hardware rendering for your device.'
...@@ -725,8 +725,8 @@ class RunCommand extends RunCommandBase { ...@@ -725,8 +725,8 @@ class RunCommand extends RunCommandBase {
terminal: globals.terminal, terminal: globals.terminal,
signals: globals.signals, signals: globals.signals,
processInfo: globals.processInfo, processInfo: globals.processInfo,
reportReady: boolArgDeprecated('report-ready'), reportReady: boolArg('report-ready'),
pidFile: stringArgDeprecated('pid-file'), pidFile: stringArg('pid-file'),
) )
..registerSignalHandlers() ..registerSignalHandlers()
..setupTerminal(); ..setupTerminal();
...@@ -736,7 +736,7 @@ class RunCommand extends RunCommandBase { ...@@ -736,7 +736,7 @@ class RunCommand extends RunCommandBase {
try { try {
final int? result = await runner.run( final int? result = await runner.run(
appStartedCompleter: appStartedTimeRecorder, appStartedCompleter: appStartedTimeRecorder,
enableDevTools: stayResident && boolArgDeprecated(FlutterCommand.kEnableDevTools), enableDevTools: stayResident && boolArg(FlutterCommand.kEnableDevTools),
route: route, route: route,
); );
handler?.stop(); handler?.stop();
......
...@@ -96,7 +96,7 @@ class ScreenshotCommand extends FlutterCommand { ...@@ -96,7 +96,7 @@ class ScreenshotCommand extends FlutterCommand {
@override @override
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async { Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
await _validateOptions(stringArgDeprecated(_kType), stringArgDeprecated(_kVmServiceUrl)); await _validateOptions(stringArg(_kType), stringArg(_kVmServiceUrl));
return super.verifyThenRunCommand(commandPath); return super.verifyThenRunCommand(commandPath);
} }
...@@ -104,11 +104,11 @@ class ScreenshotCommand extends FlutterCommand { ...@@ -104,11 +104,11 @@ class ScreenshotCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
File? outputFile; File? outputFile;
if (argResults?.wasParsed(_kOut) ?? false) { if (argResults?.wasParsed(_kOut) ?? false) {
outputFile = fs.file(stringArgDeprecated(_kOut)); outputFile = fs.file(stringArg(_kOut));
} }
bool success = true; bool success = true;
switch (stringArgDeprecated(_kType)) { switch (stringArg(_kType)) {
case _kDeviceType: case _kDeviceType:
await runScreenshot(outputFile); await runScreenshot(outputFile);
break; break;
...@@ -150,7 +150,7 @@ class ScreenshotCommand extends FlutterCommand { ...@@ -150,7 +150,7 @@ class ScreenshotCommand extends FlutterCommand {
} }
Future<bool> runSkia(File? outputFile) async { Future<bool> runSkia(File? outputFile) async {
final Uri vmServiceUrl = Uri.parse(stringArgDeprecated(_kVmServiceUrl)!); final Uri vmServiceUrl = Uri.parse(stringArg(_kVmServiceUrl)!);
final FlutterVmService vmService = await connectToVmService(vmServiceUrl, logger: globals.logger); final FlutterVmService vmService = await connectToVmService(vmServiceUrl, logger: globals.logger);
final vm_service.Response? skp = await vmService.screenshotSkp(); final vm_service.Response? skp = await vmService.screenshotSkp();
if (skp == null) { if (skp == null) {
...@@ -174,7 +174,7 @@ class ScreenshotCommand extends FlutterCommand { ...@@ -174,7 +174,7 @@ class ScreenshotCommand extends FlutterCommand {
} }
Future<bool> runRasterizer(File? outputFile) async { Future<bool> runRasterizer(File? outputFile) async {
final Uri vmServiceUrl = Uri.parse(stringArgDeprecated(_kVmServiceUrl)!); final Uri vmServiceUrl = Uri.parse(stringArg(_kVmServiceUrl)!);
final FlutterVmService vmService = await connectToVmService(vmServiceUrl, logger: globals.logger); final FlutterVmService vmService = await connectToVmService(vmServiceUrl, logger: globals.logger);
final vm_service.Response? response = await vmService.screenshot(); final vm_service.Response? response = await vmService.screenshot();
if (response == null) { if (response == null) {
......
...@@ -54,7 +54,7 @@ class ShellCompletionCommand extends FlutterCommand { ...@@ -54,7 +54,7 @@ class ShellCompletionCommand extends FlutterCommand {
} }
final File outputFile = globals.fs.file(rest.first); final File outputFile = globals.fs.file(rest.first);
if (outputFile.existsSync() && !boolArgDeprecated('overwrite')) { if (outputFile.existsSync() && !boolArg('overwrite')) {
throwToolExit( throwToolExit(
'Output file ${outputFile.path} already exists, will not overwrite. ' 'Output file ${outputFile.path} already exists, will not overwrite. '
'Use --overwrite to force overwriting existing output file.', 'Use --overwrite to force overwriting existing output file.',
......
...@@ -68,14 +68,14 @@ class SymbolizeCommand extends FlutterCommand { ...@@ -68,14 +68,14 @@ class SymbolizeCommand extends FlutterCommand {
if (argResults?.wasParsed('debug-info') != true) { if (argResults?.wasParsed('debug-info') != true) {
throwToolExit('"--debug-info" is required to symbolize stack traces.'); throwToolExit('"--debug-info" is required to symbolize stack traces.');
} }
final String debugInfoPath = stringArgDeprecated('debug-info')!; final String debugInfoPath = stringArg('debug-info')!;
if (debugInfoPath.endsWith('.dSYM') if (debugInfoPath.endsWith('.dSYM')
? !_fileSystem.isDirectorySync(debugInfoPath) ? !_fileSystem.isDirectorySync(debugInfoPath)
: !_fileSystem.isFileSync(debugInfoPath)) { : !_fileSystem.isFileSync(debugInfoPath)) {
throwToolExit('$debugInfoPath does not exist.'); throwToolExit('$debugInfoPath does not exist.');
} }
if ((argResults?.wasParsed('input') ?? false) && !_fileSystem.isFileSync(stringArgDeprecated('input')!)) { if ((argResults?.wasParsed('input') ?? false) && !_fileSystem.isFileSync(stringArg('input')!)) {
throwToolExit('${stringArgDeprecated('input')} does not exist.'); throwToolExit('${stringArg('input')} does not exist.');
} }
return super.validateCommand(); return super.validateCommand();
} }
...@@ -87,7 +87,7 @@ class SymbolizeCommand extends FlutterCommand { ...@@ -87,7 +87,7 @@ class SymbolizeCommand extends FlutterCommand {
// Configure output to either specified file or stdout. // Configure output to either specified file or stdout.
if (argResults?.wasParsed('output') ?? false) { if (argResults?.wasParsed('output') ?? false) {
final File outputFile = _fileSystem.file(stringArgDeprecated('output')); final File outputFile = _fileSystem.file(stringArg('output'));
if (!outputFile.parent.existsSync()) { if (!outputFile.parent.existsSync()) {
outputFile.parent.createSync(recursive: true); outputFile.parent.createSync(recursive: true);
} }
...@@ -103,12 +103,12 @@ class SymbolizeCommand extends FlutterCommand { ...@@ -103,12 +103,12 @@ class SymbolizeCommand extends FlutterCommand {
// Configure input from either specified file or stdin. // Configure input from either specified file or stdin.
if (argResults?.wasParsed('input') ?? false) { if (argResults?.wasParsed('input') ?? false) {
input = _fileSystem.file(stringArgDeprecated('input')).openRead(); input = _fileSystem.file(stringArg('input')).openRead();
} else { } else {
input = _stdio.stdin; input = _stdio.stdin;
} }
String debugInfoPath = stringArgDeprecated('debug-info')!; String debugInfoPath = stringArg('debug-info')!;
// If it's a dSYM container, expand the path to the actual DWARF. // If it's a dSYM container, expand the path to the actual DWARF.
if (debugInfoPath.endsWith('.dSYM')) { if (debugInfoPath.endsWith('.dSYM')) {
......
...@@ -244,7 +244,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -244,7 +244,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
// Use [DeviceBasedDevelopmentArtifacts]. // Use [DeviceBasedDevelopmentArtifacts].
? await super.requiredArtifacts ? await super.requiredArtifacts
: <DevelopmentArtifact>{}; : <DevelopmentArtifact>{};
if (stringArgDeprecated('platform') == 'chrome') { if (stringArg('platform') == 'chrome') {
results.add(DevelopmentArtifact.web); results.add(DevelopmentArtifact.web);
} }
return results; return results;
...@@ -313,11 +313,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -313,11 +313,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
'directory (or one of its subdirectories).'); 'directory (or one of its subdirectories).');
} }
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
final bool buildTestAssets = boolArgDeprecated('test-assets'); final bool buildTestAssets = boolArg('test-assets');
final List<String> names = stringsArg('name'); final List<String> names = stringsArg('name');
final List<String> plainNames = stringsArg('plain-name'); final List<String> plainNames = stringsArg('plain-name');
final String? tags = stringArgDeprecated('tags'); final String? tags = stringArg('tags');
final String? excludeTags = stringArgDeprecated('exclude-tags'); final String? excludeTags = stringArg('exclude-tags');
final BuildInfo buildInfo = await getBuildInfo(forcedBuildMode: BuildMode.debug); final BuildInfo buildInfo = await getBuildInfo(forcedBuildMode: BuildMode.debug);
TestTimeRecorder? testTimeRecorder; TestTimeRecorder? testTimeRecorder;
...@@ -343,7 +343,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -343,7 +343,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
join(flutterProject.directory.path, 'build', 'unit_test_assets'); join(flutterProject.directory.path, 'build', 'unit_test_assets');
} }
final bool startPaused = boolArgDeprecated('start-paused'); final bool startPaused = boolArg('start-paused');
if (startPaused && _testFileUris.length != 1) { if (startPaused && _testFileUris.length != 1) {
throwToolExit( throwToolExit(
'When using --start-paused, you must specify a single test file to run.', 'When using --start-paused, you must specify a single test file to run.',
...@@ -351,7 +351,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -351,7 +351,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
); );
} }
int? jobs = int.tryParse(stringArgDeprecated('concurrency')!); int? jobs = int.tryParse(stringArg('concurrency')!);
if (jobs == null || jobs <= 0 || !jobs.isFinite) { if (jobs == null || jobs <= 0 || !jobs.isFinite) {
throwToolExit( throwToolExit(
'Could not parse -j/--concurrency argument. It must be an integer greater than zero.' 'Could not parse -j/--concurrency argument. It must be an integer greater than zero.'
...@@ -369,13 +369,13 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -369,13 +369,13 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
jobs = 1; jobs = 1;
} }
final int? shardIndex = int.tryParse(stringArgDeprecated('shard-index') ?? ''); final int? shardIndex = int.tryParse(stringArg('shard-index') ?? '');
if (shardIndex != null && (shardIndex < 0 || !shardIndex.isFinite)) { if (shardIndex != null && (shardIndex < 0 || !shardIndex.isFinite)) {
throwToolExit( throwToolExit(
'Could not parse --shard-index=$shardIndex argument. It must be an integer greater than -1.'); 'Could not parse --shard-index=$shardIndex argument. It must be an integer greater than -1.');
} }
final int? totalShards = int.tryParse(stringArgDeprecated('total-shards') ?? ''); final int? totalShards = int.tryParse(stringArg('total-shards') ?? '');
if (totalShards != null && (totalShards <= 0 || !totalShards.isFinite)) { if (totalShards != null && (totalShards <= 0 || !totalShards.isFinite)) {
throwToolExit( throwToolExit(
'Could not parse --total-shards=$totalShards argument. It must be an integer greater than zero.'); 'Could not parse --total-shards=$totalShards argument. It must be an integer greater than zero.');
...@@ -390,10 +390,10 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -390,10 +390,10 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
'If you set --shard-index you need to also set --total-shards.'); 'If you set --shard-index you need to also set --total-shards.');
} }
final bool machine = boolArgDeprecated('machine'); final bool machine = boolArg('machine');
CoverageCollector? collector; CoverageCollector? collector;
if (boolArgDeprecated('coverage') || boolArgDeprecated('merge-coverage') || if (boolArg('coverage') || boolArg('merge-coverage') ||
boolArgDeprecated('branch-coverage')) { boolArg('branch-coverage')) {
final String projectName = flutterProject.manifest.appName; final String projectName = flutterProject.manifest.appName;
collector = CoverageCollector( collector = CoverageCollector(
verbose: !machine, verbose: !machine,
...@@ -401,7 +401,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -401,7 +401,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
packagesPath: buildInfo.packagesPath, packagesPath: buildInfo.packagesPath,
resolver: await CoverageCollector.getResolver(buildInfo.packagesPath), resolver: await CoverageCollector.getResolver(buildInfo.packagesPath),
testTimeRecorder: testTimeRecorder, testTimeRecorder: testTimeRecorder,
branchCoverage: boolArgDeprecated('branch-coverage'), branchCoverage: boolArg('branch-coverage'),
); );
} }
...@@ -415,12 +415,12 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -415,12 +415,12 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
final DebuggingOptions debuggingOptions = DebuggingOptions.enabled( final DebuggingOptions debuggingOptions = DebuggingOptions.enabled(
buildInfo, buildInfo,
startPaused: startPaused, startPaused: startPaused,
disableServiceAuthCodes: boolArgDeprecated('disable-service-auth-codes'), disableServiceAuthCodes: boolArg('disable-service-auth-codes'),
serveObservatory: boolArgDeprecated('serve-observatory'), serveObservatory: boolArg('serve-observatory'),
// On iOS >=14, keeping this enabled will leave a prompt on the screen. // On iOS >=14, keeping this enabled will leave a prompt on the screen.
disablePortPublication: true, disablePortPublication: true,
enableDds: enableDds, enableDds: enableDds,
nullAssertions: boolArgDeprecated(FlutterOptions.kNullAssertions), nullAssertions: boolArg(FlutterOptions.kNullAssertions),
); );
Device? integrationTestDevice; Device? integrationTestDevice;
...@@ -464,23 +464,23 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -464,23 +464,23 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
tags: tags, tags: tags,
excludeTags: excludeTags, excludeTags: excludeTags,
watcher: watcher, watcher: watcher,
enableVmService: collector != null || startPaused || boolArgDeprecated('enable-vmservice'), enableVmService: collector != null || startPaused || boolArg('enable-vmservice'),
ipv6: boolArgDeprecated('ipv6'), ipv6: boolArg('ipv6'),
machine: machine, machine: machine,
updateGoldens: boolArgDeprecated('update-goldens'), updateGoldens: boolArg('update-goldens'),
concurrency: jobs, concurrency: jobs,
testAssetDirectory: testAssetDirectory, testAssetDirectory: testAssetDirectory,
flutterProject: flutterProject, flutterProject: flutterProject,
web: stringArgDeprecated('platform') == 'chrome', web: stringArg('platform') == 'chrome',
randomSeed: stringArgDeprecated('test-randomize-ordering-seed'), randomSeed: stringArg('test-randomize-ordering-seed'),
reporter: stringArgDeprecated('reporter'), reporter: stringArg('reporter'),
fileReporter: stringArg('file-reporter'), fileReporter: stringArg('file-reporter'),
timeout: stringArgDeprecated('timeout'), timeout: stringArg('timeout'),
runSkipped: boolArgDeprecated('run-skipped'), runSkipped: boolArg('run-skipped'),
shardIndex: shardIndex, shardIndex: shardIndex,
totalShards: totalShards, totalShards: totalShards,
integrationTestDevice: integrationTestDevice, integrationTestDevice: integrationTestDevice,
integrationTestUserIdentifier: stringArgDeprecated(FlutterOptions.kDeviceUser), integrationTestUserIdentifier: stringArg(FlutterOptions.kDeviceUser),
testTimeRecorder: testTimeRecorder, testTimeRecorder: testTimeRecorder,
); );
testTimeRecorder?.stop(TestTimePhases.TestRunner, testRunnerTimeRecorderStopwatch!); testTimeRecorder?.stop(TestTimePhases.TestRunner, testRunnerTimeRecorderStopwatch!);
...@@ -488,8 +488,8 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -488,8 +488,8 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
if (collector != null) { if (collector != null) {
final Stopwatch? collectTimeRecorderStopwatch = testTimeRecorder?.start(TestTimePhases.CoverageDataCollect); final Stopwatch? collectTimeRecorderStopwatch = testTimeRecorder?.start(TestTimePhases.CoverageDataCollect);
final bool collectionResult = await collector.collectCoverageData( final bool collectionResult = await collector.collectCoverageData(
stringArgDeprecated('coverage-path'), stringArg('coverage-path'),
mergeCoverageData: boolArgDeprecated('merge-coverage'), mergeCoverageData: boolArg('merge-coverage'),
); );
testTimeRecorder?.stop(TestTimePhases.CoverageDataCollect, collectTimeRecorderStopwatch!); testTimeRecorder?.stop(TestTimePhases.CoverageDataCollect, collectTimeRecorderStopwatch!);
if (!collectionResult) { if (!collectionResult) {
......
...@@ -179,15 +179,15 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -179,15 +179,15 @@ class UpdatePackagesCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final List<Directory> packages = runner!.getRepoPackages(); final List<Directory> packages = runner!.getRepoPackages();
final bool forceUpgrade = boolArgDeprecated('force-upgrade'); final bool forceUpgrade = boolArg('force-upgrade');
final bool isPrintPaths = boolArgDeprecated('paths'); final bool isPrintPaths = boolArg('paths');
final bool isPrintTransitiveClosure = boolArgDeprecated('transitive-closure'); final bool isPrintTransitiveClosure = boolArg('transitive-closure');
final bool isVerifyOnly = boolArgDeprecated('verify-only'); final bool isVerifyOnly = boolArg('verify-only');
final bool isConsumerOnly = boolArgDeprecated('consumer-only'); final bool isConsumerOnly = boolArg('consumer-only');
final bool offline = boolArgDeprecated('offline'); final bool offline = boolArg('offline');
final bool doUpgrade = forceUpgrade || isPrintPaths || isPrintTransitiveClosure; final bool doUpgrade = forceUpgrade || isPrintPaths || isPrintTransitiveClosure;
if (boolArgDeprecated('crash')) { if (boolArg('crash')) {
throw StateError('test crash please ignore.'); throw StateError('test crash please ignore.');
} }
...@@ -442,7 +442,7 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -442,7 +442,7 @@ class UpdatePackagesCommand extends FlutterCommand {
context: PubContext.updatePackages, context: PubContext.updatePackages,
project: FlutterProject.fromDirectory(syntheticPackageDir), project: FlutterProject.fromDirectory(syntheticPackageDir),
upgrade: doUpgrade, upgrade: doUpgrade,
offline: boolArgDeprecated('offline'), offline: boolArg('offline'),
flutterRootOverride: temporaryFlutterSdk?.path, flutterRootOverride: temporaryFlutterSdk?.path,
outputMode: PubOutputMode.none, outputMode: PubOutputMode.none,
); );
...@@ -484,15 +484,15 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -484,15 +484,15 @@ class UpdatePackagesCommand extends FlutterCommand {
} }
} }
if (boolArgDeprecated('transitive-closure')) { if (boolArg('transitive-closure')) {
tree._dependencyTree.forEach((String from, Set<String> to) { tree._dependencyTree.forEach((String from, Set<String> to) {
globals.printStatus('$from -> $to'); globals.printStatus('$from -> $to');
}); });
return true; return true;
} }
if (boolArgDeprecated('paths')) { if (boolArg('paths')) {
showDependencyPaths(from: stringArgDeprecated('from')!, to: stringArgDeprecated('to')!, tree: tree); showDependencyPaths(from: stringArg('from')!, to: stringArg('to')!, tree: tree);
return true; return true;
} }
...@@ -526,7 +526,7 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -526,7 +526,7 @@ class UpdatePackagesCommand extends FlutterCommand {
); );
try { try {
// int.tryParse will not accept null, but will convert empty string to null // int.tryParse will not accept null, but will convert empty string to null
final int? maxJobs = int.tryParse(stringArgDeprecated('jobs') ?? ''); final int? maxJobs = int.tryParse(stringArg('jobs') ?? '');
final TaskQueue<void> queue = TaskQueue<void>(maxJobs: maxJobs); final TaskQueue<void> queue = TaskQueue<void>(maxJobs: maxJobs);
for (final Directory dir in packages) { for (final Directory dir in packages) {
unawaited(queue.add(() async { unawaited(queue.add(() async {
......
...@@ -71,16 +71,16 @@ class UpgradeCommand extends FlutterCommand { ...@@ -71,16 +71,16 @@ class UpgradeCommand extends FlutterCommand {
@override @override
Future<FlutterCommandResult> runCommand() { Future<FlutterCommandResult> runCommand() {
_commandRunner.workingDirectory = stringArgDeprecated('working-directory') ?? Cache.flutterRoot!; _commandRunner.workingDirectory = stringArg('working-directory') ?? Cache.flutterRoot!;
return _commandRunner.runCommand( return _commandRunner.runCommand(
force: boolArgDeprecated('force'), force: boolArg('force'),
continueFlow: boolArgDeprecated('continue'), continueFlow: boolArg('continue'),
testFlow: stringArgDeprecated('working-directory') != null, testFlow: stringArg('working-directory') != null,
gitTagVersion: GitTagVersion.determine(globals.processUtils, globals.platform), gitTagVersion: GitTagVersion.determine(globals.processUtils, globals.platform),
flutterVersion: stringArgDeprecated('working-directory') == null flutterVersion: stringArg('working-directory') == null
? globals.flutterVersion ? globals.flutterVersion
: FlutterVersion(workingDirectory: _commandRunner.workingDirectory), : FlutterVersion(workingDirectory: _commandRunner.workingDirectory),
verifyOnly: boolArgDeprecated('verify-only'), verifyOnly: boolArg('verify-only'),
); );
} }
} }
......
...@@ -203,7 +203,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -203,7 +203,7 @@ abstract class FlutterCommand extends Command<void> {
DeprecationBehavior get deprecationBehavior => DeprecationBehavior.none; DeprecationBehavior get deprecationBehavior => DeprecationBehavior.none;
bool get shouldRunPub => _usesPubOption && boolArgDeprecated('pub'); bool get shouldRunPub => _usesPubOption && boolArg('pub');
bool get shouldUpdateCache => true; bool get shouldUpdateCache => true;
...@@ -320,7 +320,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -320,7 +320,7 @@ abstract class FlutterCommand extends Command<void> {
String get targetFile { String get targetFile {
if (argResults?.wasParsed('target') ?? false) { if (argResults?.wasParsed('target') ?? false) {
return stringArgDeprecated('target')!; return stringArg('target')!;
} }
final List<String>? rest = argResults?.rest; final List<String>? rest = argResults?.rest;
if (rest != null && rest.isNotEmpty) { if (rest != null && rest.isNotEmpty) {
...@@ -339,7 +339,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -339,7 +339,7 @@ abstract class FlutterCommand extends Command<void> {
/// This can be overridden by some of its subclasses. /// This can be overridden by some of its subclasses.
String? get fileSystemScheme => String? get fileSystemScheme =>
argParser.options.containsKey(FlutterOptions.kFileSystemScheme) argParser.options.containsKey(FlutterOptions.kFileSystemScheme)
? stringArgDeprecated(FlutterOptions.kFileSystemScheme) ? stringArg(FlutterOptions.kFileSystemScheme)
: null; : null;
/// The values of the `--filesystem-root` argument. /// The values of the `--filesystem-root` argument.
...@@ -485,7 +485,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -485,7 +485,7 @@ abstract class FlutterCommand extends Command<void> {
throwToolExit( throwToolExit(
'The "--[no-]dds" and "--[no-]disable-dds" arguments are mutually exclusive. Only specify "--[no-]dds".'); 'The "--[no-]dds" and "--[no-]disable-dds" arguments are mutually exclusive. Only specify "--[no-]dds".');
} }
ddsEnabled = !boolArgDeprecated('disable-dds'); ddsEnabled = !boolArg('disable-dds');
// TODO(ianh): enable the following code once google3 is migrated away from --disable-dds (and add test to flutter_command_test.dart) // TODO(ianh): enable the following code once google3 is migrated away from --disable-dds (and add test to flutter_command_test.dart)
if (false) { // ignore: dead_code if (false) { // ignore: dead_code
if (ddsEnabled) { if (ddsEnabled) {
...@@ -497,7 +497,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -497,7 +497,7 @@ abstract class FlutterCommand extends Command<void> {
} }
} }
} else { } else {
ddsEnabled = boolArgDeprecated('dds'); ddsEnabled = boolArg('dds');
} }
return ddsEnabled; return ddsEnabled;
}(); }();
...@@ -507,9 +507,9 @@ abstract class FlutterCommand extends Command<void> { ...@@ -507,9 +507,9 @@ abstract class FlutterCommand extends Command<void> {
|| (argResults?.wasParsed('host-vmservice-port') ?? false); || (argResults?.wasParsed('host-vmservice-port') ?? false);
int _tryParseHostVmservicePort() { int _tryParseHostVmservicePort() {
final String? vmServicePort = stringArgDeprecated(vmServicePortOption) ?? final String? vmServicePort = stringArg(vmServicePortOption) ??
stringArgDeprecated(observatoryPortOption); stringArg(observatoryPortOption);
final String? hostPort = stringArgDeprecated('host-vmservice-port'); final String? hostPort = stringArg('host-vmservice-port');
if (vmServicePort == null && hostPort == null) { if (vmServicePort == null && hostPort == null) {
throwToolExit('Invalid port for `--vm-service-port/--host-vmservice-port`'); throwToolExit('Invalid port for `--vm-service-port/--host-vmservice-port`');
} }
...@@ -526,7 +526,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -526,7 +526,7 @@ abstract class FlutterCommand extends Command<void> {
return _tryParseHostVmservicePort(); return _tryParseHostVmservicePort();
} else if (argResults?.wasParsed('dds-port') ?? false) { } else if (argResults?.wasParsed('dds-port') ?? false) {
// If an explicit DDS port is provided, use dds-port for DDS. // If an explicit DDS port is provided, use dds-port for DDS.
return int.tryParse(stringArgDeprecated('dds-port')!) ?? 0; return int.tryParse(stringArg('dds-port')!) ?? 0;
} }
// Otherwise, DDS can bind to a random port. // Otherwise, DDS can bind to a random port.
return 0; return 0;
...@@ -534,7 +534,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -534,7 +534,7 @@ abstract class FlutterCommand extends Command<void> {
Uri? get devToolsServerAddress { Uri? get devToolsServerAddress {
if (argResults?.wasParsed(kDevToolsServerAddress) ?? false) { if (argResults?.wasParsed(kDevToolsServerAddress) ?? false) {
final Uri? uri = Uri.tryParse(stringArgDeprecated(kDevToolsServerAddress)!); final Uri? uri = Uri.tryParse(stringArg(kDevToolsServerAddress)!);
if (uri != null && uri.host.isNotEmpty && uri.port != 0) { if (uri != null && uri.host.isNotEmpty && uri.port != 0) {
return uri; return uri;
} }
...@@ -572,7 +572,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -572,7 +572,7 @@ abstract class FlutterCommand extends Command<void> {
/// ///
/// If no port is set, returns null. /// If no port is set, returns null.
int? get deviceVmservicePort { int? get deviceVmservicePort {
final String? devicePort = stringArgDeprecated('device-vmservice-port'); final String? devicePort = stringArg('device-vmservice-port');
if (!_usesPortOption || devicePort == null) { if (!_usesPortOption || devicePort == null) {
return null; return null;
} }
...@@ -592,7 +592,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -592,7 +592,7 @@ abstract class FlutterCommand extends Command<void> {
); );
} }
Future<bool> get disablePortPublication async => !boolArgDeprecated('publish-port'); Future<bool> get disablePortPublication async => !boolArg('publish-port');
void usesIpv6Flag({required bool verboseHelp}) { void usesIpv6Flag({required bool verboseHelp}) {
argParser.addFlag(ipv6Flag, argParser.addFlag(ipv6Flag,
...@@ -605,7 +605,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -605,7 +605,7 @@ abstract class FlutterCommand extends Command<void> {
_usesIpv6Flag = true; _usesIpv6Flag = true;
} }
bool? get ipv6 => _usesIpv6Flag ? boolArgDeprecated('ipv6') : null; bool? get ipv6 => _usesIpv6Flag ? boolArg('ipv6') : null;
void usesBuildNumberOption() { void usesBuildNumberOption() {
argParser.addOption('build-number', argParser.addOption('build-number',
...@@ -701,7 +701,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -701,7 +701,7 @@ abstract class FlutterCommand extends Command<void> {
late final Duration? deviceDiscoveryTimeout = () { late final Duration? deviceDiscoveryTimeout = () {
if ((argResults?.options.contains(FlutterOptions.kDeviceTimeout) ?? false) if ((argResults?.options.contains(FlutterOptions.kDeviceTimeout) ?? false)
&& (argResults?.wasParsed(FlutterOptions.kDeviceTimeout) ?? false)) { && (argResults?.wasParsed(FlutterOptions.kDeviceTimeout) ?? false)) {
final int? timeoutSeconds = int.tryParse(stringArgDeprecated(FlutterOptions.kDeviceTimeout)!); final int? timeoutSeconds = int.tryParse(stringArg(FlutterOptions.kDeviceTimeout)!);
if (timeoutSeconds == null) { if (timeoutSeconds == null) {
throwToolExit( 'Could not parse "--${FlutterOptions.kDeviceTimeout}" argument. It must be an integer.'); throwToolExit( 'Could not parse "--${FlutterOptions.kDeviceTimeout}" argument. It must be an integer.');
} }
...@@ -975,13 +975,13 @@ abstract class FlutterCommand extends Command<void> { ...@@ -975,13 +975,13 @@ abstract class FlutterCommand extends Command<void> {
BuildMode getBuildMode() { BuildMode getBuildMode() {
// No debug when _excludeDebug is true. // No debug when _excludeDebug is true.
// If debug is not excluded, then take the command line flag. // If debug is not excluded, then take the command line flag.
final bool debugResult = !_excludeDebug && boolArgDeprecated('debug'); final bool debugResult = !_excludeDebug && boolArg('debug');
final bool jitReleaseResult = !_excludeRelease && boolArgDeprecated('jit-release'); final bool jitReleaseResult = !_excludeRelease && boolArg('jit-release');
final bool releaseResult = !_excludeRelease && boolArgDeprecated('release'); final bool releaseResult = !_excludeRelease && boolArg('release');
final List<bool> modeFlags = <bool>[ final List<bool> modeFlags = <bool>[
debugResult, debugResult,
jitReleaseResult, jitReleaseResult,
boolArgDeprecated('profile'), boolArg('profile'),
releaseResult, releaseResult,
]; ];
if (modeFlags.where((bool flag) => flag).length > 1) { if (modeFlags.where((bool flag) => flag).length > 1) {
...@@ -991,7 +991,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -991,7 +991,7 @@ abstract class FlutterCommand extends Command<void> {
if (debugResult) { if (debugResult) {
return BuildMode.debug; return BuildMode.debug;
} }
if (boolArgDeprecated('profile')) { if (boolArg('profile')) {
return BuildMode.profile; return BuildMode.profile;
} }
if (releaseResult) { if (releaseResult) {
...@@ -1066,10 +1066,10 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1066,10 +1066,10 @@ abstract class FlutterCommand extends Command<void> {
/// each other. /// each other.
Future<BuildInfo> getBuildInfo({ BuildMode? forcedBuildMode, File? forcedTargetFile }) async { Future<BuildInfo> getBuildInfo({ BuildMode? forcedBuildMode, File? forcedTargetFile }) async {
final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') && final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') &&
boolArgDeprecated('track-widget-creation'); boolArg('track-widget-creation');
final String? buildNumber = argParser.options.containsKey('build-number') final String? buildNumber = argParser.options.containsKey('build-number')
? stringArgDeprecated('build-number') ? stringArg('build-number')
: null; : null;
final File packagesFile = globals.fs.file( final File packagesFile = globals.fs.file(
...@@ -1099,13 +1099,13 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1099,13 +1099,13 @@ abstract class FlutterCommand extends Command<void> {
} }
String? codeSizeDirectory; String? codeSizeDirectory;
if (argParser.options.containsKey(FlutterOptions.kAnalyzeSize) && boolArgDeprecated(FlutterOptions.kAnalyzeSize)) { if (argParser.options.containsKey(FlutterOptions.kAnalyzeSize) && boolArg(FlutterOptions.kAnalyzeSize)) {
Directory directory = globals.fsUtils.getUniqueDirectory( Directory directory = globals.fsUtils.getUniqueDirectory(
globals.fs.directory(getBuildDirectory()), globals.fs.directory(getBuildDirectory()),
'flutter_size', 'flutter_size',
); );
if (argParser.options.containsKey(FlutterOptions.kCodeSizeDirectory) && stringArgDeprecated(FlutterOptions.kCodeSizeDirectory) != null) { if (argParser.options.containsKey(FlutterOptions.kCodeSizeDirectory) && stringArg(FlutterOptions.kCodeSizeDirectory) != null) {
directory = globals.fs.directory(stringArgDeprecated(FlutterOptions.kCodeSizeDirectory)); directory = globals.fs.directory(stringArg(FlutterOptions.kCodeSizeDirectory));
} }
directory.createSync(recursive: true); directory.createSync(recursive: true);
codeSizeDirectory = directory.path; codeSizeDirectory = directory.path;
...@@ -1140,7 +1140,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1140,7 +1140,7 @@ abstract class FlutterCommand extends Command<void> {
// This mode is only used for commands which do not build a single target like // This mode is only used for commands which do not build a single target like
// 'flutter test'. // 'flutter test'.
nullSafetyMode = NullSafetyMode.autodetect; nullSafetyMode = NullSafetyMode.autodetect;
} else if (boolArgDeprecated(FlutterOptions.kNullSafety)) { } else if (boolArg(FlutterOptions.kNullSafety)) {
nullSafetyMode = NullSafetyMode.sound; nullSafetyMode = NullSafetyMode.sound;
extraFrontEndOptions.add('--sound-null-safety'); extraFrontEndOptions.add('--sound-null-safety');
} else { } else {
...@@ -1150,14 +1150,14 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1150,14 +1150,14 @@ abstract class FlutterCommand extends Command<void> {
} }
final bool dartObfuscation = argParser.options.containsKey(FlutterOptions.kDartObfuscationOption) final bool dartObfuscation = argParser.options.containsKey(FlutterOptions.kDartObfuscationOption)
&& boolArgDeprecated(FlutterOptions.kDartObfuscationOption); && boolArg(FlutterOptions.kDartObfuscationOption);
final String? splitDebugInfoPath = argParser.options.containsKey(FlutterOptions.kSplitDebugInfoOption) final String? splitDebugInfoPath = argParser.options.containsKey(FlutterOptions.kSplitDebugInfoOption)
? stringArgDeprecated(FlutterOptions.kSplitDebugInfoOption) ? stringArg(FlutterOptions.kSplitDebugInfoOption)
: null; : null;
final bool androidGradleDaemon = !argParser.options.containsKey(FlutterOptions.kAndroidGradleDaemon) final bool androidGradleDaemon = !argParser.options.containsKey(FlutterOptions.kAndroidGradleDaemon)
|| boolArgDeprecated(FlutterOptions.kAndroidGradleDaemon); || boolArg(FlutterOptions.kAndroidGradleDaemon);
final List<String> androidProjectArgs = argParser.options.containsKey(FlutterOptions.kAndroidProjectArgs) final List<String> androidProjectArgs = argParser.options.containsKey(FlutterOptions.kAndroidProjectArgs)
? stringsArg(FlutterOptions.kAndroidProjectArgs) ? stringsArg(FlutterOptions.kAndroidProjectArgs)
...@@ -1179,10 +1179,10 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1179,10 +1179,10 @@ abstract class FlutterCommand extends Command<void> {
final bool treeShakeIcons = argParser.options.containsKey('tree-shake-icons') final bool treeShakeIcons = argParser.options.containsKey('tree-shake-icons')
&& buildMode.isPrecompiled == true && buildMode.isPrecompiled == true
&& boolArgDeprecated('tree-shake-icons'); && boolArg('tree-shake-icons');
final String? bundleSkSLPath = argParser.options.containsKey(FlutterOptions.kBundleSkSLPathOption) final String? bundleSkSLPath = argParser.options.containsKey(FlutterOptions.kBundleSkSLPathOption)
? stringArgDeprecated(FlutterOptions.kBundleSkSLPathOption) ? stringArg(FlutterOptions.kBundleSkSLPathOption)
: null; : null;
if (bundleSkSLPath != null && !globals.fs.isFileSync(bundleSkSLPath)) { if (bundleSkSLPath != null && !globals.fs.isFileSync(bundleSkSLPath)) {
...@@ -1190,7 +1190,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1190,7 +1190,7 @@ abstract class FlutterCommand extends Command<void> {
} }
final String? performanceMeasurementFile = argParser.options.containsKey(FlutterOptions.kPerformanceMeasurementFile) final String? performanceMeasurementFile = argParser.options.containsKey(FlutterOptions.kPerformanceMeasurementFile)
? stringArgDeprecated(FlutterOptions.kPerformanceMeasurementFile) ? stringArg(FlutterOptions.kPerformanceMeasurementFile)
: null; : null;
final Map<String, Object>? defineConfigJsonMap = extractDartDefineConfigJsonMap(); final Map<String, Object>? defineConfigJsonMap = extractDartDefineConfigJsonMap();
...@@ -1198,7 +1198,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1198,7 +1198,7 @@ abstract class FlutterCommand extends Command<void> {
WebRendererMode webRenderer = WebRendererMode.autoDetect; WebRendererMode webRenderer = WebRendererMode.autoDetect;
if (argParser.options.containsKey(FlutterOptions.kWebRendererFlag)) { if (argParser.options.containsKey(FlutterOptions.kWebRendererFlag)) {
final WebRendererMode? mappedMode = _webRendererModeMap[stringArgDeprecated(FlutterOptions.kWebRendererFlag)!]; final WebRendererMode? mappedMode = _webRendererModeMap[stringArg(FlutterOptions.kWebRendererFlag)!];
if (mappedMode != null) { if (mappedMode != null) {
webRenderer = mappedMode; webRenderer = mappedMode;
} }
...@@ -1207,7 +1207,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1207,7 +1207,7 @@ abstract class FlutterCommand extends Command<void> {
return BuildInfo(buildMode, return BuildInfo(buildMode,
argParser.options.containsKey('flavor') argParser.options.containsKey('flavor')
? stringArgDeprecated('flavor') ? stringArg('flavor')
: null, : null,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
extraFrontEndOptions: extraFrontEndOptions.isNotEmpty extraFrontEndOptions: extraFrontEndOptions.isNotEmpty
...@@ -1220,7 +1220,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1220,7 +1220,7 @@ abstract class FlutterCommand extends Command<void> {
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
buildNumber: buildNumber, buildNumber: buildNumber,
buildName: argParser.options.containsKey('build-name') buildName: argParser.options.containsKey('build-name')
? stringArgDeprecated('build-name') ? stringArg('build-name')
: null, : null,
treeShakeIcons: treeShakeIcons, treeShakeIcons: treeShakeIcons,
splitDebugInfoPath: splitDebugInfoPath, splitDebugInfoPath: splitDebugInfoPath,
...@@ -1238,10 +1238,10 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1238,10 +1238,10 @@ abstract class FlutterCommand extends Command<void> {
packageConfig: packageConfig, packageConfig: packageConfig,
androidProjectArgs: androidProjectArgs, androidProjectArgs: androidProjectArgs,
initializeFromDill: argParser.options.containsKey(FlutterOptions.kInitializeFromDill) initializeFromDill: argParser.options.containsKey(FlutterOptions.kInitializeFromDill)
? stringArgDeprecated(FlutterOptions.kInitializeFromDill) ? stringArg(FlutterOptions.kInitializeFromDill)
: null, : null,
assumeInitializeFromDillUpToDate: argParser.options.containsKey(FlutterOptions.kAssumeInitializeFromDillUpToDate) assumeInitializeFromDillUpToDate: argParser.options.containsKey(FlutterOptions.kAssumeInitializeFromDillUpToDate)
&& boolArgDeprecated(FlutterOptions.kAssumeInitializeFromDillUpToDate), && boolArg(FlutterOptions.kAssumeInitializeFromDillUpToDate),
); );
} }
...@@ -1280,7 +1280,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1280,7 +1280,7 @@ abstract class FlutterCommand extends Command<void> {
overrides: <Type, Generator>{FlutterCommand: () => this}, overrides: <Type, Generator>{FlutterCommand: () => this},
body: () async { body: () async {
if (_usesFatalWarnings) { if (_usesFatalWarnings) {
globals.logger.fatalWarnings = boolArgDeprecated(FlutterOptions.kFatalWarnings); globals.logger.fatalWarnings = boolArg(FlutterOptions.kFatalWarnings);
} }
// Prints the welcome message if needed. // Prints the welcome message if needed.
globals.flutterUsage.printWelcome(); globals.flutterUsage.printWelcome();
...@@ -1451,7 +1451,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1451,7 +1451,7 @@ abstract class FlutterCommand extends Command<void> {
// ios-deploy on macOS) are required to determine `requiredArtifacts`. // ios-deploy on macOS) are required to determine `requiredArtifacts`.
final bool offline; final bool offline;
if (argParser.options.containsKey('offline')) { if (argParser.options.containsKey('offline')) {
offline = boolArgDeprecated('offline'); offline = boolArg('offline');
} else { } else {
offline = false; offline = false;
} }
...@@ -1615,27 +1615,17 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1615,27 +1615,17 @@ abstract class FlutterCommand extends Command<void> {
ApplicationPackageFactory? applicationPackages; ApplicationPackageFactory? applicationPackages;
/// Gets the parsed command-line option named [name] as a `bool`. /// Gets the parsed command-line flag named [name] as a `bool`.
/// This has been deprecated, use [boolArg] instead. ///
bool boolArgDeprecated(String name) => argResults?[name] as bool? ?? false; /// If no flag named [name] was added to the [ArgParser], an [ArgumentError]
/// will be thrown.
/// Gets the parsed command-line option named [name] as a `bool?`. bool boolArg(String name) => argResults![name] as bool;
bool? boolArg(String name) {
if (!argParser.options.containsKey(name)) {
return null;
}
return argResults![name] as bool;
}
/// Gets the parsed command-line option named [name] as a `String`. /// Gets the parsed command-line option named [name] as a `String`.
String? stringArgDeprecated(String name) => argResults?[name] as String?; ///
/// If no option named [name] was added to the [ArgParser], an [ArgumentError]
String? stringArg(String name) { /// will be thrown.
if (!argParser.options.containsKey(name)) { String? stringArg(String name) => argResults![name] as String?;
return null;
}
return argResults![name] as String?;
}
/// Gets the parsed command-line option named [name] as `List<String>`. /// Gets the parsed command-line option named [name] as `List<String>`.
List<String> stringsArg(String name) { List<String> stringsArg(String name) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:async'; import 'dart:async';
import 'package:args/command_runner.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_device.dart'; import 'package:flutter_tools/src/android/android_device.dart';
...@@ -673,6 +674,23 @@ void main() { ...@@ -673,6 +674,23 @@ void main() {
FakeDevice(targetPlatform: TargetPlatform.android_arm, platformType: PlatformType.android), FakeDevice(targetPlatform: TargetPlatform.android_arm, platformType: PlatformType.android),
]; ];
final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices); final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices);
final CommandRunner<void> runner = createTestCommandRunner(command);
try {
// run the command so that CLI args are parsed
await runner.run(<String>['run']);
} on ToolExit catch (error) {
// we can ignore the ToolExit, as we are only interested in
// command.usageValues.
expect(
error,
isA<ToolExit>().having(
(ToolExit exception) => exception.message,
'message',
contains('No pubspec.yaml file found'),
),
);
}
final CustomDimensions dimensions = await command.usageValues; final CustomDimensions dimensions = await command.usageValues;
expect(dimensions, const CustomDimensions( expect(dimensions, const CustomDimensions(
...@@ -696,6 +714,23 @@ void main() { ...@@ -696,6 +714,23 @@ void main() {
FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.usb, sdkNameAndVersion: 'iOS 16.2'), FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.usb, sdkNameAndVersion: 'iOS 16.2'),
]; ];
final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices); final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices);
final CommandRunner<void> runner = createTestCommandRunner(command);
try {
// run the command so that CLI args are parsed
await runner.run(<String>['run']);
} on ToolExit catch (error) {
// we can ignore the ToolExit, as we are only interested in
// command.usageValues.
expect(
error,
isA<ToolExit>().having(
(ToolExit exception) => exception.message,
'message',
contains('No pubspec.yaml file found'),
),
);
}
final CustomDimensions dimensions = await command.usageValues; final CustomDimensions dimensions = await command.usageValues;
expect(dimensions, const CustomDimensions( expect(dimensions, const CustomDimensions(
...@@ -720,6 +755,23 @@ void main() { ...@@ -720,6 +755,23 @@ void main() {
FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.network, sdkNameAndVersion: 'iOS 16.2'), FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.network, sdkNameAndVersion: 'iOS 16.2'),
]; ];
final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices); final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices);
final CommandRunner<void> runner = createTestCommandRunner(command);
try {
// run the command so that CLI args are parsed
await runner.run(<String>['run']);
} on ToolExit catch (error) {
// we can ignore the ToolExit, as we are only interested in
// command.usageValues.
expect(
error,
isA<ToolExit>().having(
(ToolExit exception) => exception.message,
'message',
contains('No pubspec.yaml file found'),
),
);
}
final CustomDimensions dimensions = await command.usageValues; final CustomDimensions dimensions = await command.usageValues;
expect(dimensions, const CustomDimensions( expect(dimensions, const CustomDimensions(
...@@ -745,6 +797,22 @@ void main() { ...@@ -745,6 +797,22 @@ void main() {
FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.usb, sdkNameAndVersion: 'iOS 16.2'), FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.usb, sdkNameAndVersion: 'iOS 16.2'),
]; ];
final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices); final TestRunCommandForUsageValues command = TestRunCommandForUsageValues(devices: devices);
final CommandRunner<void> runner = createTestCommandRunner(command);
try {
// run the command so that CLI args are parsed
await runner.run(<String>['run']);
} on ToolExit catch (error) {
// we can ignore the ToolExit, as we are only interested in
// command.usageValues.
expect(
error,
isA<ToolExit>().having(
(ToolExit exception) => exception.message,
'message',
contains('No pubspec.yaml file found'),
),
);
}
final CustomDimensions dimensions = await command.usageValues; final CustomDimensions dimensions = await command.usageValues;
expect(dimensions, const CustomDimensions( expect(dimensions, const CustomDimensions(
......
...@@ -47,13 +47,13 @@ void main() { ...@@ -47,13 +47,13 @@ void main() {
await runner.run(<String>['dummy', '--key']); await runner.run(<String>['dummy', '--key']);
expect(command.boolArg('key'), true); expect(command.boolArg('key'), true);
expect(command.boolArg('empty'), null); expect(() => command.boolArg('non-existent'), throwsArgumentError);
expect(command.boolArgDeprecated('key'), true); expect(command.boolArg('key'), true);
expect(() => command.boolArgDeprecated('empty'), throwsA(const TypeMatcher<ArgumentError>())); expect(() => command.boolArg('non-existent'), throwsA(const TypeMatcher<ArgumentError>()));
expect(command.boolArg('key-false'), false); expect(command.boolArg('key-false'), false);
expect(command.boolArgDeprecated('key-false'), false); expect(command.boolArg('key-false'), false);
}); });
testUsingContext('String? safe argResults', () async { testUsingContext('String? safe argResults', () async {
...@@ -72,10 +72,10 @@ void main() { ...@@ -72,10 +72,10 @@ void main() {
await runner.run(<String>['dummy', '--key=value']); await runner.run(<String>['dummy', '--key=value']);
expect(command.stringArg('key'), 'value'); expect(command.stringArg('key'), 'value');
expect(command.stringArg('empty'), null); expect(() => command.stringArg('non-existent'), throwsArgumentError);
expect(command.stringArgDeprecated('key'), 'value'); expect(command.stringArg('key'), 'value');
expect(() => command.stringArgDeprecated('empty'), throwsA(const TypeMatcher<ArgumentError>())); expect(() => command.stringArg('non-existent'), throwsA(const TypeMatcher<ArgumentError>()));
}); });
testUsingContext('List<String> safe argResults', () async { testUsingContext('List<String> safe argResults', () async {
...@@ -97,7 +97,7 @@ void main() { ...@@ -97,7 +97,7 @@ void main() {
await runner.run(<String>['dummy', '--key', 'a']); await runner.run(<String>['dummy', '--key', 'a']);
// throws error when trying to parse non-existent key. // throws error when trying to parse non-existent key.
expect(() => command.stringsArg('empty'),throwsA(const TypeMatcher<ArgumentError>())); expect(() => command.stringsArg('non-existent'), throwsA(const TypeMatcher<ArgumentError>()));
expect(command.stringsArg('key'), <String>['a']); expect(command.stringsArg('key'), <String>['a']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment