Unverified Commit 516b60bd authored by Greg Price's avatar Greg Price Committed by GitHub

Give error on too many arguments to `flutter config` (#121494)

Give error on too many arguments to `flutter config`
parent a297cb36
...@@ -101,6 +101,16 @@ class ConfigCommand extends FlutterCommand { ...@@ -101,6 +101,16 @@ class ConfigCommand extends FlutterCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
final List<String> rest = argResults?.rest ?? <String>[];
if (rest.isNotEmpty) {
throwToolExit(exitCode: 2,
'error: flutter config: Too many arguments.\n'
'\n'
'If a value has a space in it, enclose in quotes on the command line\n'
'to make a single argument. For example:\n'
' flutter config --android-studio-dir "/opt/Android Studio"');
}
if (boolArgDeprecated('machine')) { if (boolArgDeprecated('machine')) {
await handleMachine(); await handleMachine();
return FlutterCommandResult.success(); return FlutterCommandResult.success();
......
...@@ -44,6 +44,19 @@ void main() { ...@@ -44,6 +44,19 @@ void main() {
} }
group('config', () { group('config', () {
testUsingContext('throws error on excess arguments', () {
final ConfigCommand configCommand = ConfigCommand();
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
expect(() => commandRunner.run(<String>[
'config',
'--android-studio-dir=/opt/My', 'Android', 'Studio',
]), throwsToolExit());
verifyNoAnalytics();
}, overrides: <Type, Generator>{
Usage: () => testUsage,
});
testUsingContext('machine flag', () async { testUsingContext('machine flag', () async {
final ConfigCommand command = ConfigCommand(); final ConfigCommand command = ConfigCommand();
await command.handleMachine(); await command.handleMachine();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment