[dartdev] Organize dart --help commands into categories

This CL organizes the commands in the Dart CLI to categories. It
mirrors the categories used in `flutter --help`: `SDK`, `Project`, and
`Tools`. The available command section will now look as follows in
verbose mode:

```
Available commands:

Project
  build                 Build a Dart application including native assets.
  compile               Compile Dart to various formats.
  create                Create a new Dart project.
  pub                   Work with packages.
  run                   Run a Dart program.
  test                  Run tests for a project.

Source code
  analyze               Analyze Dart code in a directory.
  doc                   Generate API documentation for Dart projects.
  fix                   Apply automated fixes to Dart source code.
  format                Idiomatically format Dart source code.

Tools
  compilation-server    Control resident frontend compilers.
  development-service   Start Dart's development service.
  devtools              Open DevTools (optionally connecting to an existing application).
  info                  Show diagnostic information about the installed tooling.
  language-server       Start Dart's analysis server.
  tooling-daemon        Start Dart's tooling daemon.
```

Bug: https://github.com/dart-lang/sdk/issues/60980
Change-Id: Ic9da297fcdd0f8e85d619632ba8ec30fd2c32666
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436382
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Daco Harkes
2025-06-25 03:08:50 -07:00
committed by Commit Queue
parent 931ec382d4
commit 2273611355
17 changed files with 54 additions and 7 deletions
+2 -2
View File
@@ -116,11 +116,11 @@ class DartdevRunner extends CommandRunner<int> {
addCommand(DevToolsCommand(verbose: verbose));
addCommand(DocCommand(verbose: verbose));
addCommand(FixCommand(verbose: verbose));
addCommand(FormatCommand(verbose: verbose));
addCommand(FormatCommand(verbose: verbose, category: 'Source code'));
addCommand(InfoCommand(verbose: verbose));
addCommand(LanguageServerCommand(verbose: verbose));
addCommand(DartMCPServerCommand(verbose: verbose));
addCommand(pubCommand(isVerbose: () => verbose));
addCommand(pubCommand(isVerbose: () => verbose, category: 'Project'));
addCommand(RunCommand(
verbose: verbose,
nativeAssetsExperimentEnabled: nativeAssetsExperimentEnabled,
@@ -99,6 +99,9 @@ class AnalyzeCommand extends DartdevCommand {
..addExperimentalFlags();
}
@override
String get category => 'Source code';
@override
String get invocation => '${super.invocation} [<directory>]';
+3
View File
@@ -34,6 +34,9 @@ class BuildCommand extends DartdevCommand {
recordUseEnabled: recordUseEnabled,
));
}
@override
String get category => 'Project';
}
/// Subcommand for `dart build cli`.
@@ -42,6 +42,9 @@ class CompilationServerCommand extends DartdevCommand {
addSubcommand(CompilationServerStartCommand());
addSubcommand(CompilationServerShutdownCommand());
}
@override
String get category => 'Tools';
}
class CompilationServerStartCommand extends DartdevCommand {
@@ -1145,4 +1145,7 @@ class CompileCommand extends DartdevCommand {
));
addSubcommand(CompileWasmCommand(verbose: verbose));
}
@override
String get category => 'Project';
}
+3
View File
@@ -61,6 +61,9 @@ class CreateCommand extends DartdevCommand {
@override
String get invocation => '${super.invocation} <directory>';
@override
String get category => 'Project';
@override
FutureOr<int> run() async {
final args = argResults!;
@@ -39,6 +39,9 @@ EXPERIMENTAL: This tool may change dramatically or disappear at any time.''';
'experimental feature with no stability guarantees.');
}
@override
String get category => 'Tools';
@override
Future<int> run() async {
final args = argResults!;
@@ -59,6 +59,9 @@ class DebugAdapterCommand extends DartdevCommand {
);
}
@override
String get category => 'Tools';
@override
FutureOr<int> run() async {
final args = argResults!;
@@ -30,6 +30,9 @@ class DevelopmentServiceCommand extends DartdevCommand {
);
}
@override
String get category => 'Tools';
@override
Future<int> run() async {
final sdkDir = dirname(sdk.dart);
@@ -47,12 +50,11 @@ class DevelopmentServiceCommand extends DartdevCommand {
// On ia32 platforms we do not have an AOT snapshot and so we need
// to run the JIT snapshot.
useExecProcess = false;
script = fullSdk
? sdk.ddsSnapshot
: absolute(sdkDir, 'dds.dart.snapshot');
script =
fullSdk ? sdk.ddsSnapshot : absolute(sdkDir, 'dds.dart.snapshot');
if (!Sdk.checkArtifactExists(script, logError: false)) {
log.stderr('Error: launching development server failed : '
'Unable to find snapshot for the development server');
'Unable to find snapshot for the development server');
return 255;
}
}
@@ -39,6 +39,9 @@ class DevToolsCommand extends DartdevCommand {
@override
String get name => 'devtools';
@override
String get category => 'Tools';
@override
String get description => DevToolsServer.commandDescription;
+3
View File
@@ -55,6 +55,9 @@ For additional documentation generation options, see the 'dartdoc_options.yaml'
);
}
@override
String get category => 'Source code';
@override
String get invocation => '${super.invocation} [<directory>]';
+3
View File
@@ -70,6 +70,9 @@ To use the tool, run either ['dart fix --dry-run'] for a preview of the proposed
..addExperimentalFlags(verbose: verbose);
}
@override
String get category => 'Source code';
@override
String get description {
if (log.ansi.useAnsi) {
+3
View File
@@ -18,6 +18,9 @@ class InfoCommand extends DartdevCommand {
static const String cmdDescription =
'Show diagnostic information about the installed tooling.';
@override
String get category => 'Tools';
InfoCommand({bool verbose = false})
: super(cmdName, cmdDescription, verbose) {
argParser.addFlag(
@@ -15,6 +15,9 @@ import '../vm_interop_handler.dart';
class LanguageServerCommand extends DartdevCommand {
static const String commandName = 'language-server';
@override
String get category => 'Tools';
static const String commandDescription = '''
Start Dart's analysis server.
+3
View File
@@ -312,6 +312,9 @@ class RunCommand extends DartdevCommand {
String get invocation =>
'${super.invocation} [<dart-file|package-target> [args]]';
@override
String get category => 'Project';
/// Attempts to compile [executable] to a kernel file using the Resident
/// Frontend Compiler associated with [residentCompilerInfoFile]. If
/// [shouldRetryOnFrontendCompilerException] is true, when a
+3
View File
@@ -32,6 +32,9 @@ class TestCommand extends DartdevCommand {
return ArgParser.allowAnything();
}
@override
String get category => 'Project';
@override
void printUsage() {
print('''Usage: dart test [arguments]
@@ -28,6 +28,9 @@ class ToolingDaemonCommand extends DartdevCommand {
);
}
@override
String get category => 'Tools';
@override
Future<int> run() async {
var script = sdk.dartAotRuntime;
@@ -51,7 +54,7 @@ class ToolingDaemonCommand extends DartdevCommand {
script,
dtdCommand,
packageConfigOverride: null,
useExecProcess : useExecProcess,
useExecProcess: useExecProcess,
);
return 0;
} catch (e, st) {