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 {
@override
bool get shouldRunPub {
// If they're not analyzing the current project.
if (!boolArgDeprecated('current-package')) {
if (!boolArg('current-package')) {
return false;
}
......@@ -135,7 +135,7 @@ class AnalyzeCommand extends FlutterCommand {
}
// Don't run pub if asking for machine output.
if (boolArg('machine') != null && boolArg('machine')!) {
if (boolArg('machine')) {
return false;
}
......@@ -144,12 +144,9 @@ class AnalyzeCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> runCommand() async {
final bool? suggestionFlag = boolArg('suggestions');
final bool machineFlag = boolArg('machine') ?? false;
if (suggestionFlag != null && suggestionFlag == true) {
if (boolArg('suggestions')) {
final String directoryPath;
final bool? watchFlag = boolArg('watch');
if (watchFlag != null && watchFlag) {
if (boolArg('watch')) {
throwToolExit('flag --watch is not compatible with --suggestions');
}
if (workingDirectory == null) {
......@@ -171,9 +168,9 @@ class AnalyzeCommand extends FlutterCommand {
allProjectValidators: _allProjectValidators,
userPath: directoryPath,
processManager: _processManager,
machine: machineFlag,
machine: boolArg('machine'),
).run();
} else if (boolArgDeprecated('watch')) {
} else if (boolArg('watch')) {
await AnalyzeContinuously(
argResults!,
runner!.getRepoRoots(),
......
......@@ -209,7 +209,7 @@ class AssembleCommand extends FlutterCommand {
/// The environmental configuration for a build invocation.
Environment createEnvironment() {
final FlutterProject flutterProject = FlutterProject.current();
String? output = stringArgDeprecated('output');
String? output = stringArg('output');
if (output == null) {
throwToolExit('--output directory is required for assemble.');
}
......@@ -317,7 +317,7 @@ class AssembleCommand extends FlutterCommand {
environment,
buildSystemConfig: BuildSystemConfig(
resourcePoolSize: argumentResults.wasParsed('resource-pool-size')
? int.tryParse(stringArgDeprecated('resource-pool-size')!)
? int.tryParse(stringArg('resource-pool-size')!)
: null,
),
);
......@@ -334,17 +334,17 @@ class AssembleCommand extends FlutterCommand {
globals.printTrace('build succeeded.');
if (argumentResults.wasParsed('build-inputs')) {
writeListIfChanged(result.inputFiles, stringArgDeprecated('build-inputs')!);
writeListIfChanged(result.inputFiles, stringArg('build-inputs')!);
}
if (argumentResults.wasParsed('build-outputs')) {
writeListIfChanged(result.outputFiles, stringArgDeprecated('build-outputs')!);
writeListIfChanged(result.outputFiles, stringArg('build-outputs')!);
}
if (argumentResults.wasParsed('performance-measurement-file')) {
final File outFile = globals.fs.file(argumentResults['performance-measurement-file']);
writePerformanceData(result.performance.values, outFile);
}
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 DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
......
......@@ -181,19 +181,20 @@ known, it can be explicitly provided to attach via the command-line, e.g.
return null;
}
try {
return int.parse(stringArgDeprecated('debug-port')!);
return int.parse(stringArg('debug-port')!);
} on Exception catch (error) {
throwToolExit('Invalid port for `--debug-port`: $error');
}
}
Uri? get debugUri {
if (argResults!['debug-url'] == null) {
final String? debugUrl = stringArg('debug-url');
if (debugUrl == null) {
return null;
}
final Uri? uri = Uri.tryParse(stringArgDeprecated('debug-url')!);
final Uri? uri = Uri.tryParse(debugUrl);
if (uri == null) {
throwToolExit('Invalid `--debug-url`: ${stringArgDeprecated('debug-url')}');
throwToolExit('Invalid `--debug-url`: $debugUrl');
}
if (!uri.hasPort) {
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.
return uri;
}
bool get serveObservatory => boolArg('serve-observatory') ?? false;
bool get serveObservatory => boolArg('serve-observatory');
String? get appId {
return stringArgDeprecated('app-id');
return stringArg('app-id');
}
String? get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser);
String? get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
@override
Future<void> validateCommand() async {
......@@ -268,7 +269,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
Future<void> _attachToDevice(Device device) async {
final FlutterProject flutterProject = FlutterProject.current();
final Daemon? daemon = boolArgDeprecated('machine')
final Daemon? daemon = boolArg('machine')
? Daemon(
DaemonConnection(
daemonStreams: DaemonStreams.fromStdio(_stdio, logger: _logger),
......@@ -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 (device is FuchsiaDevice) {
final String? module = stringArgDeprecated('module');
final String? module = stringArg('module');
if (module == null) {
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.
connectionInfoCompleter: connectionInfoCompleter,
appStartedCompleter: appStartedCompleter,
allowExistingDdsInstance: true,
enableDevTools: boolArgDeprecated(FlutterCommand.kEnableDevTools),
enableDevTools: boolArg(FlutterCommand.kEnableDevTools),
);
},
device,
......@@ -460,8 +461,8 @@ known, it can be explicitly provided to attach via the command-line, e.g.
terminal: _terminal,
signals: _signals,
processInfo: _processInfo,
reportReady: boolArgDeprecated('report-ready'),
pidFile: stringArgDeprecated('pid-file'),
reportReady: boolArg('report-ready'),
pidFile: stringArg('pid-file'),
)
..registerSignalHandlers()
..setupTerminal();
......@@ -469,7 +470,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
result = await runner.attach(
appStartedCompleter: onAppStart,
allowExistingDdsInstance: true,
enableDevTools: boolArgDeprecated(FlutterCommand.kEnableDevTools),
enableDevTools: boolArg(FlutterCommand.kEnableDevTools),
);
if (result != 0) {
throwToolExit(null, exitCode: result);
......@@ -505,7 +506,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
final FlutterDevice flutterDevice = await FlutterDevice.create(
device,
target: targetFile,
targetModel: TargetModel(stringArgDeprecated('target-model')!),
targetModel: TargetModel(stringArg('target-model')!),
buildInfo: buildInfo,
userIdentifier: userIdentifier,
platform: _platform,
......@@ -526,8 +527,8 @@ known, it can be explicitly provided to attach via the command-line, e.g.
target: targetFile,
debuggingOptions: debuggingOptions,
packagesFilePath: globalResults!['packages'] as String?,
projectRootPath: stringArgDeprecated('project-root'),
dillOutputPath: stringArgDeprecated('output-dill'),
projectRootPath: stringArg('project-root'),
dillOutputPath: stringArg('output-dill'),
ipv6: usesIpv6,
flutterProject: flutterProject,
)
......
......@@ -6,7 +6,6 @@ import '../android/android_builder.dart';
import '../android/android_sdk.dart';
import '../android/gradle_utils.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/os.dart';
import '../build_info.dart';
......@@ -113,7 +112,7 @@ class BuildAarCommand extends BuildSubCommand {
final Iterable<AndroidArch> targetArchitectures =
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')
&& buildNumberArg != null
&& buildNumberArg.isNotEmpty
......@@ -122,7 +121,7 @@ class BuildAarCommand extends BuildSubCommand {
final File targetFile = _fileSystem.file(_fileSystem.path.join('lib', 'main.dart'));
for (final String buildMode in const <String>['debug', 'profile', 'release']) {
if (boolArgDeprecated(buildMode)) {
if (boolArg(buildMode)) {
androidBuildInfo.add(
AndroidBuildInfo(
await getBuildInfo(
......
......@@ -58,9 +58,9 @@ class BuildApkCommand extends BuildSubCommand {
final String name = 'apk';
@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
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
......@@ -80,11 +80,11 @@ class BuildApkCommand extends BuildSubCommand {
Future<CustomDimensions> get usageValues async {
String buildMode;
if (boolArgDeprecated('release')) {
if (boolArg('release')) {
buildMode = 'release';
} else if (boolArgDeprecated('debug')) {
} else if (boolArg('debug')) {
buildMode = 'debug';
} else if (boolArgDeprecated('profile')) {
} else if (boolArg('profile')) {
buildMode = 'profile';
} else {
// The build defaults to release.
......@@ -94,7 +94,7 @@ class BuildApkCommand extends BuildSubCommand {
return CustomDimensions(
commandBuildApkTargetPlatform: stringsArg('target-platform').join(','),
commandBuildApkBuildMode: buildMode,
commandBuildApkSplitPerAbi: boolArgDeprecated('split-per-abi'),
commandBuildApkSplitPerAbi: boolArg('split-per-abi'),
);
}
......@@ -106,9 +106,9 @@ class BuildApkCommand extends BuildSubCommand {
final BuildInfo buildInfo = await getBuildInfo();
final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo(
buildInfo,
splitPerAbi: boolArgDeprecated('split-per-abi'),
splitPerAbi: boolArg('split-per-abi'),
targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName),
multidexEnabled: boolArgDeprecated('multidex'),
multidexEnabled: boolArg('multidex'),
);
validateBuild(androidBuildInfo);
displayNullSafetyMode(androidBuildInfo.buildInfo);
......
......@@ -70,7 +70,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
final String name = 'appbundle';
@override
DeprecationBehavior get deprecationBehavior => boolArgDeprecated('ignore-deprecation') ? DeprecationBehavior.ignore : DeprecationBehavior.exit;
DeprecationBehavior get deprecationBehavior => boolArg('ignore-deprecation') ? DeprecationBehavior.ignore : DeprecationBehavior.exit;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
......@@ -88,11 +88,11 @@ class BuildAppBundleCommand extends BuildSubCommand {
Future<CustomDimensions> get usageValues async {
String buildMode;
if (boolArgDeprecated('release')) {
if (boolArg('release')) {
buildMode = 'release';
} else if (boolArgDeprecated('debug')) {
} else if (boolArg('debug')) {
buildMode = 'debug';
} else if (boolArgDeprecated('profile')) {
} else if (boolArg('profile')) {
buildMode = 'profile';
} else {
// The build defaults to release.
......@@ -113,12 +113,12 @@ class BuildAppBundleCommand extends BuildSubCommand {
final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo(await getBuildInfo(),
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
// require generated loading units are done after gen_snapshot in assemble.
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(
FlutterProject.current().directory,
globals.logger,
......@@ -154,8 +154,8 @@ class BuildAppBundleCommand extends BuildSubCommand {
project: FlutterProject.current(),
target: targetFile,
androidBuildInfo: androidBuildInfo,
validateDeferredComponents: boolArgDeprecated('validate-deferred-components'),
deferredComponentsEnabled: boolArgDeprecated('deferred-components') && !boolArgDeprecated('debug'),
validateDeferredComponents: boolArg('validate-deferred-components'),
deferredComponentsEnabled: boolArg('deferred-components') && !boolArg('debug'),
);
return FlutterCommandResult.success();
}
......
......@@ -78,14 +78,14 @@ class BuildBundleCommand extends BuildSubCommand {
final String projectDir = globals.fs.file(targetFile).parent.parent.path;
final FlutterProject flutterProject = FlutterProject.fromDirectory(globals.fs.directory(projectDir));
return CustomDimensions(
commandBuildBundleTargetPlatform: stringArgDeprecated('target-platform'),
commandBuildBundleTargetPlatform: stringArg('target-platform'),
commandBuildBundleIsModule: flutterProject.isModule,
);
}
@override
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.');
}
return super.validateCommand();
......@@ -93,7 +93,7 @@ class BuildBundleCommand extends BuildSubCommand {
@override
Future<FlutterCommandResult> runCommand() async {
final String targetPlatform = stringArgDeprecated('target-platform')!;
final String targetPlatform = stringArg('target-platform')!;
final TargetPlatform platform = getTargetPlatformForName(targetPlatform);
// Check for target platforms that are only allowed via feature flags.
switch (platform) {
......@@ -133,8 +133,8 @@ class BuildBundleCommand extends BuildSubCommand {
platform: platform,
buildInfo: buildInfo,
mainPath: targetFile,
depfilePath: stringArgDeprecated('depfile'),
assetDirPath: stringArgDeprecated('asset-dir'),
depfilePath: stringArg('depfile'),
assetDirPath: stringArg('asset-dir'),
);
return FlutterCommandResult.success();
}
......
......@@ -49,10 +49,10 @@ class BuildIOSCommand extends _BuildIOSSubCommand {
final XcodeBuildAction xcodeBuildAction = XcodeBuildAction.build;
@override
EnvironmentType get environmentType => boolArgDeprecated('simulator') ? EnvironmentType.simulator : EnvironmentType.physical;
EnvironmentType get environmentType => boolArg('simulator') ? EnvironmentType.simulator : EnvironmentType.physical;
@override
bool get configOnly => boolArgDeprecated('config-only');
bool get configOnly => boolArg('config-only');
@override
Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs.directory(xcodeResultOutput).parent;
......@@ -131,7 +131,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
@override
final bool configOnly = false;
String? get exportOptionsPlist => stringArgDeprecated('export-options-plist');
String? get exportOptionsPlist => stringArg('export-options-plist');
@override
Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs
......@@ -455,7 +455,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
final String relativeOutputPath = app.ipaOutputPath;
final String absoluteOutputPath = globals.fs.path.absolute(relativeOutputPath);
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';
File? generatedExportPlist;
try {
......@@ -540,7 +540,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
<plist version="1.0">
<dict>
<key>method</key>
<string>${stringArgDeprecated('export-method')}</string>
<string>${stringArg('export-method')}</string>
<key>uploadBitcode</key>
<false/>
</dict>
......@@ -596,7 +596,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
EnvironmentType get environmentType;
bool get configOnly;
bool get shouldCodesign => boolArgDeprecated('codesign');
bool get shouldCodesign => boolArg('codesign');
late final Future<BuildInfo> cachedBuildInfo = getBuildInfo();
......
......@@ -109,13 +109,13 @@ abstract class BuildFrameworkCommand extends BuildSubCommand {
Future<List<BuildInfo>> getBuildInfos() async {
final List<BuildInfo> buildInfos = <BuildInfo>[];
if (boolArgDeprecated('debug')) {
if (boolArg('debug')) {
buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.debug));
}
if (boolArgDeprecated('profile')) {
if (boolArg('profile')) {
buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.profile));
}
if (boolArgDeprecated('release')) {
if (boolArg('release')) {
buildInfos.add(await getBuildInfo(forcedBuildMode: BuildMode.release));
}
......@@ -216,14 +216,14 @@ class BuildIOSFrameworkCommand extends BuildFrameworkCommand {
Future<void> validateCommand() async {
await super.validateCommand();
if (boolArgDeprecated('universal')) {
if (boolArg('universal')) {
throwToolExit('--universal has been deprecated, only XCFrameworks are supported.');
}
}
@override
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');
if (outputArgument.isEmpty) {
......@@ -247,8 +247,8 @@ class BuildIOSFrameworkCommand extends BuildFrameworkCommand {
modeDirectory.deleteSync(recursive: true);
}
if (boolArgDeprecated('cocoapods')) {
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArgDeprecated('force'));
if (boolArg('cocoapods')) {
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force'));
} else {
// Copy Flutter.xcframework.
await _produceFlutterFramework(buildInfo, modeDirectory);
......@@ -496,7 +496,7 @@ end
'SYMROOT=${iPhoneBuildOutput.path}',
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
if (boolArg('static') ?? false)
if (boolArg('static'))
'MACH_O_TYPE=staticlib',
];
......@@ -522,7 +522,7 @@ end
'SYMROOT=${simulatorBuildOutput.path}',
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
if (boolArg('static') ?? false)
if (boolArg('static'))
'MACH_O_TYPE=staticlib',
];
......
......@@ -60,7 +60,7 @@ class BuildLinuxCommand extends BuildSubCommand {
final BuildInfo buildInfo = await getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current();
final TargetPlatform targetPlatform =
getTargetPlatformForName(stringArgDeprecated('target-platform')!);
getTargetPlatformForName(stringArg('target-platform')!);
final bool needCrossBuild =
getNameForHostPlatformArch(_operatingSystemUtils.hostPlatform)
!= getNameForTargetPlatformArch(targetPlatform);
......@@ -94,7 +94,7 @@ class BuildLinuxCommand extends BuildSubCommand {
),
needCrossBuild: needCrossBuild,
targetPlatform: targetPlatform,
targetSysroot: stringArgDeprecated('target-sysroot')!,
targetSysroot: stringArg('target-sysroot')!,
);
return FlutterCommandResult.success();
}
......
......@@ -46,7 +46,7 @@ class BuildMacosCommand extends BuildSubCommand {
@override
bool get supported => globals.platform.isMacOS;
bool get configOnly => boolArgDeprecated('config-only');
bool get configOnly => boolArg('config-only');
@override
Future<FlutterCommandResult> runCommand() async {
......
......@@ -80,8 +80,8 @@ class BuildMacOSFrameworkCommand extends BuildFrameworkCommand {
modeDirectory.deleteSync(recursive: true);
}
if (boolArg('cocoapods') ?? false) {
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force') ?? false);
if (boolArg('cocoapods')) {
produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force'));
}
// Build aot, create App.framework and copy FlutterMacOS.framework. Make XCFrameworks.
......@@ -240,7 +240,7 @@ end
final Directory flutterFramework = outputBuildDirectory.childDirectory('FlutterMacOS.framework');
// If FlutterMacOS.podspec was generated, do not generate XCFramework.
if (!(boolArg('cocoapods') ?? false)) {
if (!boolArg('cocoapods')) {
await BuildFrameworkCommand.produceXCFramework(
<Directory>[flutterFramework],
'FlutterMacOS',
......@@ -269,7 +269,7 @@ end
'SYMROOT=${buildOutput.path}',
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
'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(
......
......@@ -132,18 +132,18 @@ class BuildWebCommand extends BuildSubCommand {
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) {
throwToolExit('Compiling to WebAssembly (wasm) is only available on the master channel.');
}
final FlutterProject flutterProject = FlutterProject.current();
final String target = stringArgDeprecated('target')!;
final String target = stringArg('target')!;
final BuildInfo buildInfo = await getBuildInfo();
if (buildInfo.isDebug) {
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('/'))) {
throwToolExit('base-href should start and end with /');
}
......@@ -171,16 +171,16 @@ class BuildWebCommand extends BuildSubCommand {
flutterProject,
target,
buildInfo,
boolArgDeprecated('csp'),
stringArgDeprecated('pwa-strategy')!,
boolArgDeprecated('source-maps'),
boolArgDeprecated('native-null-assertions'),
boolArg('csp'),
stringArg('pwa-strategy')!,
boolArg('source-maps'),
boolArg('native-null-assertions'),
wasmRequested,
baseHref: baseHref,
dart2jsOptimization: stringArgDeprecated('dart2js-optimization') ?? kDart2jsDefaultOptimizationLevel,
dart2jsOptimization: stringArg('dart2js-optimization') ?? kDart2jsDefaultOptimizationLevel,
outputDirectoryPath: outputDirectoryPath,
dumpInfo: boolArgDeprecated('dump-info'),
noFrequencyBasedMinification: boolArgDeprecated('no-frequency-based-minification'),
dumpInfo: boolArg('dump-info'),
noFrequencyBasedMinification: boolArg('no-frequency-based-minification'),
);
return FlutterCommandResult.success();
}
......
......@@ -39,7 +39,7 @@ class ChannelCommand extends FlutterCommand {
switch (rest.length) {
case 0:
await _listChannels(
showAll: boolArgDeprecated('all'),
showAll: boolArg('all'),
verbose: globalResults?['verbose'] == true,
);
return FlutterCommandResult.success();
......
......@@ -111,12 +111,12 @@ class ConfigCommand extends FlutterCommand {
' flutter config --android-studio-dir "/opt/Android Studio"');
}
if (boolArgDeprecated('machine')) {
if (boolArg('machine')) {
await handleMachine();
return FlutterCommandResult.success();
}
if (boolArgDeprecated('clear-features')) {
if (boolArg('clear-features')) {
for (final Feature feature in allFeatures) {
final String? configSetting = feature.configSetting;
if (configSetting != null) {
......@@ -127,7 +127,7 @@ class ConfigCommand extends FlutterCommand {
}
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
// intentionally to be sure that opt-out events are sent correctly.
AnalyticsConfigEvent(enabled: value).send();
......@@ -142,11 +142,11 @@ class ConfigCommand extends FlutterCommand {
}
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) {
_updateConfig('android-studio-dir', stringArgDeprecated('android-studio-dir')!);
_updateConfig('android-studio-dir', stringArg('android-studio-dir')!);
}
if (argResults?.wasParsed('clear-ios-signing-cert') ?? false) {
......@@ -154,7 +154,7 @@ class ConfigCommand extends FlutterCommand {
}
if (argResults?.wasParsed('build-dir') ?? false) {
final String buildDir = stringArgDeprecated('build-dir')!;
final String buildDir = stringArg('build-dir')!;
if (globals.fs.path.isAbsolute(buildDir)) {
throwToolExit('build-dir should be a relative path');
}
......@@ -167,7 +167,7 @@ class ConfigCommand extends FlutterCommand {
continue;
}
if (argResults?.wasParsed(configSetting) ?? false) {
final bool keyValue = boolArgDeprecated(configSetting);
final bool keyValue = boolArg(configSetting);
globals.config.setValue(configSetting, keyValue);
globals.printStatus('Setting "$configSetting" value to "$keyValue".');
}
......
......@@ -95,9 +95,9 @@ class CreateCommand extends CreateBase {
@override
Future<CustomDimensions> get usageValues async {
return CustomDimensions(
commandCreateProjectType: stringArgDeprecated('template'),
commandCreateAndroidLanguage: stringArgDeprecated('android-language'),
commandCreateIosLanguage: stringArgDeprecated('ios-language'),
commandCreateProjectType: stringArg('template'),
commandCreateAndroidLanguage: stringArg('android-language'),
commandCreateIosLanguage: stringArg('ios-language'),
);
}
......@@ -207,7 +207,7 @@ class CreateCommand extends CreateBase {
validateOutputDirectoryArg();
String? sampleCode;
final String? sampleArgument = stringArg('sample');
final bool emptyArgument = boolArg('empty') ?? false;
final bool emptyArgument = boolArg('empty');
if (sampleArgument != null) {
final String? templateArgument = stringArg('template');
if (templateArgument != null && stringToProjectType(templateArgument) != FlutterProjectType.app) {
......@@ -256,10 +256,10 @@ class CreateCommand extends CreateBase {
final String organization = await getOrganization();
final bool overwrite = boolArgDeprecated('overwrite');
final bool overwrite = boolArg('overwrite');
validateProjectDir(overwrite: overwrite);
if (boolArgDeprecated('with-driver-test')) {
if (boolArg('with-driver-test')) {
globals.printWarning(
'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 '
......@@ -309,13 +309,13 @@ class CreateCommand extends CreateBase {
organization: organization,
projectName: projectName,
titleCaseProjectName: titleCaseProjectName,
projectDescription: stringArgDeprecated('description'),
projectDescription: stringArg('description'),
flutterRoot: flutterRoot,
withPlatformChannelPluginHook: generateMethodChannelsPlugin,
withFfiPluginHook: generateFfiPlugin,
withEmptyMain: emptyArgument,
androidLanguage: stringArgDeprecated('android-language'),
iosLanguage: stringArgDeprecated('ios-language'),
androidLanguage: stringArg('android-language'),
iosLanguage: stringArg('ios-language'),
iosDevelopmentTeam: developmentTeam,
ios: includeIos,
android: includeAndroid,
......@@ -324,7 +324,7 @@ class CreateCommand extends CreateBase {
macos: includeMacos,
windows: includeWindows,
dartSdkVersionBounds: "'>=$dartSdk <4.0.0'",
implementationTests: boolArgDeprecated('implementation-tests'),
implementationTests: boolArg('implementation-tests'),
agpVersion: gradle.templateAndroidGradlePluginVersion,
kotlinVersion: gradle.templateKotlinGradlePluginVersion,
gradleVersion: gradle.templateDefaultGradleVersion,
......@@ -408,12 +408,12 @@ class CreateCommand extends CreateBase {
break;
}
if (boolArgDeprecated('pub')) {
if (boolArg('pub')) {
final FlutterProject project = FlutterProject.fromDirectory(relativeDir);
await pub.get(
context: pubContext,
project: project,
offline: boolArgDeprecated('offline'),
offline: boolArg('offline'),
outputMode: PubOutputMode.summaryOnly,
);
await project.ensureReadyForPlatformSpecificTooling(
......@@ -505,7 +505,7 @@ Your $application code is in $relativeAppMain.
}) async {
int generatedCount = 0;
final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description')
? stringArg('description')
: 'A new Flutter module project.';
templateContext['description'] = description;
generatedCount += await renderTemplate(
......@@ -526,7 +526,7 @@ Your $application code is in $relativeAppMain.
}) async {
int generatedCount = 0;
final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description')
? stringArg('description')
: 'A new Flutter package project.';
templateContext['description'] = description;
generatedCount += await renderTemplate(
......@@ -564,7 +564,7 @@ Your $application code is in $relativeAppMain.
templateContext['no_platforms'] = !willAddPlatforms;
int generatedCount = 0;
final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description')
? stringArg('description')
: 'A new Flutter plugin project.';
templateContext['description'] = description;
generatedCount += await renderMerged(
......@@ -634,7 +634,7 @@ Your $application code is in $relativeAppMain.
templateContext['no_platforms'] = !willAddPlatforms;
int generatedCount = 0;
final String? description = argResults!.wasParsed('description')
? stringArgDeprecated('description')
? stringArg('description')
: 'A new Flutter FFI plugin project.';
templateContext['description'] = description;
generatedCount += await renderMerged(
......
......@@ -253,7 +253,7 @@ abstract class CreateBase extends FlutterCommand {
/// If `--org` is not specified, returns the organization from the existing project.
@protected
Future<String> getOrganization() async {
String? organization = stringArgDeprecated('org');
String? organization = stringArg('org');
if (!argResults!.wasParsed('org')) {
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
final Set<String> existingOrganizations = await project.organizationNames;
......@@ -326,8 +326,8 @@ abstract class CreateBase extends FlutterCommand {
@protected
String get projectName {
final String projectName =
stringArgDeprecated('project-name') ?? globals.fs.path.basename(projectDirPath);
if (!boolArgDeprecated('skip-name-checks')) {
stringArg('project-name') ?? globals.fs.path.basename(projectDirPath);
if (!boolArg('skip-name-checks')) {
final String? error = _validateProjectName(projectName);
if (error != null) {
throwToolExit(error);
......@@ -527,7 +527,7 @@ abstract class CreateBase extends FlutterCommand {
final bool windowsPlatform = templateContext['windows'] as bool? ?? false;
final bool webPlatform = templateContext['web'] as bool? ?? false;
if (boolArgDeprecated('pub')) {
if (boolArg('pub')) {
final Environment environment = Environment(
artifacts: globals.artifacts!,
logger: globals.logger,
......@@ -587,7 +587,7 @@ abstract class CreateBase extends FlutterCommand {
platforms: platformsForMigrateConfig,
projectDirectory: directory,
update: false,
currentRevision: stringArgDeprecated('initial-create-revision') ?? globals.flutterVersion.frameworkRevision,
currentRevision: stringArg('initial-create-revision') ?? globals.flutterVersion.frameworkRevision,
createRevision: globals.flutterVersion.frameworkRevision,
logger: globals.logger,
);
......
......@@ -461,8 +461,8 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
///
/// Only check if `--check` is explicitly specified. (Don't check by default)
Future<FlutterCommandResult> runNonInteractively() async {
final String jsonStr = stringArgDeprecated(_kJson)!;
final bool shouldCheck = boolArgDeprecated(_kCheck);
final String jsonStr = stringArg(_kJson)!;
final bool shouldCheck = boolArg(_kCheck);
dynamic json;
try {
......@@ -570,7 +570,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
/// Run interactively (with user prompts), the target device should be
/// connected to via ssh.
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
// single-subscription stream apparently.
......@@ -781,10 +781,10 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
Future<FlutterCommandResult> runCommand() async {
checkFeatureEnabled();
if (stringArgDeprecated(_kJson) != null) {
if (stringArg(_kJson) != null) {
return runNonInteractively();
}
if (boolArgDeprecated(_kSsh) == true) {
if (boolArg(_kSsh) == true) {
return runInteractivelySsh();
}
throw UnsupportedError('Unknown run mode');
......
......@@ -67,7 +67,7 @@ class DaemonCommand extends FlutterCommand {
if (argResults!['listen-on-tcp-port'] != null) {
int? port;
try {
port = int.parse(stringArgDeprecated('listen-on-tcp-port')!);
port = int.parse(stringArg('listen-on-tcp-port')!);
} on FormatException catch (error) {
throwToolExit('Invalid port for `--listen-on-tcp-port`: $error');
}
......
......@@ -58,7 +58,7 @@ class DebugAdapterCommand extends FlutterCommand {
platform: globals.platform,
ipv6: ipv6 ?? false,
enableDds: enableDds,
test: boolArgDeprecated('test'),
test: boolArg('test'),
onError: (Object? e) {
globals.printError(
'Input could not be parsed as a Debug Adapter Protocol message.\n'
......
......@@ -36,7 +36,7 @@ class DevicesCommand extends FlutterCommand {
@override
Duration? get deviceDiscoveryTimeout {
if (argResults?['timeout'] != null) {
final int? timeoutSeconds = int.tryParse(stringArgDeprecated('timeout')!);
final int? timeoutSeconds = int.tryParse(stringArg('timeout')!);
if (timeoutSeconds == null) {
throwToolExit('Could not parse -t/--timeout argument. It must be an integer.');
}
......@@ -67,7 +67,7 @@ class DevicesCommand extends FlutterCommand {
);
await output.findAndOutputAllTargetDevices(
machine: boolArgDeprecated('machine'),
machine: boolArg('machine'),
);
return FlutterCommandResult.success();
......
......@@ -35,7 +35,7 @@ class DoctorCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async {
globals.flutterVersion.fetchTagsAndUpdate();
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}'))) {
final bool success = await globals.doctor?.checkRemoteArtifacts(engineRevision) ?? false;
if (success) {
......@@ -48,7 +48,7 @@ class DoctorCommand extends FlutterCommand {
}
}
final bool success = await globals.doctor?.diagnose(
androidLicenses: boolArgDeprecated('android-licenses'),
androidLicenses: boolArg('android-licenses'),
verbose: verbose,
androidLicenseValidator: androidLicenseValidator,
) ?? false;
......
......@@ -91,7 +91,7 @@ class DowngradeCommand extends FlutterCommand {
_fileSystem ??= globals.fs;
String workingDirectory = Cache.flutterRoot!;
if (argResults!.wasParsed('working-directory')) {
workingDirectory = stringArgDeprecated('working-directory')!;
workingDirectory = stringArg('working-directory')!;
_flutterVersion = FlutterVersion(workingDirectory: workingDirectory);
}
......@@ -127,7 +127,7 @@ class DowngradeCommand extends FlutterCommand {
// If there is a terminal attached, prompt the user to confirm the downgrade.
final Stdio stdio = _stdio!;
final Terminal terminal = _terminal!;
if (stdio.hasTerminal && boolArgDeprecated('prompt')) {
if (stdio.hasTerminal && boolArg('prompt')) {
terminal.usesTerminalUi = true;
final String result = await terminal.promptForCharInput(
const <String>['y', 'n'],
......
......@@ -73,7 +73,6 @@ class DriveCommand extends RunCommandBase {
addMultidexOption();
argParser
..addFlag('keep-app-running',
defaultsTo: null,
help: 'Will keep the Flutter application running when done testing.\n'
'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" '
......@@ -171,7 +170,7 @@ class DriveCommand extends RunCommandBase {
// specified not to.
@override
bool get shouldRunPub {
if (argResults!.wasParsed('pub') && !boolArgDeprecated('pub')) {
if (argResults!.wasParsed('pub') && !boolArg('pub')) {
return false;
}
return true;
......@@ -196,9 +195,9 @@ class DriveCommand extends RunCommandBase {
@override
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
bool get startPausedDefault => true;
......@@ -206,7 +205,7 @@ class DriveCommand extends RunCommandBase {
@override
bool get cachePubGet => false;
String? get applicationBinaryPath => stringArgDeprecated(FlutterOptions.kUseApplicationBinary);
String? get applicationBinaryPath => stringArg(FlutterOptions.kUseApplicationBinary);
Future<Device?> get targetedDevice async {
return findTargetDevice(
......@@ -226,7 +225,7 @@ class DriveCommand extends RunCommandBase {
_logger.printTrace('Network device is being used. Changing `publish-port` to be enabled.');
return false;
}
return !boolArgDeprecated('publish-port');
return !boolArg('publish-port');
}
@override
......@@ -279,7 +278,7 @@ class DriveCommand extends RunCommandBase {
bool screenshotTaken = false;
try {
if (stringArgDeprecated('use-existing-app') == null) {
if (stringArg('use-existing-app') == null) {
await driverService.start(
buildInfo,
device,
......@@ -294,14 +293,14 @@ class DriveCommand extends RunCommandBase {
'trace-startup': traceStartup,
if (web)
'--no-launch-chrome': true,
if (boolArgDeprecated('multidex'))
if (boolArg('multidex'))
'multidex': true,
}
);
} else {
final Uri? uri = Uri.tryParse(stringArgDeprecated('use-existing-app')!);
final Uri? uri = Uri.tryParse(stringArg('use-existing-app')!);
if (uri == null) {
throwToolExit('Invalid VM Service URI: ${stringArgDeprecated('use-existing-app')}');
throwToolExit('Invalid VM Service URI: ${stringArg('use-existing-app')}');
}
await driverService.reuseApplication(
uri,
......@@ -316,16 +315,16 @@ class DriveCommand extends RunCommandBase {
stringsArg('test-arguments'),
<String, String>{},
packageConfig,
chromeBinary: stringArgDeprecated('chrome-binary'),
headless: boolArgDeprecated('headless'),
chromeBinary: stringArg('chrome-binary'),
headless: boolArg('headless'),
webBrowserFlags: stringsArg(FlutterOptions.kWebBrowserFlag),
browserDimension: stringArgDeprecated('browser-dimension')!.split(','),
browserName: stringArgDeprecated('browser-name'),
driverPort: stringArgDeprecated('driver-port') != null
? int.tryParse(stringArgDeprecated('driver-port')!)
browserDimension: stringArg('browser-dimension')!.split(','),
browserName: stringArg('browser-name'),
driverPort: stringArg('driver-port') != null
? int.tryParse(stringArg('driver-port')!)
: null,
androidEmulator: boolArgDeprecated('android-emulator'),
profileMemory: stringArgDeprecated('profile-memory'),
androidEmulator: boolArg('android-emulator'),
profileMemory: stringArg('profile-memory'),
);
// If the test is sent a signal or times out, take a screenshot
......@@ -344,11 +343,11 @@ class DriveCommand extends RunCommandBase {
screenshotTaken = true;
}
if (boolArgDeprecated('keep-app-running')) {
if (boolArg('keep-app-running')) {
_logger.printStatus('Leaving the application running.');
} else {
final File? skslFile = stringArgDeprecated('write-sksl-on-exit') != null
? _fileSystem.file(stringArgDeprecated('write-sksl-on-exit'))
final File? skslFile = stringArg('write-sksl-on-exit') != null
? _fileSystem.file(stringArg('write-sksl-on-exit'))
: null;
await driverService.stop(userIdentifier: userIdentifier, writeSkslOnExit: skslFile);
}
......@@ -422,7 +421,7 @@ class DriveCommand extends RunCommandBase {
String? _getTestFile() {
if (argResults!['driver'] != null) {
return stringArgDeprecated('driver');
return stringArg('driver');
}
// If the --driver argument wasn't provided, then derive the value from
......
......@@ -48,9 +48,9 @@ class EmulatorsCommand extends FlutterCommand {
final ArgResults argumentResults = argResults!;
if (argumentResults.wasParsed('launch')) {
final bool coldBoot = argumentResults.wasParsed('cold');
await _launchEmulator(stringArgDeprecated('launch')!, coldBoot: coldBoot);
await _launchEmulator(stringArg('launch')!, coldBoot: coldBoot);
} else if (argumentResults.wasParsed('create')) {
await _createEmulator(name: stringArgDeprecated('name'));
await _createEmulator(name: stringArg('name'));
} else {
final String? searchText =
argumentResults.rest.isNotEmpty
......
......@@ -226,7 +226,7 @@ class GenerateLocalizationsCommand extends FlutterCommand {
final List<String> outputFileList;
File? untranslatedMessagesFile;
bool format = boolArg('format') ?? false;
bool format = boolArg('format');
if (_fileSystem.file('l10n.yaml').existsSync()) {
final LocalizationOptions options = parseLocalizationsOptions(
......@@ -249,23 +249,23 @@ class GenerateLocalizationsCommand extends FlutterCommand {
untranslatedMessagesFile = generator.untranslatedMessagesFile;
format = format || options.format;
} else {
final String inputPathString = stringArgDeprecated('arb-dir')!; // Has default value, cannot be null.
final String? outputPathString = stringArgDeprecated('output-dir');
final String outputFileString = stringArgDeprecated('output-localization-file')!; // Has default value, cannot be null.
final String templateArbFileName = stringArgDeprecated('template-arb-file')!; // Has default value, cannot be null.
final String? untranslatedMessagesFilePath = stringArgDeprecated('untranslated-messages-file');
final String classNameString = stringArgDeprecated('output-class')!; // Has default value, cannot be null.
final String inputPathString = stringArg('arb-dir')!; // Has default value, cannot be null.
final String? outputPathString = stringArg('output-dir');
final String outputFileString = stringArg('output-localization-file')!; // Has default value, cannot be null.
final String templateArbFileName = stringArg('template-arb-file')!; // Has default value, cannot be null.
final String? untranslatedMessagesFilePath = stringArg('untranslated-messages-file');
final String classNameString = stringArg('output-class')!; // Has default value, cannot be null.
final List<String> preferredSupportedLocales = stringsArg('preferred-supported-locales');
final String? headerString = stringArgDeprecated('header');
final String? headerFile = stringArgDeprecated('header-file');
final bool useDeferredLoading = boolArgDeprecated('use-deferred-loading');
final String? inputsAndOutputsListPath = stringArgDeprecated('gen-inputs-and-outputs-list');
final bool useSyntheticPackage = boolArgDeprecated('synthetic-package');
final String? projectPathString = stringArgDeprecated('project-dir');
final bool areResourceAttributesRequired = boolArgDeprecated('required-resource-attributes');
final bool usesNullableGetter = boolArgDeprecated('nullable-getter');
final bool useEscaping = boolArgDeprecated('use-escaping');
final bool suppressWarnings = boolArgDeprecated('suppress-warnings');
final String? headerString = stringArg('header');
final String? headerFile = stringArg('header-file');
final bool useDeferredLoading = boolArg('use-deferred-loading');
final String? inputsAndOutputsListPath = stringArg('gen-inputs-and-outputs-list');
final bool useSyntheticPackage = boolArg('synthetic-package');
final String? projectPathString = stringArg('project-dir');
final bool areResourceAttributesRequired = boolArg('required-resource-attributes');
final bool usesNullableGetter = boolArg('nullable-getter');
final bool useEscaping = boolArg('use-escaping');
final bool suppressWarnings = boolArg('suppress-warnings');
precacheLanguageAndRegionTags();
......
......@@ -153,7 +153,7 @@ class IdeConfigCommand extends FlutterCommand {
manifest.add('$relativePath${Template.copyTemplateExtension}');
continue;
}
if (boolArgDeprecated('overwrite')) {
if (boolArg('overwrite')) {
finalDestinationFile.deleteSync();
globals.printStatus(' $relativeDestination (overwritten)');
} else {
......@@ -174,7 +174,7 @@ class IdeConfigCommand extends FlutterCommand {
}
// If we're not overwriting, then we're not going to remove missing items either.
if (!boolArgDeprecated('overwrite')) {
if (!boolArg('overwrite')) {
return;
}
......@@ -213,7 +213,7 @@ class IdeConfigCommand extends FlutterCommand {
throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2);
}
if (boolArgDeprecated('update-templates')) {
if (boolArg('update-templates')) {
_handleTemplateUpdate();
return FlutterCommandResult.success();
}
......@@ -231,7 +231,7 @@ class IdeConfigCommand extends FlutterCommand {
globals.printStatus('Updating IDE configuration for Flutter tree at $dirPath...');
int generatedCount = 0;
generatedCount += _renderTemplate(_ideName, dirPath, <String, Object>{
'withRootModule': boolArgDeprecated('with-root-module'),
'withRootModule': boolArg('with-root-module'),
'android': true,
});
......@@ -254,7 +254,7 @@ class IdeConfigCommand extends FlutterCommand {
return template.render(
globals.fs.directory(dirPath),
context,
overwriteExisting: boolArgDeprecated('overwrite'),
overwriteExisting: boolArg('overwrite'),
);
}
}
......
......@@ -37,10 +37,10 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
Device? device;
bool get uninstallOnly => boolArgDeprecated('uninstall-only');
String? get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser);
bool get uninstallOnly => boolArg('uninstall-only');
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);
@override
......
......@@ -46,7 +46,7 @@ class LogsCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> runCommand() async {
final Device cachedDevice = device!;
if (boolArgDeprecated('clear')) {
if (boolArg('clear')) {
cachedDevice.clearLogs();
}
......
......@@ -102,7 +102,7 @@ class PrecacheCommand extends FlutterCommand {
Set<String> _explicitArtifactSelections() {
final Map<String, String> umbrellaForArtifact = _umbrellaForArtifactMap();
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) {
final String? umbrellaName = umbrellaForArtifact[artifact.name];
if (explicitlySelected(artifact.name) ||
......@@ -135,15 +135,15 @@ class PrecacheCommand extends FlutterCommand {
if (_platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') {
await _cache.lock();
}
if (boolArgDeprecated('force')) {
if (boolArg('force')) {
_cache.clearStampFiles();
}
final bool includeAllPlatforms = boolArgDeprecated('all-platforms');
final bool includeAllPlatforms = boolArg('all-platforms');
if (includeAllPlatforms) {
_cache.includeAllPlatforms = true;
}
if (boolArgDeprecated('use-unsigned-mac-binaries')) {
if (boolArg('use-unsigned-mac-binaries')) {
_cache.useUnsignedMacBinaries = true;
}
final Set<String> explicitlyEnabled = _explicitArtifactSelections();
......@@ -160,7 +160,7 @@ class PrecacheCommand extends FlutterCommand {
}
final String argumentName = umbrellaForArtifact[artifact.name] ?? artifact.name;
if (includeAllPlatforms || boolArgDeprecated(argumentName) || downloadDefaultArtifacts) {
if (includeAllPlatforms || boolArg(argumentName) || downloadDefaultArtifacts) {
requiredArtifacts.add(artifact);
}
}
......
......@@ -96,7 +96,7 @@ class ScreenshotCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
await _validateOptions(stringArgDeprecated(_kType), stringArgDeprecated(_kVmServiceUrl));
await _validateOptions(stringArg(_kType), stringArg(_kVmServiceUrl));
return super.verifyThenRunCommand(commandPath);
}
......@@ -104,11 +104,11 @@ class ScreenshotCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async {
File? outputFile;
if (argResults?.wasParsed(_kOut) ?? false) {
outputFile = fs.file(stringArgDeprecated(_kOut));
outputFile = fs.file(stringArg(_kOut));
}
bool success = true;
switch (stringArgDeprecated(_kType)) {
switch (stringArg(_kType)) {
case _kDeviceType:
await runScreenshot(outputFile);
break;
......@@ -150,7 +150,7 @@ class ScreenshotCommand extends FlutterCommand {
}
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 vm_service.Response? skp = await vmService.screenshotSkp();
if (skp == null) {
......@@ -174,7 +174,7 @@ class ScreenshotCommand extends FlutterCommand {
}
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 vm_service.Response? response = await vmService.screenshot();
if (response == null) {
......
......@@ -54,7 +54,7 @@ class ShellCompletionCommand extends FlutterCommand {
}
final File outputFile = globals.fs.file(rest.first);
if (outputFile.existsSync() && !boolArgDeprecated('overwrite')) {
if (outputFile.existsSync() && !boolArg('overwrite')) {
throwToolExit(
'Output file ${outputFile.path} already exists, will not overwrite. '
'Use --overwrite to force overwriting existing output file.',
......
......@@ -68,14 +68,14 @@ class SymbolizeCommand extends FlutterCommand {
if (argResults?.wasParsed('debug-info') != true) {
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')
? !_fileSystem.isDirectorySync(debugInfoPath)
: !_fileSystem.isFileSync(debugInfoPath)) {
throwToolExit('$debugInfoPath does not exist.');
}
if ((argResults?.wasParsed('input') ?? false) && !_fileSystem.isFileSync(stringArgDeprecated('input')!)) {
throwToolExit('${stringArgDeprecated('input')} does not exist.');
if ((argResults?.wasParsed('input') ?? false) && !_fileSystem.isFileSync(stringArg('input')!)) {
throwToolExit('${stringArg('input')} does not exist.');
}
return super.validateCommand();
}
......@@ -87,7 +87,7 @@ class SymbolizeCommand extends FlutterCommand {
// Configure output to either specified file or stdout.
if (argResults?.wasParsed('output') ?? false) {
final File outputFile = _fileSystem.file(stringArgDeprecated('output'));
final File outputFile = _fileSystem.file(stringArg('output'));
if (!outputFile.parent.existsSync()) {
outputFile.parent.createSync(recursive: true);
}
......@@ -103,12 +103,12 @@ class SymbolizeCommand extends FlutterCommand {
// Configure input from either specified file or stdin.
if (argResults?.wasParsed('input') ?? false) {
input = _fileSystem.file(stringArgDeprecated('input')).openRead();
input = _fileSystem.file(stringArg('input')).openRead();
} else {
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 (debugInfoPath.endsWith('.dSYM')) {
......
......@@ -244,7 +244,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
// Use [DeviceBasedDevelopmentArtifacts].
? await super.requiredArtifacts
: <DevelopmentArtifact>{};
if (stringArgDeprecated('platform') == 'chrome') {
if (stringArg('platform') == 'chrome') {
results.add(DevelopmentArtifact.web);
}
return results;
......@@ -313,11 +313,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
'directory (or one of its subdirectories).');
}
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> plainNames = stringsArg('plain-name');
final String? tags = stringArgDeprecated('tags');
final String? excludeTags = stringArgDeprecated('exclude-tags');
final String? tags = stringArg('tags');
final String? excludeTags = stringArg('exclude-tags');
final BuildInfo buildInfo = await getBuildInfo(forcedBuildMode: BuildMode.debug);
TestTimeRecorder? testTimeRecorder;
......@@ -343,7 +343,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
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) {
throwToolExit(
'When using --start-paused, you must specify a single test file to run.',
......@@ -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) {
throwToolExit(
'Could not parse -j/--concurrency argument. It must be an integer greater than zero.'
......@@ -369,13 +369,13 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
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)) {
throwToolExit(
'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)) {
throwToolExit(
'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 {
'If you set --shard-index you need to also set --total-shards.');
}
final bool machine = boolArgDeprecated('machine');
final bool machine = boolArg('machine');
CoverageCollector? collector;
if (boolArgDeprecated('coverage') || boolArgDeprecated('merge-coverage') ||
boolArgDeprecated('branch-coverage')) {
if (boolArg('coverage') || boolArg('merge-coverage') ||
boolArg('branch-coverage')) {
final String projectName = flutterProject.manifest.appName;
collector = CoverageCollector(
verbose: !machine,
......@@ -401,7 +401,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
packagesPath: buildInfo.packagesPath,
resolver: await CoverageCollector.getResolver(buildInfo.packagesPath),
testTimeRecorder: testTimeRecorder,
branchCoverage: boolArgDeprecated('branch-coverage'),
branchCoverage: boolArg('branch-coverage'),
);
}
......@@ -415,12 +415,12 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
final DebuggingOptions debuggingOptions = DebuggingOptions.enabled(
buildInfo,
startPaused: startPaused,
disableServiceAuthCodes: boolArgDeprecated('disable-service-auth-codes'),
serveObservatory: boolArgDeprecated('serve-observatory'),
disableServiceAuthCodes: boolArg('disable-service-auth-codes'),
serveObservatory: boolArg('serve-observatory'),
// On iOS >=14, keeping this enabled will leave a prompt on the screen.
disablePortPublication: true,
enableDds: enableDds,
nullAssertions: boolArgDeprecated(FlutterOptions.kNullAssertions),
nullAssertions: boolArg(FlutterOptions.kNullAssertions),
);
Device? integrationTestDevice;
......@@ -464,23 +464,23 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
tags: tags,
excludeTags: excludeTags,
watcher: watcher,
enableVmService: collector != null || startPaused || boolArgDeprecated('enable-vmservice'),
ipv6: boolArgDeprecated('ipv6'),
enableVmService: collector != null || startPaused || boolArg('enable-vmservice'),
ipv6: boolArg('ipv6'),
machine: machine,
updateGoldens: boolArgDeprecated('update-goldens'),
updateGoldens: boolArg('update-goldens'),
concurrency: jobs,
testAssetDirectory: testAssetDirectory,
flutterProject: flutterProject,
web: stringArgDeprecated('platform') == 'chrome',
randomSeed: stringArgDeprecated('test-randomize-ordering-seed'),
reporter: stringArgDeprecated('reporter'),
web: stringArg('platform') == 'chrome',
randomSeed: stringArg('test-randomize-ordering-seed'),
reporter: stringArg('reporter'),
fileReporter: stringArg('file-reporter'),
timeout: stringArgDeprecated('timeout'),
runSkipped: boolArgDeprecated('run-skipped'),
timeout: stringArg('timeout'),
runSkipped: boolArg('run-skipped'),
shardIndex: shardIndex,
totalShards: totalShards,
integrationTestDevice: integrationTestDevice,
integrationTestUserIdentifier: stringArgDeprecated(FlutterOptions.kDeviceUser),
integrationTestUserIdentifier: stringArg(FlutterOptions.kDeviceUser),
testTimeRecorder: testTimeRecorder,
);
testTimeRecorder?.stop(TestTimePhases.TestRunner, testRunnerTimeRecorderStopwatch!);
......@@ -488,8 +488,8 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
if (collector != null) {
final Stopwatch? collectTimeRecorderStopwatch = testTimeRecorder?.start(TestTimePhases.CoverageDataCollect);
final bool collectionResult = await collector.collectCoverageData(
stringArgDeprecated('coverage-path'),
mergeCoverageData: boolArgDeprecated('merge-coverage'),
stringArg('coverage-path'),
mergeCoverageData: boolArg('merge-coverage'),
);
testTimeRecorder?.stop(TestTimePhases.CoverageDataCollect, collectTimeRecorderStopwatch!);
if (!collectionResult) {
......
......@@ -179,15 +179,15 @@ class UpdatePackagesCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async {
final List<Directory> packages = runner!.getRepoPackages();
final bool forceUpgrade = boolArgDeprecated('force-upgrade');
final bool isPrintPaths = boolArgDeprecated('paths');
final bool isPrintTransitiveClosure = boolArgDeprecated('transitive-closure');
final bool isVerifyOnly = boolArgDeprecated('verify-only');
final bool isConsumerOnly = boolArgDeprecated('consumer-only');
final bool offline = boolArgDeprecated('offline');
final bool forceUpgrade = boolArg('force-upgrade');
final bool isPrintPaths = boolArg('paths');
final bool isPrintTransitiveClosure = boolArg('transitive-closure');
final bool isVerifyOnly = boolArg('verify-only');
final bool isConsumerOnly = boolArg('consumer-only');
final bool offline = boolArg('offline');
final bool doUpgrade = forceUpgrade || isPrintPaths || isPrintTransitiveClosure;
if (boolArgDeprecated('crash')) {
if (boolArg('crash')) {
throw StateError('test crash please ignore.');
}
......@@ -442,7 +442,7 @@ class UpdatePackagesCommand extends FlutterCommand {
context: PubContext.updatePackages,
project: FlutterProject.fromDirectory(syntheticPackageDir),
upgrade: doUpgrade,
offline: boolArgDeprecated('offline'),
offline: boolArg('offline'),
flutterRootOverride: temporaryFlutterSdk?.path,
outputMode: PubOutputMode.none,
);
......@@ -484,15 +484,15 @@ class UpdatePackagesCommand extends FlutterCommand {
}
}
if (boolArgDeprecated('transitive-closure')) {
if (boolArg('transitive-closure')) {
tree._dependencyTree.forEach((String from, Set<String> to) {
globals.printStatus('$from -> $to');
});
return true;
}
if (boolArgDeprecated('paths')) {
showDependencyPaths(from: stringArgDeprecated('from')!, to: stringArgDeprecated('to')!, tree: tree);
if (boolArg('paths')) {
showDependencyPaths(from: stringArg('from')!, to: stringArg('to')!, tree: tree);
return true;
}
......@@ -526,7 +526,7 @@ class UpdatePackagesCommand extends FlutterCommand {
);
try {
// 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);
for (final Directory dir in packages) {
unawaited(queue.add(() async {
......
......@@ -71,16 +71,16 @@ class UpgradeCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> runCommand() {
_commandRunner.workingDirectory = stringArgDeprecated('working-directory') ?? Cache.flutterRoot!;
_commandRunner.workingDirectory = stringArg('working-directory') ?? Cache.flutterRoot!;
return _commandRunner.runCommand(
force: boolArgDeprecated('force'),
continueFlow: boolArgDeprecated('continue'),
testFlow: stringArgDeprecated('working-directory') != null,
force: boolArg('force'),
continueFlow: boolArg('continue'),
testFlow: stringArg('working-directory') != null,
gitTagVersion: GitTagVersion.determine(globals.processUtils, globals.platform),
flutterVersion: stringArgDeprecated('working-directory') == null
flutterVersion: stringArg('working-directory') == null
? globals.flutterVersion
: FlutterVersion(workingDirectory: _commandRunner.workingDirectory),
verifyOnly: boolArgDeprecated('verify-only'),
verifyOnly: boolArg('verify-only'),
);
}
}
......
......@@ -4,6 +4,7 @@
import 'dart:async';
import 'package:args/command_runner.dart';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_device.dart';
......@@ -673,6 +674,23 @@ void main() {
FakeDevice(targetPlatform: TargetPlatform.android_arm, platformType: PlatformType.android),
];
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;
expect(dimensions, const CustomDimensions(
......@@ -696,6 +714,23 @@ void main() {
FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.usb, sdkNameAndVersion: 'iOS 16.2'),
];
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;
expect(dimensions, const CustomDimensions(
......@@ -720,6 +755,23 @@ void main() {
FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.network, sdkNameAndVersion: 'iOS 16.2'),
];
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;
expect(dimensions, const CustomDimensions(
......@@ -745,6 +797,22 @@ void main() {
FakeIOSDevice(interfaceType: IOSDeviceConnectionInterface.usb, sdkNameAndVersion: 'iOS 16.2'),
];
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;
expect(dimensions, const CustomDimensions(
......
......@@ -47,13 +47,13 @@ void main() {
await runner.run(<String>['dummy', '--key']);
expect(command.boolArg('key'), true);
expect(command.boolArg('empty'), null);
expect(() => command.boolArg('non-existent'), throwsArgumentError);
expect(command.boolArgDeprecated('key'), true);
expect(() => command.boolArgDeprecated('empty'), throwsA(const TypeMatcher<ArgumentError>()));
expect(command.boolArg('key'), true);
expect(() => command.boolArg('non-existent'), throwsA(const TypeMatcher<ArgumentError>()));
expect(command.boolArg('key-false'), false);
expect(command.boolArgDeprecated('key-false'), false);
expect(command.boolArg('key-false'), false);
});
testUsingContext('String? safe argResults', () async {
......@@ -72,10 +72,10 @@ void main() {
await runner.run(<String>['dummy', '--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.stringArgDeprecated('empty'), throwsA(const TypeMatcher<ArgumentError>()));
expect(command.stringArg('key'), 'value');
expect(() => command.stringArg('non-existent'), throwsA(const TypeMatcher<ArgumentError>()));
});
testUsingContext('List<String> safe argResults', () async {
......@@ -97,7 +97,7 @@ void main() {
await runner.run(<String>['dummy', '--key', 'a']);
// 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']);
......
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