From 973404a27f69b683e58f1898d3b2b27a8e86d6da Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 8 Oct 2020 14:06:58 -0700 Subject: [PATCH] [flutter_tools] support powershell style help request (#67493) --- packages/flutter_tools/lib/executable.dart | 5 +++++ .../integration.shard/command_output_test.dart | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index 3a53c91203..c625381f05 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -60,6 +60,11 @@ import 'src/web/web_runner.dart'; Future main(List args) async { final bool veryVerbose = args.contains('-vv'); final bool verbose = args.contains('-v') || args.contains('--verbose') || veryVerbose; + // Support the -? Powershell help idiom. + final int powershellHelpIndex = args.indexOf('-?'); + if (powershellHelpIndex != -1) { + args[powershellHelpIndex] = '-h'; + } final bool doctor = (args.isNotEmpty && args.first == 'doctor') || (args.length == 2 && verbose && args.last == 'doctor'); diff --git a/packages/flutter_tools/test/integration.shard/command_output_test.dart b/packages/flutter_tools/test/integration.shard/command_output_test.dart index b984076ad2..da77ad7458 100644 --- a/packages/flutter_tools/test/integration.shard/command_output_test.dart +++ b/packages/flutter_tools/test/integration.shard/command_output_test.dart @@ -33,6 +33,21 @@ void main() { expect(result.stdout, isNot(contains('exiting with code 0'))); }); + testWithoutContext('Flutter help is shown with -? command line argument', () async { + final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); + final ProcessResult result = await processManager.run([ + flutterBin, + ...getLocalEngineArguments(), + '-?', + ]); + + // Development tools. + expect(result.stdout, contains( + 'Run "flutter help " for more information about a command.\n' + 'Run "flutter help -v" for verbose help output, including less commonly used options.' + )); + }); + testWithoutContext('flutter doctor is not verbose', () async { final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final ProcessResult result = await processManager.run([