Unverified Commit 596e9d1c authored by Jesús S Guerrero's avatar Jesús S Guerrero Committed by GitHub

[flutter_tools] stringArg refactor (#103231)

parent 95116386
......@@ -215,7 +215,7 @@ class AssembleCommand extends FlutterCommand {
/// The environmental configuration for a build invocation.
Environment createEnvironment() {
final FlutterProject flutterProject = FlutterProject.current();
String? output = stringArg('output');
String? output = stringArgDeprecated('output');
if (output == null) {
throwToolExit('--output directory is required for assemble.');
}
......@@ -318,7 +318,7 @@ class AssembleCommand extends FlutterCommand {
environment,
buildSystemConfig: BuildSystemConfig(
resourcePoolSize: argumentResults.wasParsed('resource-pool-size')
? int.tryParse(stringArg('resource-pool-size')!)
? int.tryParse(stringArgDeprecated('resource-pool-size')!)
: null,
),
);
......@@ -335,17 +335,17 @@ class AssembleCommand extends FlutterCommand {
globals.printTrace('build succeeded.');
if (argumentResults.wasParsed('build-inputs')) {
writeListIfChanged(result.inputFiles, stringArg('build-inputs')!);
writeListIfChanged(result.inputFiles, stringArgDeprecated('build-inputs')!);
}
if (argumentResults.wasParsed('build-outputs')) {
writeListIfChanged(result.outputFiles, stringArg('build-outputs')!);
writeListIfChanged(result.outputFiles, stringArgDeprecated('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(stringArg('depfile'));
final File depfileFile = globals.fs.file(stringArgDeprecated('depfile'));
final Depfile depfile = Depfile(result.inputFiles, result.outputFiles);
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
......
......@@ -153,7 +153,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
return null;
}
try {
return int.parse(stringArg('debug-port'));
return int.parse(stringArgDeprecated('debug-port'));
} on Exception catch (error) {
throwToolExit('Invalid port for `--debug-port`: $error');
}
......@@ -163,9 +163,9 @@ known, it can be explicitly provided to attach via the command-line, e.g.
if (argResults['debug-url'] == null) {
return null;
}
final Uri uri = Uri.tryParse(stringArg('debug-url'));
final Uri uri = Uri.tryParse(stringArgDeprecated('debug-url'));
if (uri == null) {
throwToolExit('Invalid `--debug-url`: ${stringArg('debug-url')}');
throwToolExit('Invalid `--debug-url`: ${stringArgDeprecated('debug-url')}');
}
if (!uri.hasPort) {
throwToolExit('Port not specified for `--debug-url`: $uri');
......@@ -174,10 +174,10 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
String get appId {
return stringArg('app-id');
return stringArgDeprecated('app-id');
}
String get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
String get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser);
@override
Future<void> validateCommand() async {
......@@ -255,7 +255,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
if (debugPort == null && debugUri == null) {
if (device is FuchsiaDevice) {
final String module = stringArg('module');
final String module = stringArgDeprecated('module');
if (module == null) {
throwToolExit("'--module' is required for attaching to a Fuchsia device");
}
......@@ -370,7 +370,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
signals: globals.signals,
processInfo: globals.processInfo,
reportReady: boolArg('report-ready'),
pidFile: stringArg('pid-file'),
pidFile: stringArgDeprecated('pid-file'),
)
..registerSignalHandlers()
..setupTerminal();
......@@ -418,7 +418,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(stringArg('target-model')),
targetModel: TargetModel(stringArgDeprecated('target-model')),
buildInfo: buildInfo,
userIdentifier: userIdentifier,
platform: globals.platform,
......@@ -437,8 +437,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: stringArg('project-root'),
dillOutputPath: stringArg('output-dill'),
projectRootPath: stringArgDeprecated('project-root'),
dillOutputPath: stringArgDeprecated('output-dill'),
ipv6: usesIpv6,
flutterProject: flutterProject,
)
......
......@@ -112,7 +112,7 @@ class BuildAarCommand extends BuildSubCommand {
final Iterable<AndroidArch> targetArchitectures =
stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName);
final String? buildNumberArg = stringArg('build-number');
final String? buildNumberArg = stringArgDeprecated('build-number');
final String buildNumber = argParser.options.containsKey('build-number')
&& buildNumberArg != null
&& buildNumberArg.isNotEmpty
......@@ -142,7 +142,7 @@ class BuildAarCommand extends BuildSubCommand {
project: _getProject(),
target: targetFile.path,
androidBuildInfo: androidBuildInfo,
outputDirectoryPath: stringArg('output-dir'),
outputDirectoryPath: stringArgDeprecated('output-dir'),
buildNumber: buildNumber,
);
return FlutterCommandResult.success();
......
......@@ -80,7 +80,7 @@ class BuildBundleCommand extends BuildSubCommand {
return const CustomDimensions();
}
return CustomDimensions(
commandBuildBundleTargetPlatform: stringArg('target-platform'),
commandBuildBundleTargetPlatform: stringArgDeprecated('target-platform'),
commandBuildBundleIsModule: flutterProject.isModule,
);
}
......@@ -95,7 +95,7 @@ class BuildBundleCommand extends BuildSubCommand {
@override
Future<FlutterCommandResult> runCommand() async {
final String targetPlatform = stringArg('target-platform')!;
final String targetPlatform = stringArgDeprecated('target-platform')!;
final TargetPlatform platform = getTargetPlatformForName(targetPlatform);
if (platform == null) {
throwToolExit('Unknown platform: $targetPlatform');
......@@ -138,8 +138,8 @@ class BuildBundleCommand extends BuildSubCommand {
platform: platform,
buildInfo: buildInfo,
mainPath: targetFile,
depfilePath: stringArg('depfile'),
assetDirPath: stringArg('asset-dir'),
depfilePath: stringArgDeprecated('depfile'),
assetDirPath: stringArgDeprecated('asset-dir'),
);
return FlutterCommandResult.success();
}
......
......@@ -79,9 +79,9 @@ class BuildFuchsiaCommand extends BuildSubCommand {
await buildFuchsia(
fuchsiaProject: flutterProject.fuchsia,
target: targetFile,
targetPlatform: getTargetPlatformForName(stringArg('target-platform')!),
targetPlatform: getTargetPlatformForName(stringArgDeprecated('target-platform')!),
buildInfo: buildInfo,
runnerPackageSource: stringArg('runner-source')!,
runnerPackageSource: stringArgDeprecated('runner-source')!,
);
return FlutterCommandResult.success();
}
......
......@@ -98,7 +98,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
@override
final bool configOnly = false;
String? get exportOptionsPlist => stringArg('export-options-plist');
String? get exportOptionsPlist => stringArgDeprecated('export-options-plist');
@override
Directory _outputAppDirectory(String xcodeResultOutput) => globals.fs
......@@ -153,7 +153,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 = stringArg('export-method')!;
final String exportMethod = stringArgDeprecated('export-method')!;
final bool isAppStoreUpload = exportMethod == 'app-store';
File? generatedExportPlist;
try {
......@@ -241,7 +241,7 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
''');
plistContents.write('''
<string>${stringArg('export-method')}</string>
<string>${stringArgDeprecated('export-method')}</string>
''');
if (xcodeBuildResult?.xcodeBuildExecution?.buildSettings['ENABLE_BITCODE'] != 'YES') {
// Bitcode is off by default in Flutter iOS apps.
......
......@@ -159,7 +159,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
@override
Future<FlutterCommandResult> runCommand() async {
final String outputArgument = stringArg('output')
final String outputArgument = stringArgDeprecated('output')
?? globals.fs.path.join(globals.fs.currentDirectory.path, 'build', 'ios', 'framework');
if (outputArgument.isEmpty) {
......
......@@ -61,7 +61,7 @@ class BuildLinuxCommand extends BuildSubCommand {
final BuildInfo buildInfo = await getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current();
final TargetPlatform targetPlatform =
getTargetPlatformForName(stringArg('target-platform')!);
getTargetPlatformForName(stringArgDeprecated('target-platform')!);
final bool needCrossBuild =
getNameForHostPlatformArch(_operatingSystemUtils.hostPlatform)
!= getNameForTargetPlatformArch(targetPlatform);
......@@ -95,7 +95,7 @@ class BuildLinuxCommand extends BuildSubCommand {
),
needCrossBuild: needCrossBuild,
targetPlatform: targetPlatform,
targetSysroot: stringArg('target-sysroot')!,
targetSysroot: stringArgDeprecated('target-sysroot')!,
);
return FlutterCommandResult.success();
}
......
......@@ -90,12 +90,12 @@ class BuildWebCommand extends BuildSubCommand {
throwToolExit('"build web" is not currently supported. To enable, run "flutter config --enable-web".');
}
final FlutterProject flutterProject = FlutterProject.current();
final String target = stringArg('target')!;
final String target = stringArgDeprecated('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 = stringArg('base-href');
final String? baseHref = stringArgDeprecated('base-href');
if (baseHref != null && !(baseHref.startsWith('/') && baseHref.endsWith('/'))) {
throwToolExit('base-href should start and end with /');
}
......@@ -119,11 +119,11 @@ class BuildWebCommand extends BuildSubCommand {
target,
buildInfo,
boolArg('csp'),
stringArg('pwa-strategy')!,
stringArgDeprecated('pwa-strategy')!,
boolArg('source-maps'),
boolArg('native-null-assertions'),
baseHref,
stringArg('dart2js-optimization'),
stringArgDeprecated('dart2js-optimization'),
);
return FlutterCommandResult.success();
}
......
......@@ -132,11 +132,11 @@ class ConfigCommand extends FlutterCommand {
}
if (argResults?.wasParsed('android-sdk') ?? false) {
_updateConfig('android-sdk', stringArg('android-sdk')!);
_updateConfig('android-sdk', stringArgDeprecated('android-sdk')!);
}
if (argResults?.wasParsed('android-studio-dir') ?? false) {
_updateConfig('android-studio-dir', stringArg('android-studio-dir')!);
_updateConfig('android-studio-dir', stringArgDeprecated('android-studio-dir')!);
}
if (argResults?.wasParsed('clear-ios-signing-cert') ?? false) {
......@@ -144,7 +144,7 @@ class ConfigCommand extends FlutterCommand {
}
if (argResults?.wasParsed('build-dir') ?? false) {
final String buildDir = stringArg('build-dir')!;
final String buildDir = stringArgDeprecated('build-dir')!;
if (globals.fs.path.isAbsolute(buildDir)) {
throwToolExit('build-dir should be a relative path');
}
......
......@@ -93,9 +93,9 @@ class CreateCommand extends CreateBase {
@override
Future<CustomDimensions> get usageValues async {
return CustomDimensions(
commandCreateProjectType: stringArg('template'),
commandCreateAndroidLanguage: stringArg('android-language'),
commandCreateIosLanguage: stringArg('ios-language'),
commandCreateProjectType: stringArgDeprecated('template'),
commandCreateAndroidLanguage: stringArgDeprecated('android-language'),
commandCreateIosLanguage: stringArgDeprecated('ios-language'),
);
}
......@@ -162,7 +162,7 @@ class CreateCommand extends CreateBase {
FlutterProjectType detectedProjectType;
final bool metadataExists = projectDir.absolute.childFile('.metadata').existsSync();
if (argResults['template'] != null) {
template = stringToProjectType(stringArg('template'));
template = stringToProjectType(stringArgDeprecated('template'));
}
// If the project directory exists and isn't empty, then try to determine the template
// type from the project directory.
......@@ -190,7 +190,7 @@ class CreateCommand extends CreateBase {
Future<FlutterCommandResult> runCommand() async {
if (argResults['list-samples'] != null) {
// _writeSamplesJson can potentially be long-lived.
await _writeSamplesJson(stringArg('list-samples'));
await _writeSamplesJson(stringArgDeprecated('list-samples'));
return FlutterCommandResult.success();
}
......@@ -199,12 +199,12 @@ class CreateCommand extends CreateBase {
String sampleCode;
if (argResults['sample'] != null) {
if (argResults['template'] != null &&
stringToProjectType(stringArg('template') ?? 'app') != FlutterProjectType.app) {
stringToProjectType(stringArgDeprecated('template') ?? 'app') != FlutterProjectType.app) {
throwToolExit('Cannot specify --sample with a project type other than '
'"${flutterProjectTypeToString(FlutterProjectType.app)}"');
}
// Fetch the sample from the server.
sampleCode = await _fetchSampleFromServer(stringArg('sample'));
sampleCode = await _fetchSampleFromServer(stringArgDeprecated('sample'));
}
final FlutterProjectType template = _getProjectType(projectDir);
......@@ -276,12 +276,12 @@ class CreateCommand extends CreateBase {
organization: organization,
projectName: projectName,
titleCaseProjectName: titleCaseProjectName,
projectDescription: stringArg('description'),
projectDescription: stringArgDeprecated('description'),
flutterRoot: flutterRoot,
withPlatformChannelPluginHook: generateMethodChannelsPlugin,
withFfiPluginHook: generateFfiPlugin,
androidLanguage: stringArg('android-language'),
iosLanguage: stringArg('ios-language'),
androidLanguage: stringArgDeprecated('android-language'),
iosLanguage: stringArgDeprecated('ios-language'),
iosDevelopmentTeam: developmentTeam,
ios: includeIos,
android: featureFlags.isAndroidEnabled && platforms.contains('android'),
......@@ -438,7 +438,7 @@ Your $application code is in $relativeAppMain.
}) async {
int generatedCount = 0;
final String description = argResults.wasParsed('description')
? stringArg('description')
? stringArgDeprecated('description')
: 'A new Flutter module project.';
templateContext['description'] = description;
generatedCount += await renderTemplate(
......@@ -472,7 +472,7 @@ Your $application code is in $relativeAppMain.
}) async {
int generatedCount = 0;
final String description = argResults.wasParsed('description')
? stringArg('description')
? stringArgDeprecated('description')
: 'A new Flutter package project.';
templateContext['description'] = description;
generatedCount += await renderTemplate(
......@@ -518,7 +518,7 @@ Your $application code is in $relativeAppMain.
templateContext['no_platforms'] = !willAddPlatforms;
int generatedCount = 0;
final String description = argResults.wasParsed('description')
? stringArg('description')
? stringArgDeprecated('description')
: 'A new Flutter plugin project.';
templateContext['description'] = description;
generatedCount += await renderMerged(
......@@ -597,7 +597,7 @@ Your $application code is in $relativeAppMain.
templateContext['no_platforms'] = !willAddPlatforms;
int generatedCount = 0;
final String description = argResults.wasParsed('description')
? stringArg('description')
? stringArgDeprecated('description')
: 'A new Flutter FFI plugin project.';
templateContext['description'] = description;
generatedCount += await renderMerged(
......
......@@ -243,7 +243,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 = stringArg('org');
String organization = stringArgDeprecated('org');
if (!argResults.wasParsed('org')) {
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
final Set<String> existingOrganizations = await project.organizationNames;
......@@ -315,7 +315,7 @@ abstract class CreateBase extends FlutterCommand {
@protected
String get projectName {
final String projectName =
stringArg('project-name') ?? globals.fs.path.basename(projectDirPath);
stringArgDeprecated('project-name') ?? globals.fs.path.basename(projectDirPath);
if (!boolArg('skip-name-checks')) {
final String error = _validateProjectName(projectName);
if (error != null) {
......@@ -593,7 +593,7 @@ abstract class CreateBase extends FlutterCommand {
projectDirectory: directory,
create: true,
update: false,
currentRevision: stringArg('initial-create-revision') ?? globals.flutterVersion.frameworkRevision,
currentRevision: stringArgDeprecated('initial-create-revision') ?? globals.flutterVersion.frameworkRevision,
createRevision: globals.flutterVersion.frameworkRevision,
logger: globals.logger,
);
......
......@@ -482,7 +482,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
///
/// Only check if `--check` is explicitly specified. (Don't check by default)
Future<FlutterCommandResult> runNonInteractively() async {
final String jsonStr = stringArg(_kJson);
final String jsonStr = stringArgDeprecated(_kJson);
final bool shouldCheck = boolArg(_kCheck) ?? false;
dynamic json;
......@@ -803,7 +803,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
Future<FlutterCommandResult> runCommand() async {
checkFeatureEnabled();
if (stringArg(_kJson) != null) {
if (stringArgDeprecated(_kJson) != null) {
return runNonInteractively();
}
if (boolArg(_kSsh) == true) {
......
......@@ -69,7 +69,7 @@ class DaemonCommand extends FlutterCommand {
if (argResults['listen-on-tcp-port'] != null) {
int port;
try {
port = int.parse(stringArg('listen-on-tcp-port'));
port = int.parse(stringArgDeprecated('listen-on-tcp-port'));
} on FormatException catch (error) {
throwToolExit('Invalid port for `--listen-on-tcp-port`: $error');
}
......
......@@ -36,7 +36,7 @@ class DevicesCommand extends FlutterCommand {
@override
Duration? get deviceDiscoveryTimeout {
if (argResults?['timeout'] != null) {
final int? timeoutSeconds = int.tryParse(stringArg('timeout')!);
final int? timeoutSeconds = int.tryParse(stringArgDeprecated('timeout')!);
if (timeoutSeconds == null) {
throwToolExit('Could not parse -t/--timeout argument. It must be an integer.');
}
......
......@@ -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 = stringArg('check-for-remote-artifacts')!;
final String engineRevision = stringArgDeprecated('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) {
......
......@@ -92,7 +92,7 @@ class DowngradeCommand extends FlutterCommand {
_fileSystem ??= globals.fs;
String workingDirectory = Cache.flutterRoot!;
if (argResults!.wasParsed('working-directory')) {
workingDirectory = stringArg('working-directory')!;
workingDirectory = stringArgDeprecated('working-directory')!;
_flutterVersion = FlutterVersion(workingDirectory: workingDirectory);
}
......
......@@ -179,9 +179,9 @@ class DriveCommand extends RunCommandBase {
@override
final List<String> aliases = <String>['driver'];
String get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
String get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser);
String get screenshot => stringArg('screenshot');
String get screenshot => stringArgDeprecated('screenshot');
@override
bool get startPausedDefault => true;
......@@ -209,7 +209,7 @@ class DriveCommand extends RunCommandBase {
if (await _fileSystem.type(testFile) != FileSystemEntityType.file) {
throwToolExit('Test file not found: $testFile');
}
final String applicationBinaryPath = stringArg(FlutterOptions.kUseApplicationBinary);
final String applicationBinaryPath = stringArgDeprecated(FlutterOptions.kUseApplicationBinary);
final Device device = await findTargetDevice(includeUnsupportedDevices: applicationBinaryPath == null);
if (device == null) {
throwToolExit(null);
......@@ -240,7 +240,7 @@ class DriveCommand extends RunCommandBase {
bool screenshotTaken = false;
try {
if (stringArg('use-existing-app') == null) {
if (stringArgDeprecated('use-existing-app') == null) {
await driverService.start(
buildInfo,
device,
......@@ -260,9 +260,9 @@ class DriveCommand extends RunCommandBase {
}
);
} else {
final Uri uri = Uri.tryParse(stringArg('use-existing-app'));
final Uri uri = Uri.tryParse(stringArgDeprecated('use-existing-app'));
if (uri == null) {
throwToolExit('Invalid VM Service URI: ${stringArg('use-existing-app')}');
throwToolExit('Invalid VM Service URI: ${stringArgDeprecated('use-existing-app')}');
}
await driverService.reuseApplication(
uri,
......@@ -277,15 +277,15 @@ class DriveCommand extends RunCommandBase {
stringsArg('test-arguments'),
<String, String>{},
packageConfig,
chromeBinary: stringArg('chrome-binary'),
chromeBinary: stringArgDeprecated('chrome-binary'),
headless: boolArg('headless'),
browserDimension: stringArg('browser-dimension').split(','),
browserName: stringArg('browser-name'),
driverPort: stringArg('driver-port') != null
? int.tryParse(stringArg('driver-port'))
browserDimension: stringArgDeprecated('browser-dimension').split(','),
browserName: stringArgDeprecated('browser-name'),
driverPort: stringArgDeprecated('driver-port') != null
? int.tryParse(stringArgDeprecated('driver-port'))
: null,
androidEmulator: boolArg('android-emulator'),
profileMemory: stringArg('profile-memory'),
profileMemory: stringArgDeprecated('profile-memory'),
);
if (testResult != 0 && screenshot != null) {
// Take a screenshot while the app is still running.
......@@ -296,8 +296,8 @@ class DriveCommand extends RunCommandBase {
if (boolArg('keep-app-running') ?? (argResults['use-existing-app'] != null)) {
_logger.printStatus('Leaving the application running.');
} else {
final File skslFile = stringArg('write-sksl-on-exit') != null
? _fileSystem.file(stringArg('write-sksl-on-exit'))
final File skslFile = stringArgDeprecated('write-sksl-on-exit') != null
? _fileSystem.file(stringArgDeprecated('write-sksl-on-exit'))
: null;
await driverService.stop(userIdentifier: userIdentifier, writeSkslOnExit: skslFile);
}
......@@ -318,7 +318,7 @@ class DriveCommand extends RunCommandBase {
String _getTestFile() {
if (argResults['driver'] != null) {
return stringArg('driver');
return stringArgDeprecated('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(stringArg('launch')!, coldBoot: coldBoot);
await _launchEmulator(stringArgDeprecated('launch')!, coldBoot: coldBoot);
} else if (argumentResults.wasParsed('create')) {
await _createEmulator(name: stringArg('name'));
await _createEmulator(name: stringArgDeprecated('name'));
} else {
final String? searchText =
argumentResults.rest != null && argumentResults.rest.isNotEmpty
......
......@@ -216,19 +216,19 @@ class GenerateLocalizationsCommand extends FlutterCommand {
return FlutterCommandResult.success();
}
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? untranslatedMessagesFile = stringArg('untranslated-messages-file');
final String classNameString = stringArg('output-class')!; // Has default value, cannot be null.
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? untranslatedMessagesFile = stringArgDeprecated('untranslated-messages-file');
final String classNameString = stringArgDeprecated('output-class')!; // Has default value, cannot be null.
final List<String> preferredSupportedLocales = stringsArg('preferred-supported-locales');
final String? headerString = stringArg('header');
final String? headerFile = stringArg('header-file');
final String? headerString = stringArgDeprecated('header');
final String? headerFile = stringArgDeprecated('header-file');
final bool useDeferredLoading = boolArg('use-deferred-loading');
final String? inputsAndOutputsListPath = stringArg('gen-inputs-and-outputs-list');
final String? inputsAndOutputsListPath = stringArgDeprecated('gen-inputs-and-outputs-list');
final bool useSyntheticPackage = boolArg('synthetic-package');
final String? projectPathString = stringArg('project-dir');
final String? projectPathString = stringArgDeprecated('project-dir');
final bool areResourceAttributesRequired = boolArg('required-resource-attributes');
final bool usesNullableGetter = boolArg('nullable-getter');
......
......@@ -34,9 +34,9 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
Device? device;
bool get uninstallOnly => boolArg('uninstall-only');
String? get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
String? get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser);
String? get _applicationBinaryPath => stringArg(FlutterOptions.kUseApplicationBinary);
String? get _applicationBinaryPath => stringArgDeprecated(FlutterOptions.kUseApplicationBinary);
File? get _applicationBinary => _applicationBinaryPath == null ? null : globals.fs.file(_applicationBinaryPath);
@override
......
......@@ -179,25 +179,25 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
/// Whether to start the application paused by default.
bool get startPausedDefault;
String get route => stringArg('route');
String get route => stringArgDeprecated('route');
String get traceAllowlist => stringArg('trace-allowlist');
String get traceAllowlist => stringArgDeprecated('trace-allowlist');
/// Create a debugging options instance for the current `run` or `drive` invocation.
Future<DebuggingOptions> createDebuggingOptions(bool webMode) async {
final BuildInfo buildInfo = await getBuildInfo();
final int browserDebugPort = featureFlags.isWebEnabled && argResults.wasParsed('web-browser-debug-port')
? int.parse(stringArg('web-browser-debug-port'))
? int.parse(stringArgDeprecated('web-browser-debug-port'))
: null;
if (buildInfo.mode.isRelease) {
return DebuggingOptions.disabled(
buildInfo,
dartEntrypointArgs: stringsArg('dart-entrypoint-args'),
hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '',
port: featureFlags.isWebEnabled ? stringArg('web-port') : '',
webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArg('web-server-debug-protocol') == 'sse',
webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArg('web-server-debug-backend-protocol') == 'sse',
webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArg('web-server-debug-injected-client-protocol') == 'sse',
hostname: featureFlags.isWebEnabled ? stringArgDeprecated('web-hostname') : '',
port: featureFlags.isWebEnabled ? stringArgDeprecated('web-port') : '',
webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-protocol') == 'sse',
webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-backend-protocol') == 'sse',
webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-injected-client-protocol') == 'sse',
webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'),
webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
webBrowserDebugPort: browserDebugPort,
......@@ -212,13 +212,13 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
cacheStartupProfile: cacheStartupProfile,
enableDds: enableDds,
dartEntrypointArgs: stringsArg('dart-entrypoint-args'),
dartFlags: stringArg('dart-flags') ?? '',
dartFlags: stringArgDeprecated('dart-flags') ?? '',
useTestFonts: argParser.options.containsKey('use-test-fonts') && boolArg('use-test-fonts'),
enableSoftwareRendering: argParser.options.containsKey('enable-software-rendering') && boolArg('enable-software-rendering'),
skiaDeterministicRendering: argParser.options.containsKey('skia-deterministic-rendering') && boolArg('skia-deterministic-rendering'),
traceSkia: boolArg('trace-skia'),
traceAllowlist: traceAllowlist,
traceSkiaAllowlist: stringArg('trace-skia-allowlist'),
traceSkiaAllowlist: stringArgDeprecated('trace-skia-allowlist'),
traceSystrace: boolArg('trace-systrace'),
endlessTraceBuffer: boolArg('endless-trace-buffer'),
dumpSkpOnShaderCompilation: dumpSkpOnShaderCompilation,
......@@ -230,17 +230,17 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
ddsPort: ddsPort,
devToolsServerAddress: devToolsServerAddress,
verboseSystemLogs: boolArg('verbose-system-logs'),
hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '',
port: featureFlags.isWebEnabled ? stringArg('web-port') : '',
webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArg('web-server-debug-protocol') == 'sse',
webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArg('web-server-debug-backend-protocol') == 'sse',
webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArg('web-server-debug-injected-client-protocol') == 'sse',
hostname: featureFlags.isWebEnabled ? stringArgDeprecated('web-hostname') : '',
port: featureFlags.isWebEnabled ? stringArgDeprecated('web-port') : '',
webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-protocol') == 'sse',
webUseSseForDebugBackend: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-backend-protocol') == 'sse',
webUseSseForInjectedClient: featureFlags.isWebEnabled && stringArgDeprecated('web-server-debug-injected-client-protocol') == 'sse',
webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'),
webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
webBrowserDebugPort: browserDebugPort,
webEnableExpressionEvaluation: featureFlags.isWebEnabled && boolArg('web-enable-expression-evaluation'),
webLaunchUrl: featureFlags.isWebEnabled ? stringArg('web-launch-url') : null,
vmserviceOutFile: stringArg('vmservice-out-file'),
webLaunchUrl: featureFlags.isWebEnabled ? stringArgDeprecated('web-launch-url') : null,
vmserviceOutFile: stringArgDeprecated('vmservice-out-file'),
fastStart: argParser.options.containsKey('fast-start')
&& boolArg('fast-start')
&& !runningWithPrebuiltApplication,
......@@ -371,7 +371,7 @@ class RunCommand extends RunCommandBase {
List<Device> devices;
bool webMode = false;
String get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
String get userIdentifier => stringArgDeprecated(FlutterOptions.kDeviceUser);
@override
bool get startPausedDefault => false;
......@@ -523,8 +523,8 @@ class RunCommand extends RunCommandBase {
applicationBinary: applicationBinaryPath == null
? null
: globals.fs.file(applicationBinaryPath),
projectRootPath: stringArg('project-root'),
dillOutputPath: stringArg('output-dill'),
projectRootPath: stringArgDeprecated('project-root'),
dillOutputPath: stringArgDeprecated('output-dill'),
stayResident: stayResident,
ipv6: ipv6,
multidexEnabled: boolArg('multidex'),
......@@ -580,7 +580,7 @@ class RunCommand extends RunCommandBase {
// debug mode.
final BuildInfo buildInfo = await getBuildInfo();
final bool hotMode = shouldUseHotMode(buildInfo);
final String applicationBinaryPath = stringArg(FlutterOptions.kUseApplicationBinary);
final String applicationBinaryPath = stringArgDeprecated(FlutterOptions.kUseApplicationBinary);
if (boolArg('machine')) {
if (devices.length > 1) {
......@@ -596,9 +596,9 @@ class RunCommand extends RunCommandBase {
? null
: globals.fs.file(applicationBinaryPath),
trackWidgetCreation: trackWidgetCreation,
projectRootPath: stringArg('project-root'),
projectRootPath: stringArgDeprecated('project-root'),
packagesFilePath: globalResults['packages'] as String,
dillOutputPath: stringArg('output-dill'),
dillOutputPath: stringArgDeprecated('output-dill'),
ipv6: ipv6,
multidexEnabled: boolArg('multidex'),
);
......@@ -691,7 +691,7 @@ class RunCommand extends RunCommandBase {
signals: globals.signals,
processInfo: globals.processInfo,
reportReady: boolArg('report-ready'),
pidFile: stringArg('pid-file'),
pidFile: stringArgDeprecated('pid-file'),
)
..registerSignalHandlers()
..setupTerminal();
......
......@@ -93,7 +93,7 @@ class ScreenshotCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
await _validateOptions(stringArg(_kType), stringArg(_kObservatoryUrl));
await _validateOptions(stringArgDeprecated(_kType), stringArgDeprecated(_kObservatoryUrl));
return super.verifyThenRunCommand(commandPath);
}
......@@ -101,11 +101,11 @@ class ScreenshotCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async {
File? outputFile;
if (argResults?.wasParsed(_kOut) ?? false) {
outputFile = globals.fs.file(stringArg(_kOut));
outputFile = globals.fs.file(stringArgDeprecated(_kOut));
}
bool success = true;
switch (stringArg(_kType)) {
switch (stringArgDeprecated(_kType)) {
case _kDeviceType:
await runScreenshot(outputFile);
break;
......@@ -136,7 +136,7 @@ class ScreenshotCommand extends FlutterCommand {
}
Future<bool> runSkia(File? outputFile) async {
final Uri observatoryUrl = Uri.parse(stringArg(_kObservatoryUrl)!);
final Uri observatoryUrl = Uri.parse(stringArgDeprecated(_kObservatoryUrl)!);
final FlutterVmService vmService = await connectToVmService(observatoryUrl, logger: globals.logger);
final vm_service.Response? skp = await vmService.screenshotSkp();
if (skp == null) {
......@@ -160,7 +160,7 @@ class ScreenshotCommand extends FlutterCommand {
}
Future<bool> runRasterizer(File? outputFile) async {
final Uri observatoryUrl = Uri.parse(stringArg(_kObservatoryUrl)!);
final Uri observatoryUrl = Uri.parse(stringArgDeprecated(_kObservatoryUrl)!);
final FlutterVmService vmService = await connectToVmService(observatoryUrl, logger: globals.logger);
final vm_service.Response? response = await vmService.screenshot();
if (response == null) {
......
......@@ -68,11 +68,11 @@ class SymbolizeCommand extends FlutterCommand {
if (argResults?.wasParsed('debug-info') != true) {
throwToolExit('"--debug-info" is required to symbolize stack traces.');
}
if (!_fileSystem.isFileSync(stringArg('debug-info')!)) {
throwToolExit('${stringArg('debug-info')} does not exist.');
if (!_fileSystem.isFileSync(stringArgDeprecated('debug-info')!)) {
throwToolExit('${stringArgDeprecated('debug-info')} does not exist.');
}
if ((argResults?.wasParsed('input') ?? false) && !_fileSystem.isFileSync(stringArg('input')!)) {
throwToolExit('${stringArg('input')} does not exist.');
if ((argResults?.wasParsed('input') ?? false) && !_fileSystem.isFileSync(stringArgDeprecated('input')!)) {
throwToolExit('${stringArgDeprecated('input')} does not exist.');
}
return super.validateCommand();
}
......@@ -84,7 +84,7 @@ class SymbolizeCommand extends FlutterCommand {
// Configure output to either specified file or stdout.
if (argResults?.wasParsed('output') ?? false) {
final File outputFile = _fileSystem.file(stringArg('output'));
final File outputFile = _fileSystem.file(stringArgDeprecated('output'));
if (!outputFile.parent.existsSync()) {
outputFile.parent.createSync(recursive: true);
}
......@@ -100,12 +100,12 @@ class SymbolizeCommand extends FlutterCommand {
// Configure input from either specified file or stdin.
if (argResults?.wasParsed('input') ?? false) {
input = _fileSystem.file(stringArg('input')).openRead();
input = _fileSystem.file(stringArgDeprecated('input')).openRead();
} else {
input = _stdio.stdin;
}
final Uint8List symbols = _fileSystem.file(stringArg('debug-info')).readAsBytesSync();
final Uint8List symbols = _fileSystem.file(stringArgDeprecated('debug-info')).readAsBytesSync();
await _dwarfSymbolizationService.decode(
input: input,
output: output,
......
......@@ -239,7 +239,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
// Use [DeviceBasedDevelopmentArtifacts].
? await super.requiredArtifacts
: <DevelopmentArtifact>{};
if (stringArg('platform') == 'chrome') {
if (stringArgDeprecated('platform') == 'chrome') {
results.add(DevelopmentArtifact.web);
}
return results;
......@@ -305,8 +305,8 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
final bool buildTestAssets = boolArg('test-assets');
final List<String> names = stringsArg('name');
final List<String> plainNames = stringsArg('plain-name');
final String tags = stringArg('tags');
final String excludeTags = stringArg('exclude-tags');
final String tags = stringArgDeprecated('tags');
final String excludeTags = stringArgDeprecated('exclude-tags');
final BuildInfo buildInfo = await getBuildInfo(forcedBuildMode: BuildMode.debug);
if (buildInfo.packageConfig['test_api'] == null) {
......@@ -332,7 +332,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
);
}
int jobs = int.tryParse(stringArg('concurrency'));
int jobs = int.tryParse(stringArgDeprecated('concurrency'));
if (jobs == null || jobs <= 0 || !jobs.isFinite) {
throwToolExit(
'Could not parse -j/--concurrency argument. It must be an integer greater than zero.'
......@@ -350,13 +350,13 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
jobs = 1;
}
final int shardIndex = int.tryParse(stringArg('shard-index') ?? '');
final int shardIndex = int.tryParse(stringArgDeprecated('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(stringArg('total-shards') ?? '');
final int totalShards = int.tryParse(stringArgDeprecated('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.');
......@@ -446,20 +446,20 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
concurrency: jobs,
buildTestAssets: buildTestAssets,
flutterProject: flutterProject,
web: stringArg('platform') == 'chrome',
randomSeed: stringArg('test-randomize-ordering-seed'),
reporter: stringArg('reporter'),
timeout: stringArg('timeout'),
web: stringArgDeprecated('platform') == 'chrome',
randomSeed: stringArgDeprecated('test-randomize-ordering-seed'),
reporter: stringArgDeprecated('reporter'),
timeout: stringArgDeprecated('timeout'),
runSkipped: boolArg('run-skipped'),
shardIndex: shardIndex,
totalShards: totalShards,
integrationTestDevice: integrationTestDevice,
integrationTestUserIdentifier: stringArg(FlutterOptions.kDeviceUser),
integrationTestUserIdentifier: stringArgDeprecated(FlutterOptions.kDeviceUser),
);
if (collector != null) {
final bool collectionResult = collector.collectCoverageData(
stringArg('coverage-path'),
stringArgDeprecated('coverage-path'),
mergeCoverageData: boolArg('merge-coverage'),
);
if (!collectionResult) {
......
......@@ -462,7 +462,7 @@ class UpdatePackagesCommand extends FlutterCommand {
}
if (boolArg('paths')) {
showDependencyPaths(from: stringArg('from')!, to: stringArg('to')!, tree: tree);
showDependencyPaths(from: stringArgDeprecated('from')!, to: stringArgDeprecated('to')!, tree: tree);
return true;
}
......@@ -496,7 +496,7 @@ class UpdatePackagesCommand extends FlutterCommand {
);
try {
// int.tryParse will not accept null, but will convert empty string to null
final int? maxJobs = int.tryParse(stringArg('jobs') ?? '');
final int? maxJobs = int.tryParse(stringArgDeprecated('jobs') ?? '');
final TaskQueue<void> queue = TaskQueue<void>(maxJobs: maxJobs);
for (final Directory dir in packages) {
unawaited(queue.add(() async {
......
......@@ -70,13 +70,13 @@ class UpgradeCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> runCommand() {
_commandRunner.workingDirectory = stringArg('working-directory') ?? Cache.flutterRoot!;
_commandRunner.workingDirectory = stringArgDeprecated('working-directory') ?? Cache.flutterRoot!;
return _commandRunner.runCommand(
force: boolArg('force'),
continueFlow: boolArg('continue'),
testFlow: stringArg('working-directory') != null,
testFlow: stringArgDeprecated('working-directory') != null,
gitTagVersion: GitTagVersion.determine(globals.processUtils, globals.platform),
flutterVersion: stringArg('working-directory') == null
flutterVersion: stringArgDeprecated('working-directory') == null
? globals.flutterVersion
: FlutterVersion(workingDirectory: _commandRunner.workingDirectory),
verifyOnly: boolArg('verify-only'),
......
......@@ -293,7 +293,7 @@ abstract class FlutterCommand extends Command<void> {
String get targetFile {
if (argResults?.wasParsed('target') ?? false) {
return stringArg('target')!;
return stringArgDeprecated('target')!;
}
final List<String>? rest = argResults?.rest;
if (rest != null && rest.isNotEmpty) {
......@@ -312,7 +312,7 @@ abstract class FlutterCommand extends Command<void> {
/// This can be overridden by some of its subclasses.
String? get fileSystemScheme =>
argParser.options.containsKey(FlutterOptions.kFileSystemScheme)
? stringArg(FlutterOptions.kFileSystemScheme)
? stringArgDeprecated(FlutterOptions.kFileSystemScheme)
: null;
/// The values of the `--filesystem-root` argument.
......@@ -450,8 +450,8 @@ abstract class FlutterCommand extends Command<void> {
|| (argResults?.wasParsed('host-vmservice-port') ?? false);
int _tryParseHostVmservicePort() {
final String? observatoryPort = stringArg('observatory-port');
final String? hostPort = stringArg('host-vmservice-port');
final String? observatoryPort = stringArgDeprecated('observatory-port');
final String? hostPort = stringArgDeprecated('host-vmservice-port');
if (observatoryPort == null && hostPort == null) {
throwToolExit('Invalid port for `--observatory-port/--host-vmservice-port`');
}
......@@ -468,7 +468,7 @@ abstract class FlutterCommand extends Command<void> {
return _tryParseHostVmservicePort();
} else if (argResults?.wasParsed('dds-port') ?? false) {
// If an explicit DDS port is provided, use dds-port for DDS.
return int.tryParse(stringArg('dds-port')!) ?? 0;
return int.tryParse(stringArgDeprecated('dds-port')!) ?? 0;
}
// Otherwise, DDS can bind to a random port.
return 0;
......@@ -476,7 +476,7 @@ abstract class FlutterCommand extends Command<void> {
Uri? get devToolsServerAddress {
if (argResults?.wasParsed(kDevToolsServerAddress) ?? false) {
final Uri? uri = Uri.tryParse(stringArg(kDevToolsServerAddress)!);
final Uri? uri = Uri.tryParse(stringArgDeprecated(kDevToolsServerAddress)!);
if (uri != null && uri.host.isNotEmpty && uri.port != 0) {
return uri;
}
......@@ -513,7 +513,7 @@ abstract class FlutterCommand extends Command<void> {
///
/// If no port is set, returns null.
int? get deviceVmservicePort {
final String? devicePort = stringArg('device-vmservice-port');
final String? devicePort = stringArgDeprecated('device-vmservice-port');
if (!_usesPortOption || devicePort == null) {
return null;
}
......@@ -626,7 +626,7 @@ abstract class FlutterCommand extends Command<void> {
late final Duration? deviceDiscoveryTimeout = () {
if ((argResults?.options.contains(FlutterOptions.kDeviceTimeout) ?? false)
&& (argResults?.wasParsed(FlutterOptions.kDeviceTimeout) ?? false)) {
final int? timeoutSeconds = int.tryParse(stringArg(FlutterOptions.kDeviceTimeout)!);
final int? timeoutSeconds = int.tryParse(stringArgDeprecated(FlutterOptions.kDeviceTimeout)!);
if (timeoutSeconds == null) {
throwToolExit( 'Could not parse "--${FlutterOptions.kDeviceTimeout}" argument. It must be an integer.');
}
......@@ -980,7 +980,7 @@ abstract class FlutterCommand extends Command<void> {
boolArg('track-widget-creation');
final String? buildNumber = argParser.options.containsKey('build-number')
? stringArg('build-number')
? stringArgDeprecated('build-number')
: null;
final File packagesFile = globals.fs.file(
......@@ -1015,8 +1015,8 @@ abstract class FlutterCommand extends Command<void> {
globals.fs.directory(getBuildDirectory()),
'flutter_size',
);
if (argParser.options.containsKey(FlutterOptions.kCodeSizeDirectory) && stringArg(FlutterOptions.kCodeSizeDirectory) != null) {
directory = globals.fs.directory(stringArg(FlutterOptions.kCodeSizeDirectory));
if (argParser.options.containsKey(FlutterOptions.kCodeSizeDirectory) && stringArgDeprecated(FlutterOptions.kCodeSizeDirectory) != null) {
directory = globals.fs.directory(stringArgDeprecated(FlutterOptions.kCodeSizeDirectory));
}
directory.createSync(recursive: true);
codeSizeDirectory = directory.path;
......@@ -1059,7 +1059,7 @@ abstract class FlutterCommand extends Command<void> {
&& boolArg(FlutterOptions.kDartObfuscationOption);
final String? splitDebugInfoPath = argParser.options.containsKey(FlutterOptions.kSplitDebugInfoOption)
? stringArg(FlutterOptions.kSplitDebugInfoOption)
? stringArgDeprecated(FlutterOptions.kSplitDebugInfoOption)
: null;
final bool androidGradleDaemon = !argParser.options.containsKey(FlutterOptions.kAndroidGradleDaemon)
......@@ -1088,7 +1088,7 @@ abstract class FlutterCommand extends Command<void> {
&& boolArg('tree-shake-icons');
final String? bundleSkSLPath = argParser.options.containsKey(FlutterOptions.kBundleSkSLPathOption)
? stringArg(FlutterOptions.kBundleSkSLPathOption)
? stringArgDeprecated(FlutterOptions.kBundleSkSLPathOption)
: null;
if (bundleSkSLPath != null && !globals.fs.isFileSync(bundleSkSLPath)) {
......@@ -1096,7 +1096,7 @@ abstract class FlutterCommand extends Command<void> {
}
final String? performanceMeasurementFile = argParser.options.containsKey(FlutterOptions.kPerformanceMeasurementFile)
? stringArg(FlutterOptions.kPerformanceMeasurementFile)
? stringArgDeprecated(FlutterOptions.kPerformanceMeasurementFile)
: null;
List<String> dartDefines = argParser.options.containsKey(FlutterOptions.kDartDefinesOption)
......@@ -1104,12 +1104,12 @@ abstract class FlutterCommand extends Command<void> {
: <String>[];
if (argParser.options.containsKey('web-renderer')) {
dartDefines = updateDartDefines(dartDefines, stringArg('web-renderer')!);
dartDefines = updateDartDefines(dartDefines, stringArgDeprecated('web-renderer')!);
}
return BuildInfo(buildMode,
argParser.options.containsKey('flavor')
? stringArg('flavor')
? stringArgDeprecated('flavor')
: null,
trackWidgetCreation: trackWidgetCreation,
extraFrontEndOptions: extraFrontEndOptions.isNotEmpty
......@@ -1122,7 +1122,7 @@ abstract class FlutterCommand extends Command<void> {
fileSystemScheme: fileSystemScheme,
buildNumber: buildNumber,
buildName: argParser.options.containsKey('build-name')
? stringArg('build-name')
? stringArgDeprecated('build-name')
: null,
treeShakeIcons: treeShakeIcons,
splitDebugInfoPath: splitDebugInfoPath,
......@@ -1138,7 +1138,7 @@ abstract class FlutterCommand extends Command<void> {
packageConfig: packageConfig,
androidProjectArgs: androidProjectArgs,
initializeFromDill: argParser.options.containsKey(FlutterOptions.kInitializeFromDill)
? stringArg(FlutterOptions.kInitializeFromDill)
? stringArgDeprecated(FlutterOptions.kInitializeFromDill)
: null,
assumeInitializeFromDillUpToDate: argParser.options.containsKey(FlutterOptions.kAssumeInitializeFromDillUpToDate)
&& boolArg(FlutterOptions.kAssumeInitializeFromDillUpToDate),
......@@ -1522,7 +1522,14 @@ abstract class FlutterCommand extends Command<void> {
bool boolArg(String name) => argResults?[name] as bool? ?? false;
/// Gets the parsed command-line option named [name] as a `String`.
String? stringArg(String name) => argResults?[name] as String?;
String? stringArgDeprecated(String name) => argResults?[name] as String?;
String? stringArg(String name) {
if (argResults == null || !argParser.options.containsKey(name)) {
return null;
}
return argResults?[name] as String?;
}
/// Gets the parsed command-line option named [name] as an `int`.
int? intArg(String name) => argResults?[name] as int?;
......
......@@ -11,8 +11,22 @@ import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import '../src/common.dart';
import '../src/context.dart';
import '../src/testbed.dart';
class CommandDummy extends FlutterCommand{
@override
String get description => 'description';
@override
String get name => 'test';
@override
Future<FlutterCommandResult> runCommand() async {
return FlutterCommandResult.success();
}
}
void main() {
test('Help for command line arguments is consistently styled and complete', () => Testbed().run(() {
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: true);
......@@ -22,6 +36,20 @@ void main() {
).forEach(runner.addCommand);
verifyCommandRunner(runner);
}));
testUsingContext('String? safe argResults', () async {
final CommandDummy command = CommandDummy();
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: true);
command.argParser.addOption('key');
runner.addCommand(command);
await runner.run(<String>['test', '--key=value']);
expect(command.stringArg('key'), 'value');
expect(command.stringArg('empty'), null);
expect(command.stringArgDeprecated('key'), 'value');
expect(() => command.stringArgDeprecated('empty'), throwsA(const TypeMatcher<ArgumentError>()));
});
}
void verifyCommandRunner(CommandRunner<Object> runner) {
......
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