Skip to content

Commit b549e82

Browse files
author
Jonah Williams
authored
[flutter_tools] support trailing args (flutter#86431)
1 parent 4d96a3f commit b549e82

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

packages/flutter_tools/lib/src/commands/packages.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,8 @@ class PackagesForwardCommand extends FlutterCommand {
249249
}
250250

251251
class PackagesPassthroughCommand extends FlutterCommand {
252-
PackagesPassthroughCommand() {
253-
requiresPubspecYaml();
254-
}
252+
@override
253+
ArgParser argParser = ArgParser.allowAnything();
255254

256255
@override
257256
String get name => 'pub';

packages/flutter_tools/lib/src/runner/flutter_command.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ abstract class FlutterCommand extends Command<void> {
159159
@override
160160
ArgParser get argParser => _argParser;
161161
final ArgParser _argParser = ArgParser(
162-
allowTrailingOptions: false,
163162
usageLineLength: globals.outputPreferences.wrapText ? globals.outputPreferences.wrapColumn : null,
164163
);
165164

packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,19 +1620,6 @@ void main() {
16201620
);
16211621
});
16221622

1623-
// Verify that we help the user correct an option ordering issue
1624-
testUsingContext('produces sensible error message', () async {
1625-
Cache.flutterRoot = '../..';
1626-
1627-
final CreateCommand command = CreateCommand();
1628-
final CommandRunner<void> runner = createTestCommandRunner(command);
1629-
1630-
expect(
1631-
runner.run(<String>['create', projectDir.path, '--pub']),
1632-
throwsToolExit(exitCode: 2, message: 'Try moving --pub'),
1633-
);
1634-
});
1635-
16361623
testUsingContext('fails when file exists where output directory should be', () async {
16371624
Cache.flutterRoot = '../..';
16381625
final CreateCommand command = CreateCommand();

packages/flutter_tools/test/integration.shard/command_output_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,19 @@ void main() {
247247
'A crash report has been written to',
248248
));
249249
});
250+
251+
testWithoutContext('flutter supports trailing args', () async {
252+
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
253+
final String helloWorld = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
254+
final ProcessResult result = await processManager.run(<String>[
255+
flutterBin,
256+
'test',
257+
'test/hello_test.dart',
258+
'-r',
259+
'json',
260+
], workingDirectory: helloWorld);
261+
262+
expect(result.exitCode, 0);
263+
expect(result.stderr, isEmpty);
264+
});
250265
}

0 commit comments

Comments
 (0)