diff --git a/packages/flutter_tools/bin/fuchsia_attach.dart b/packages/flutter_tools/bin/fuchsia_attach.dart index ec49191f75..71c0d9f613 100644 --- a/packages/flutter_tools/bin/fuchsia_attach.dart +++ b/packages/flutter_tools/bin/fuchsia_attach.dart @@ -22,6 +22,8 @@ final ArgParser parser = ArgParser() ..addOption('build-dir', help: 'The fuchsia build directory') ..addOption('dart-sdk', help: 'The prebuilt dart SDK') ..addOption('target', help: 'The GN target to attach to') + ..addOption('entrypoint', defaultsTo: 'main.dart', help: 'The filename of the main method. Defaults to main.dart') + ..addOption('device', help: 'The device id to attach to') ..addFlag('verbose', negatable: true); // Track the original working directory so that the tool can find the @@ -50,10 +52,11 @@ Future main(List args) async { fs.currentDirectory = path; // Check for a package with a lib directory. - String targetFile = 'lib/main.dart'; + final String entrypoint = argResults['entrypoint']; + String targetFile = 'lib/$entrypoint'; if (!fs.file(targetFile).existsSync()) { // Otherwise assume the package is flat. - targetFile = 'main.dart'; + targetFile = entrypoint; } final List command = [ 'attach', @@ -70,6 +73,10 @@ Future main(List args) async { '--packages', packages, ]; + final String deviceName = argResults['device']; + if (deviceName != null && deviceName.isNotEmpty) { + command.addAll(['-d', deviceName]); + } if (verbose) { command.add('--verbose'); }