From b549e829e8570ece6d48749e2ba693a1d3de547b Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 14 Jul 2021 15:51:10 -0700 Subject: [PATCH] [flutter_tools] support trailing args (#86431) --- .../flutter_tools/lib/src/commands/packages.dart | 5 ++--- .../lib/src/runner/flutter_command.dart | 1 - .../commands.shard/permeable/create_test.dart | 13 ------------- .../integration.shard/command_output_test.dart | 15 +++++++++++++++ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/packages.dart b/packages/flutter_tools/lib/src/commands/packages.dart index 6c90e71986..0ffd536125 100644 --- a/packages/flutter_tools/lib/src/commands/packages.dart +++ b/packages/flutter_tools/lib/src/commands/packages.dart @@ -249,9 +249,8 @@ class PackagesForwardCommand extends FlutterCommand { } class PackagesPassthroughCommand extends FlutterCommand { - PackagesPassthroughCommand() { - requiresPubspecYaml(); - } + @override + ArgParser argParser = ArgParser.allowAnything(); @override String get name => 'pub'; diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index 383711fbd6..b9fd49c58e 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -159,7 +159,6 @@ abstract class FlutterCommand extends Command { @override ArgParser get argParser => _argParser; final ArgParser _argParser = ArgParser( - allowTrailingOptions: false, usageLineLength: globals.outputPreferences.wrapText ? globals.outputPreferences.wrapColumn : null, ); diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index 8e65f68d29..9e6e1c9106 100755 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -1620,19 +1620,6 @@ void main() { ); }); - // Verify that we help the user correct an option ordering issue - testUsingContext('produces sensible error message', () async { - Cache.flutterRoot = '../..'; - - final CreateCommand command = CreateCommand(); - final CommandRunner runner = createTestCommandRunner(command); - - expect( - runner.run(['create', projectDir.path, '--pub']), - throwsToolExit(exitCode: 2, message: 'Try moving --pub'), - ); - }); - testUsingContext('fails when file exists where output directory should be', () async { Cache.flutterRoot = '../..'; final CreateCommand command = CreateCommand(); diff --git a/packages/flutter_tools/test/integration.shard/command_output_test.dart b/packages/flutter_tools/test/integration.shard/command_output_test.dart index cd0c4eefa7..e1fa2197b8 100644 --- a/packages/flutter_tools/test/integration.shard/command_output_test.dart +++ b/packages/flutter_tools/test/integration.shard/command_output_test.dart @@ -247,4 +247,19 @@ void main() { 'A crash report has been written to', )); }); + + testWithoutContext('flutter supports trailing args', () async { + final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); + final String helloWorld = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world'); + final ProcessResult result = await processManager.run([ + flutterBin, + 'test', + 'test/hello_test.dart', + '-r', + 'json', + ], workingDirectory: helloWorld); + + expect(result.exitCode, 0); + expect(result.stderr, isEmpty); + }); }