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