Skip to content

feat(flutter_tools): add IntOptionDescriptor and DefaultedIntOptionDescriptor - #192455

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
kevmoo:int-option-descriptors
Sep 10, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
kevmoo:int-option-descriptors

Conversation

@kevmoo

@kevmoo kevmoo commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Adds IntOptionDescriptor (OptionDescriptor<int?>) and DefaultedIntOptionDescriptor (OptionDescriptor) to option_descriptor.dart.

  • Parses single-value integer CLI options and throws a descriptive FormatException on invalid numeric strings.
  • Migrates DebuggingOptionDescriptors.ddsPort, WebOptions.webPort, and WebOptions.webBrowserDebugPort from StringOptionDescriptor to IntOptionDescriptor.
  • Eliminates redundant manual int.tryParse / int.parse call sites in FlutterCommand.ddsPort and RunCommand.
  • Adds comprehensive unit tests in option_descriptor_test.dart.

…scriptor

Adds IntOptionDescriptor (OptionDescriptor<int?>) and DefaultedIntOptionDescriptor (OptionDescriptor<int>) to option_descriptor.dart.

- Parses single-value integer CLI options and throws a descriptive FormatException on invalid numeric strings.
- Migrates DebuggingOptionDescriptors.ddsPort, WebOptions.webPort, and WebOptions.webBrowserDebugPort from StringOptionDescriptor to IntOptionDescriptor.
- Eliminates redundant manual int.tryParse / int.parse call sites in FlutterCommand.ddsPort and RunCommand.
- Adds comprehensive unit tests in option_descriptor_test.dart.
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 8, 2026
…ults.getValue

- Catches FormatException in SafeArgResults.getValue and calls throwToolExit(e.message) so invalid integer flags (--dds-port=abc, --web-port=abc) exit cleanly instead of triggering unhandled tool crash reports.
- Deduplicates integer parsing logic into _IntOptionDescriptorBase._parseValue.
- Removes redundant wasParsed(WebOptions.webBrowserDebugPort) check in RunCommandBase.
- Adds unit test verifying SafeArgResults.getValue converts FormatException into ToolExit.
@kevmoo
kevmoo marked this pull request as ready for review September 9, 2026 00:16

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces IntOptionDescriptor and DefaultedIntOptionDescriptor to natively support integer command-line options, replacing manual string parsing for options such as dds-port, web-port, and web-browser-debug-port. Additionally, SafeArgResults.getValue is updated to catch FormatException and throw a ToolExit. The review feedback suggests restricting the defaultsTo parameter type to int? in the _IntOptionDescriptorBase constructor to ensure compile-time type safety.

@kevmoo kevmoo added the CICD Run CI/CD label Sep 9, 2026
Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than the DDS port concern.

Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated
…default 0

- Updates DebuggingOptionDescriptors.ddsPort from IntOptionDescriptor to DefaultedIntOptionDescriptor with defaultsTo: 0.
- Simplifies FlutterCommand.ddsPort to directly return getValue(DebuggingOptionDescriptors.ddsPort) when explicit ddsPort or fallback random port 0 is used.

@harryterkelsen harryterkelsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 9, 2026
@auto-submit

auto-submit Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/192455, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Oct 8, 2026
…lutter#193323)

Migrate `BuildLinuxCommand` (`build linux`) and `BuildWindowsCommand`
(`build windows`) to typed `OptionDescriptor`s and `OptionBundle`s
(following flutter#191018, flutter#191510, flutter#191760, flutter#192307, flutter#192455, flutter#192524, and
flutter#192818):

- Add `DesktopBuildOptionsBundle` in `common_options.dart`,
encapsulating `CommonBuildOptionsBundle`, `BuildModeOptionsBundle`,
`DartCompileOptionsBundle`, `BuildInfoOptions.flavor`, `splitDebugInfo`,
`obfuscate`, `extraFrontEndOptions`, `extraGenSnapshotOptions`,
`performanceMeasurementFile`, `analyzeSize`, `codeSizeDirectory`,
`trackWidgetCreation`, and `configOnly`.
- Migrate `BuildLinuxCommand` (`build_linux.dart`) to
`DesktopBuildOptionsBundle`,
`DefaultedEnumOptionDescriptor<TargetPlatform>`
(`_targetPlatformOption`), and `DefaultedStringOptionDescriptor`
(`_targetSysroot`), replacing untyped `boolArg('config-only')`,
`stringArg('target-platform')!`, and `stringArg('target-sysroot')!`
queries.
- Migrate `BuildWindowsCommand` (`build_windows.dart`) to
`DesktopBuildOptionsBundle` and
`getValue(DesktopBuildOptionsBundle.configOnly)`.
- Delete the obsolete `FlutterCommand.addCommonDesktopBuildOptions`
helper method from `flutter_command.dart` (no remaining callers in
`flutter_tools`).

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants