Unverified Commit 598737ad authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Clean up the command line tool interactive help output. (#80903)

parent b30d97a6
......@@ -9,7 +9,6 @@ import 'platform.dart';
import 'terminal.dart';
const String fire = '🔥';
const String image = '🖼️';
const int maxLineWidth = 84;
/// Encapsulates the help text construction and printing.
......@@ -32,9 +31,13 @@ class CommandHelp {
final OutputPreferences _outputPreferences;
// COMMANDS IN ALPHABETICAL ORDER.
// Uppercase first, then lowercase.
// When updating this, update all the tests in command_help_test.dart accordingly.
late final CommandHelpOption I = _makeOption(
'I',
'Toggle oversized image inversion $image.',
'Toggle oversized image inversion.',
'debugInvertOversizedImages',
);
......@@ -44,6 +47,11 @@ class CommandHelp {
'debugDumpLayerTree',
);
late final CommandHelpOption M = _makeOption(
'M',
'Write SkSL shaders to a unique file in the project directory.',
);
late final CommandHelpOption P = _makeOption(
'P',
'Toggle performance overlay.',
......@@ -75,7 +83,7 @@ class CommandHelp {
late final CommandHelpOption b = _makeOption(
'b',
'Toggle the platform brightness setting (dark and light mode).',
'Toggle platform brightness (dark and light mode).',
'debugBrightnessOverride',
);
......@@ -94,17 +102,27 @@ class CommandHelp {
'Run source code generators.'
);
late final CommandHelpOption h = _makeOption(
late final CommandHelpOption hWithDetails = _makeOption(
'h',
'Repeat this help message.',
);
late final CommandHelpOption hWithoutDetails = _makeOption(
'h',
'List all available interactive commands.',
);
late final CommandHelpOption i = _makeOption(
'i',
'Toggle widget inspector.',
'WidgetsApp.showWidgetInspectorOverride',
);
late final CommandHelpOption k = _makeOption(
'k',
'Toggle CanvasKit rendering.',
);
late final CommandHelpOption o = _makeOption(
'o',
'Simulate different operating systems.',
......@@ -147,17 +165,11 @@ class CommandHelp {
late final CommandHelpOption z = _makeOption(
'z',
'Toggle elevation checker.',
'debugCheckElevationsEnabled',
);
late final CommandHelpOption k = _makeOption(
'k',
'Toggle CanvasKit rendering.',
);
late final CommandHelpOption M = _makeOption(
'M',
'Write SkSL shaders to a unique file in the project directory.',
);
// When updating the list above, see the notes above the list regarding order
// and tests.
CommandHelpOption _makeOption(String key, String description, [
String inParenthesis = '',
......
......@@ -1449,7 +1449,6 @@ abstract class ResidentRunner extends ResidentHandlers {
commandHelp.s.print();
}
if (supportsServiceProtocol) {
commandHelp.b.print();
commandHelp.w.print();
commandHelp.t.print();
if (isRunningDebug) {
......@@ -1457,21 +1456,24 @@ abstract class ResidentRunner extends ResidentHandlers {
commandHelp.S.print();
commandHelp.U.print();
commandHelp.i.print();
commandHelp.I.print();
commandHelp.p.print();
commandHelp.I.print();
commandHelp.o.print();
commandHelp.b.print();
commandHelp.z.print();
commandHelp.g.print();
} else {
commandHelp.S.print();
commandHelp.U.print();
}
// Performance related features: `P` should precede `a`, which should precede `M`.
commandHelp.P.print();
commandHelp.a.print();
if (supportsWriteSkSL) {
commandHelp.M.print();
}
// `P` should precede `a`
commandHelp.P.print();
commandHelp.a.print();
if (isRunningDebug) {
commandHelp.g.print();
}
}
}
......
......@@ -213,8 +213,10 @@ class ColdRunner extends ResidentRunner {
globals.printStatus('Flutter run key commands.');
if (details) {
printHelpDetails();
commandHelp.hWithDetails.print();
} else {
commandHelp.hWithoutDetails.print();
}
commandHelp.h.print(); // TODO(ianh): print different message if details is false
if (_didAttach) {
commandHelp.d.print();
}
......
......@@ -1081,7 +1081,6 @@ class HotRunner extends ResidentRunner {
return message.toString();
}
@override
void printHelp({ @required bool details }) {
globals.printStatus('Flutter run key commands.');
......@@ -1089,15 +1088,17 @@ class HotRunner extends ResidentRunner {
if (supportsRestart) {
commandHelp.R.print();
}
commandHelp.h.print(); // TODO(ianh): print different message if "details" is false
if (details) {
printHelpDetails();
commandHelp.hWithDetails.print();
} else {
commandHelp.hWithoutDetails.print();
}
if (_didAttach) {
commandHelp.d.print();
}
commandHelp.c.print();
commandHelp.q.print();
if (details) {
printHelpDetails();
}
globals.printStatus('');
if (debuggingOptions.buildInfo.nullSafetyMode == NullSafetyMode.sound) {
globals.printStatus('💪 Running with sound null safety 💪', emphasis: true);
......
......@@ -1465,7 +1465,7 @@ void main() {
expect(testLogger.statusText, isEmpty);
}));
testUsingContext('ResidentRunner printHelpDetails', () => testbed.run(() {
testUsingContext('ResidentRunner printHelpDetails hot runner', () => testbed.run(() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
residentRunner.printHelp(details: true);
......@@ -1484,25 +1484,56 @@ void main() {
'Flutter run key commands.',
commandHelp.r,
commandHelp.R,
commandHelp.h,
commandHelp.c,
commandHelp.q,
commandHelp.s,
commandHelp.b,
commandHelp.w,
commandHelp.t,
commandHelp.L,
commandHelp.S,
commandHelp.U,
commandHelp.i,
commandHelp.I,
commandHelp.p,
commandHelp.I,
commandHelp.o,
commandHelp.b,
commandHelp.z,
commandHelp.g,
commandHelp.M,
commandHelp.P,
commandHelp.a,
commandHelp.M,
commandHelp.g,
commandHelp.hWithDetails,
commandHelp.c,
commandHelp.q,
'',
'💪 Running with sound null safety 💪',
'',
'An Observatory debugger and profiler on FakeDevice is available at: null',
'',
].join('\n')
));
}));
testUsingContext('ResidentRunner printHelp hot runner', () => testbed.run(() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
residentRunner.printHelp(details: false);
final CommandHelp commandHelp = residentRunner.commandHelp;
// supports service protocol
expect(residentRunner.supportsServiceProtocol, true);
// isRunningDebug
expect(residentRunner.isRunningDebug, true);
// does support SkSL
expect(residentRunner.supportsWriteSkSL, true);
// commands
expect(testLogger.statusText, equals(
<dynamic>[
'Flutter run key commands.',
commandHelp.r,
commandHelp.R,
commandHelp.hWithoutDetails,
commandHelp.c,
commandHelp.q,
'',
'💪 Running with sound null safety 💪',
'',
......@@ -1538,7 +1569,40 @@ void main() {
<dynamic>[
'Flutter run key commands.',
commandHelp.s,
commandHelp.h,
commandHelp.hWithDetails,
commandHelp.c,
commandHelp.q,
''
].join('\n')
));
}));
testUsingContext('ResidentRunner printHelp cold runner', () => testbed.run(() {
fakeVmServiceHost = null;
residentRunner = ColdRunner(
<FlutterDevice>[
mockFlutterDevice,
],
stayResident: false,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
target: 'main.dart',
devtoolsHandler: createNoOpHandler,
);
residentRunner.printHelp(details: false);
final CommandHelp commandHelp = residentRunner.commandHelp;
// does not supports service protocol
expect(residentRunner.supportsServiceProtocol, false);
// isRunningDebug
expect(residentRunner.isRunningDebug, false);
// does support SkSL
expect(residentRunner.supportsWriteSkSL, false);
// commands
expect(testLogger.statusText, equals(
<dynamic>[
'Flutter run key commands.',
commandHelp.hWithoutDetails,
commandHelp.c,
commandHelp.q,
''
......
......@@ -542,7 +542,7 @@ void main() {
'Flutter run key commands.',
startsWith('r Hot reload.'),
'R Hot restart.',
'h Repeat this help message.',
'h List all available interactive commands.',
'd Detach (terminate "flutter run" but leave application running).',
'c Clear the screen',
'q Quit (terminate the application on the device).',
......@@ -555,25 +555,25 @@ void main() {
'Flutter run key commands.',
startsWith('r Hot reload.'),
'R Hot restart.',
'h Repeat this help message.',
'd Detach (terminate "flutter run" but leave application running).',
'c Clear the screen',
'q Quit (terminate the application on the device).',
'b Toggle the platform brightness setting (dark and light mode). (debugBrightnessOverride)',
'w Dump widget hierarchy to the console. (debugDumpApp)',
't Dump rendering tree to the console. (debugDumpRenderTree)',
'L Dump layer tree to the console. (debugDumpLayerTree)',
'S Dump accessibility tree in traversal order. (debugDumpSemantics)',
'U Dump accessibility tree in inverse hit test order. (debugDumpSemantics)',
'i Toggle widget inspector. (WidgetsApp.showWidgetInspectorOverride)',
startsWith('I Toggle oversized image inversion'),
'p Toggle the display of construction lines. (debugPaintSizeEnabled)',
'I Toggle oversized image inversion. (debugInvertOversizedImages)',
'o Simulate different operating systems. (defaultTargetPlatform)',
'z Toggle elevation checker.',
'g Run source code generators.',
'M Write SkSL shaders to a unique file in the project directory.',
'b Toggle platform brightness (dark and light mode). (debugBrightnessOverride)',
'z Toggle elevation checker. (debugCheckElevationsEnabled)',
'P Toggle performance overlay. (WidgetsApp.showPerformanceOverlay)',
'a Toggle timeline events for all widget build methods. (debugProfileWidgetBuilds)',
'M Write SkSL shaders to a unique file in the project directory.',
'g Run source code generators.',
'h Repeat this help message.',
'd Detach (terminate "flutter run" but leave application running).',
'c Clear the screen',
'q Quit (terminate the application on the device).',
'',
contains('Running with sound null safety'),
'',
......
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