Skip to content

Commit 72fc9b4

Browse files
authored
Explain how to use flutter channel. (#158533)
Closes flutter/flutter#152274. I ran into flutter/flutter#152274 myself, so seemed like an easy fix.
1 parent ee586d4 commit 72fc9b4

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

packages/flutter_tools/lib/src/commands/channel.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,21 @@ class ChannelCommand extends FlutterCommand {
2929
}
3030

3131
@override
32-
final String name = 'channel';
32+
String get name => 'channel';
3333

3434
@override
35-
final String description = 'List or switch Flutter channels.';
35+
String get description => 'List or switch Flutter channels.\n'
36+
'\n'
37+
'Common commands:\n'
38+
'\n'
39+
' flutter channel\n'
40+
' List Flutter channels.\n'
41+
'\n'
42+
' flutter channel main\n'
43+
" Switch to Flutter's main channel.";
3644

3745
@override
38-
final String category = FlutterCommandCategory.sdk;
46+
String get category => FlutterCommandCategory.sdk;
3947

4048
@override
4149
String get invocation => '${runner?.executableName} $name [<channel-name>]';

packages/flutter_tools/test/general.shard/channel_test.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ void main() {
5454
);
5555
}
5656

57+
testUsingContext('usage (--help) explains how to use channel', () async {
58+
final ChannelCommand command = ChannelCommand();
59+
60+
// Required because otherwise command.usage fails as it is not hooked up.
61+
createTestCommandRunner(command);
62+
63+
// TODO(matanlurey): https://github.com/flutter/flutter/issues/158532
64+
//
65+
// <Command>.usage is checked instead of log output because by default
66+
// every command emits usage directly to stdout (via print) instead of
67+
// to the interfaces provided. It would be a much larger refactor to
68+
// change how every command works:
69+
expect(
70+
command.usage,
71+
stringContainsInOrder(<String>[
72+
'List or switch Flutter channels',
73+
'Common commands:',
74+
'List Flutter channels',
75+
"Switch to Flutter's main channel.",
76+
]),
77+
);
78+
}, overrides: <Type, Generator>{
79+
ProcessManager: () => FakeProcessManager.empty(),
80+
FileSystem: () => MemoryFileSystem.test(),
81+
});
82+
5783
testUsingContext('list', () async {
5884
await simpleChannelTest(<String>['channel']);
5985
}, overrides: <Type, Generator>{

0 commit comments

Comments
 (0)