Skip to content

Add a --dart-entrypoint-args flag to flutter run to pass through Dart entrypoint arguments on Flutter Desktop#69607

Merged
fluttergithubbot merged 5 commits intoflutter:masterfrom
gw280:gwright-runner-args
Nov 6, 2020
Merged

Add a --dart-entrypoint-args flag to flutter run to pass through Dart entrypoint arguments on Flutter Desktop#69607
fluttergithubbot merged 5 commits intoflutter:masterfrom
gw280:gwright-runner-args

Conversation

@gw280
Copy link
Contributor

@gw280 gw280 commented Nov 2, 2020

Description

Adds a --dart-entrypoint-args multioption to flutter run.

Related Issues

#32986

Tests

I added the following tests:

startApp supports dartEntrypointArgs

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

N/A to flutter_tools

@gw280 gw280 requested a review from jonahwilliams November 2, 2020 21:34
@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 2, 2020
@google-cla google-cla bot added the cla: yes label Nov 2, 2020
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

I would suggest adding this to the debuggingOptions object -

DebuggingOptions createDebuggingOptions() {

The plumbing for where to send this is already complete, and it will not require any g3fixes to roll into google3

@gw280 gw280 requested a review from jonahwilliams November 3, 2020 21:03
@gw280 gw280 force-pushed the gwright-runner-args branch from c86c9d1 to af85926 Compare November 4, 2020 16:55
)
..addMultiOption('dart-entrypoint-args',
abbr: 'a',
help: 'Pass a list of arguments to the Dart entrypoint at application '
Copy link
Contributor

Choose a reason for hiding this comment

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

I would connect this more strongly with main(List<String> args), dart entrypoint is a bit vague. I think Dart calls this the "main function".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Dart entrypoint can be any name, the default is main. I will clarify that it's main() by default though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we might have made the configurable in our embedder? But Dart says it is only main()

abbr: 'a',
help: 'Pass a list of arguments to the Dart entrypoint at application '
'startup. Specify this option multiple times each with one argument '
'to pass multiple arguments to the Dart entrypoint.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Document that this is only support on desktop platforms (which ones).

}

List<String> command = <String>[ executable, ];
if (debuggingOptions?.dartEntrypointArgs != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can dartEntrypointArgs be null here?

you can do this a bit more Dart-y with a spread:

 final Process process = await _processManager.start(
  <String>[
    executable,
    ...?debuggingOptions?.dartEntrypointArgs,
  ]
  (...)
)

this.startPaused = false,
this.disableServiceAuthCodes = false,
this.disableDds = false,
this.dartEntrypointArgs,
Copy link
Contributor

Choose a reason for hiding this comment

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

A default value for each would be nice this.dartEntrypointArgs = const <String>[]

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@fluttergithubbot fluttergithubbot merged commit 2b51278 into flutter:master Nov 6, 2020
@blurymind
Copy link

is there any example code to show how to use this to do myApp.exe /path/to/file.txt ?

@tvolkert
Copy link
Contributor

If we have this flag in the shared runner, it would be nice if it worked for all platforms. (I tried it for Android, and it doesn't do anything).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants