[flutter_tools] support trailing args (#86431)
This commit is contained in:
@@ -249,9 +249,8 @@ class PackagesForwardCommand extends FlutterCommand {
|
||||
}
|
||||
|
||||
class PackagesPassthroughCommand extends FlutterCommand {
|
||||
PackagesPassthroughCommand() {
|
||||
requiresPubspecYaml();
|
||||
}
|
||||
@override
|
||||
ArgParser argParser = ArgParser.allowAnything();
|
||||
|
||||
@override
|
||||
String get name => 'pub';
|
||||
|
||||
@@ -159,7 +159,6 @@ abstract class FlutterCommand extends Command<void> {
|
||||
@override
|
||||
ArgParser get argParser => _argParser;
|
||||
final ArgParser _argParser = ArgParser(
|
||||
allowTrailingOptions: false,
|
||||
usageLineLength: globals.outputPreferences.wrapText ? globals.outputPreferences.wrapColumn : null,
|
||||
);
|
||||
|
||||
|
||||
@@ -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<void> runner = createTestCommandRunner(command);
|
||||
|
||||
expect(
|
||||
runner.run(<String>['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();
|
||||
|
||||
@@ -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(<String>[
|
||||
flutterBin,
|
||||
'test',
|
||||
'test/hello_test.dart',
|
||||
'-r',
|
||||
'json',
|
||||
], workingDirectory: helloWorld);
|
||||
|
||||
expect(result.exitCode, 0);
|
||||
expect(result.stderr, isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user