Unverified Commit bec63a54 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tools] Provide global options with subcommand help text (#54884)

parent 6c70a8fe
......@@ -848,6 +848,23 @@ abstract class FlutterCommand extends Command<void> {
}
}
@override
String get usage {
final String usageWithoutDescription = super.usage.substring(
// The description plus two newlines.
description.length + 2,
);
final String help = <String>[
description,
'',
'Global options:',
runner.argParser.usage,
'',
usageWithoutDescription,
].join('\n');
return help;
}
ApplicationPackageStore applicationPackages;
/// Gets the parsed command-line option named [name] as `bool`.
......
......@@ -42,6 +42,12 @@ void main() {
when(mockProcessInfo.maxRss).thenReturn(10);
});
testUsingContext('help text contains global options', () {
final FakeCommand fake = FakeCommand();
createTestCommandRunner(fake);
expect(fake.usage, contains('Global options:\n'));
});
testUsingContext('honors shouldUpdateCache false', () async {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: false);
await flutterCommand.run();
......@@ -423,10 +429,9 @@ void main() {
});
}
class FakeCommand extends FlutterCommand {
@override
String get description => null;
String get description => 'A fake command';
@override
String get name => 'fake';
......
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