Unverified Commit 3e43c3e1 authored by Pierre-Louis's avatar Pierre-Louis Committed by GitHub

Categorize flutter tool commands (#87747)

parent 0a626945
......@@ -105,6 +105,9 @@ class AnalyzeCommand extends FlutterCommand {
@override
String get description => "Analyze the project's Dart code.";
@override
String get category => FlutterCommandCategory.project;
@override
bool get shouldRunPub {
// If they're not analyzing the current project.
......
......@@ -139,6 +139,9 @@ class AssembleCommand extends FlutterCommand {
@override
String get name => 'assemble';
@override
String get category => FlutterCommandCategory.project;
@override
Future<CustomDimensions> get usageValues async {
final FlutterProject flutterProject = FlutterProject.current();
......
......@@ -144,6 +144,9 @@ If the app or module is already running and the specific observatory port is
known, it can be explicitly provided to attach via the command-line, e.g.
`$ flutter attach --debug-port 12345`''';
@override
final String category = FlutterCommandCategory.tools;
int get debugPort {
if (argResults['debug-port'] == null) {
return null;
......
......@@ -57,6 +57,9 @@ class BuildCommand extends FlutterCommand {
@override
final String description = 'Build an executable app or install bundle.';
@override
String get category => FlutterCommandCategory.project;
@override
Future<FlutterCommandResult> runCommand() async => null;
}
......
......@@ -27,6 +27,9 @@ class ChannelCommand extends FlutterCommand {
@override
final String description = 'List or switch Flutter channels.';
@override
final String category = FlutterCommandCategory.sdk;
@override
String get invocation => '${runner.executableName} $name [<channel-name>]';
......
......@@ -29,6 +29,9 @@ class CleanCommand extends FlutterCommand {
@override
final String description = 'Delete the build/ and .dart_tool/ directories.';
@override
String get category => FlutterCommandCategory.project;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};
......
......@@ -54,6 +54,9 @@ class ConfigCommand extends FlutterCommand {
'The Flutter tool anonymously reports feature usage statistics and basic crash reports to help improve '
"Flutter tools over time. See Google's privacy policy: https://www.google.com/intl/en/policies/privacy/";
@override
final String category = FlutterCommandCategory.sdk;
@override
final List<String> aliases = <String>['configure'];
......
......@@ -78,6 +78,9 @@ class CreateCommand extends CreateBase {
final String description = 'Create a new Flutter project.\n\n'
'If run on a project that already exists, this will repair the project, recreating any files that are missing.';
@override
String get category => FlutterCommandCategory.project;
@override
String get invocation => '${runner.executableName} $name <output directory>';
......
......@@ -158,6 +158,9 @@ Requires the custom devices feature to be enabled. You can enable it using "flut
@override
String get name => 'custom-devices';
@override
String get category => FlutterCommandCategory.tools;
@override
Future<FlutterCommandResult> runCommand() async => null;
......
......@@ -49,6 +49,9 @@ class DaemonCommand extends FlutterCommand {
@override
final String description = 'Run a persistent, JSON-RPC based server to communicate with devices.';
@override
final String category = FlutterCommandCategory.tools;
@override
final bool hidden;
......
......@@ -33,6 +33,9 @@ class DevicesCommand extends FlutterCommand {
@override
final String description = 'List all connected devices.';
@override
final String category = FlutterCommandCategory.tools;
@override
Duration get deviceDiscoveryTimeout {
if (argResults['timeout'] != null) {
......
......@@ -31,6 +31,9 @@ class DoctorCommand extends FlutterCommand {
@override
final String description = 'Show information about the installed tooling.';
@override
final String category = FlutterCommandCategory.sdk;
@override
Future<FlutterCommandResult> runCommand() async {
globals.flutterVersion.fetchTagsAndUpdate();
......
......@@ -76,6 +76,9 @@ class DowngradeCommand extends FlutterCommand {
@override
String get name => 'downgrade';
@override
final String category = FlutterCommandCategory.sdk;
@override
Future<FlutterCommandResult> runCommand() async {
// Commands do not necessarily have access to the correct zone injected
......
......@@ -22,7 +22,7 @@ import '../device.dart';
import '../drive/drive_service.dart';
import '../globals_null_migrated.dart' as globals;
import '../resident_runner.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult, FlutterOptions;
import '../runner/flutter_command.dart' show FlutterCommandCategory, FlutterCommandResult, FlutterOptions;
import '../web/web_device.dart';
import 'run.dart';
......@@ -172,6 +172,9 @@ class DriveCommand extends RunCommandBase {
@override
final String description = 'Run integration tests for the project on an attached device or emulator.';
@override
String get category => FlutterCommandCategory.project;
@override
final List<String> aliases = <String>['driver'];
......
......@@ -31,6 +31,9 @@ class EmulatorsCommand extends FlutterCommand {
@override
final String description = 'List, launch and create emulators.';
@override
final String category = FlutterCommandCategory.tools;
@override
final List<String> aliases = <String>['emulator'];
......
......@@ -29,6 +29,9 @@ class FormatCommand extends FlutterCommand {
@override
final String description = 'Format one or more Dart files.';
@override
String get category => FlutterCommandCategory.project;
@override
String get invocation => '${runner.executableName} $name <one or more paths>';
......
......@@ -194,6 +194,9 @@ class GenerateLocalizationsCommand extends FlutterCommand {
@override
String get name => 'gen-l10n';
@override
String get category => FlutterCommandCategory.project;
@override
Future<FlutterCommandResult> runCommand() async {
if (_fileSystem.file('l10n.yaml').existsSync()) {
......
......@@ -30,6 +30,9 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
@override
final String description = 'Install a Flutter app on an attached device.';
@override
final String category = FlutterCommandCategory.tools;
Device device;
bool get uninstallOnly => boolArg('uninstall-only');
......
......@@ -28,6 +28,9 @@ class LogsCommand extends FlutterCommand {
@override
final String description = 'Show log output for running Flutter apps.';
@override
final String category = FlutterCommandCategory.tools;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};
......
......@@ -50,6 +50,9 @@ class PackagesCommand extends FlutterCommand {
@override
final String description = 'Commands for managing Flutter packages.';
@override
String get category => FlutterCommandCategory.project;
@override
Future<FlutterCommandResult> runCommand() async => null;
}
......
......@@ -77,6 +77,9 @@ class PrecacheCommand extends FlutterCommand {
'If no explicit platform flags are provided, this command will download the artifacts '
'for all currently enabled platforms';
@override
final String category = FlutterCommandCategory.sdk;
@override
bool get shouldUpdateCache => false;
......
......@@ -343,6 +343,9 @@ class RunCommand extends RunCommandBase {
@override
final String description = 'Run your Flutter app on an attached device.';
@override
String get category => FlutterCommandCategory.project;
List<Device> devices;
bool webMode = false;
......
......@@ -61,6 +61,9 @@ class ScreenshotCommand extends FlutterCommand {
@override
String get description => 'Take a screenshot from a connected device.';
@override
final String category = FlutterCommandCategory.tools;
@override
final List<String> aliases = <String>['pic'];
......
......@@ -31,6 +31,9 @@ class ShellCompletionCommand extends FlutterCommand {
'install it in your shell environment. Once it is sourced, your shell will be able to '
'complete flutter commands and options.';
@override
final String category = FlutterCommandCategory.sdk;
@override
final List<String> aliases = <String>['zsh-completion'];
......
......@@ -59,6 +59,9 @@ class SymbolizeCommand extends FlutterCommand {
@override
String get name => 'symbolize';
@override
final String category = FlutterCommandCategory.tools;
@override
bool get shouldUpdateCache => false;
......
......@@ -249,6 +249,9 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
@override
String get description => 'Run Flutter unit tests for the current project.';
@override
String get category => FlutterCommandCategory.project;
@override
Future<FlutterCommandResult> verifyThenRunCommand(String commandPath) {
_testFiles = argResults.rest.map<String>(globals.fs.path.absolute).toList();
......
......@@ -63,6 +63,9 @@ class UpgradeCommand extends FlutterCommand {
@override
final String description = 'Upgrade your copy of Flutter.';
@override
final String category = FlutterCommandCategory.sdk;
@override
bool get shouldUpdateCache => false;
......
......@@ -122,6 +122,13 @@ class FlutterOptions {
static const String kInitializeFromDill = 'initialize-from-dill';
}
/// flutter command categories for usage.
class FlutterCommandCategory {
static const String sdk = 'Flutter SDK';
static const String project = 'Project';
static const String tools = 'Tools & Devices';
}
abstract class FlutterCommand extends Command<void> {
/// The currently executing command (or sub-command).
///
......
......@@ -7,6 +7,7 @@
import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:flutter_tools/executable.dart' as executable;
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import '../src/common.dart';
......@@ -34,6 +35,18 @@ void verifyCommandRunner(CommandRunner<Object> runner) {
void verifyCommand(Command<Object> runner) {
expect(runner.argParser, isNotNull, reason: 'command ${runner.name} has no argParser');
verifyOptions(runner.name, runner.argParser.options.values);
if (runner.hidden == false && runner.parent == null) {
expect(
runner.category,
anyOf(
FlutterCommandCategory.sdk,
FlutterCommandCategory.project,
FlutterCommandCategory.tools,
),
reason: "top-level command ${runner.name} doesn't have a valid category",
);
}
runner.subcommands.values.forEach(verifyCommand);
}
......
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