Skip to content

Commit

Permalink
flutter_tool: DRY up arg helpers, use new typed arg functions (flutte…
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo authored Jul 17, 2024
1 parent 91a5b7b commit 83bfab5
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/flutter_tools/lib/src/runner/flutter_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1884,29 +1884,20 @@ 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`.
///
/// 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);
}
}

Expand Down

0 comments on commit 83bfab5

Please sign in to comment.