Throw error on unexpected positional arguments (#130274)

This PR fixes ignoring when random positional arguments added to the
`flutter gen-l10n`.

So we are no longer able to call `flutter gen-l10n hello world` or
`flutter gen-l10n --format false`.

Fixes https://github.com/flutter/flutter/issues/118203
This commit is contained in:
Tae Hyung Kim
2023-07-10 12:12:23 -07:00
committed by GitHub
parent f731af6371
commit dabd7b3bb5
2 changed files with 18 additions and 0 deletions

View File

@@ -480,4 +480,17 @@ format: true
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('throws error when unexpected positional argument is provided', () {
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem,
logger: logger,
artifacts: artifacts,
processManager: processManager,
);
expect(
() async => createTestCommandRunner(command).run(<String>['gen-l10n', '--synthetic-package', 'false']),
throwsToolExit(message: 'Unexpected positional argument "false".')
);
});
}