flutter_tool: DRY up arg helpers, use new typed arg functions (#151784)

This commit is contained in:
Kevin Moore 2024-07-16 21:01:28 -07:00 committed by GitHub
parent 91a5b7bd9a
commit 83bfab5376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1884,10 +1884,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
/// If no flag named [name] was added to the [ArgParser], an [ArgumentError]
/// will be thrown.
bool boolArg(String name, {bool global = false}) {
if (global) {
return globalResults![name] as bool;
}
return argResults![name] as bool;
return (global ? globalResults : argResults)!.flag(name);
}
/// Gets the parsed command-line option named [name] as a `String`.
@ -1895,18 +1892,12 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
/// If no option named [name] was added to the [ArgParser], an [ArgumentError]
/// will be thrown.
String? stringArg(String name, {bool global = false}) {
if (global) {
return globalResults![name] as String?;
}
return argResults![name] as String?;
return (global ? globalResults : argResults)!.option(name);
}
/// Gets the parsed command-line option named [name] as `List<String>`.
List<String> stringsArg(String name, {bool global = false}) {
if (global) {
return globalResults![name] as List<String>;
}
return argResults![name] as List<String>;
return (global ? globalResults : argResults)!.multiOption(name);
}
}