From e51812237eb001b04ce2fdd9bcb90f0e4230b4e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Thu, 16 Oct 2025 22:34:28 +0200 Subject: [PATCH] Update the Spectre.Console.Cli documentation with CancellationToken Now that #1911 is merged, all `Execute` methods of commands have a new CancellationToken parameter. Update the documentation to reflect that. New documentation shall still be written with an example on how to pass the top-level CancellationToken to the app.Run(Async) method. --- docs/input/cli/commands.md | 2 +- docs/input/cli/composing.md | 4 ++-- docs/input/cli/getting-started.md | 2 +- docs/input/cli/introduction.md | 4 ++-- docs/input/cli/unit-testing.md | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/input/cli/commands.md b/docs/input/cli/commands.md index 167c19cd..f77e0905 100644 --- a/docs/input/cli/commands.md +++ b/docs/input/cli/commands.md @@ -18,7 +18,7 @@ public class HelloCommand : Command } - public override int Execute(CommandContext context, Settings settings) + public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken) { AnsiConsole.MarkupLine($"Hello, [blue]{settings.Name}[/]"); return 0; diff --git a/docs/input/cli/composing.md b/docs/input/cli/composing.md index 7eafe9ce..7407106f 100644 --- a/docs/input/cli/composing.md +++ b/docs/input/cli/composing.md @@ -55,7 +55,7 @@ in the previous step. ```csharp public class AddPackageCommand : Command { - public override int Execute(CommandContext context, AddPackageSettings settings) + public override int Execute(CommandContext context, AddPackageSettings settings, CancellationToken cancellationToken) { // Omitted return 0; @@ -64,7 +64,7 @@ public class AddPackageCommand : Command public class AddReferenceCommand : Command { - public override int Execute(CommandContext context, AddReferenceSettings settings) + public override int Execute(CommandContext context, AddReferenceSettings settings, CancellationToken cancellationToken) { // Omitted return 0; diff --git a/docs/input/cli/getting-started.md b/docs/input/cli/getting-started.md index 7ccdb5dd..47b72bae 100644 --- a/docs/input/cli/getting-started.md +++ b/docs/input/cli/getting-started.md @@ -33,7 +33,7 @@ internal sealed class FileSizeCommand : Command public bool IncludeHidden { get; init; } } - public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings) + public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken) { var searchOptions = new EnumerationOptions { diff --git a/docs/input/cli/introduction.md b/docs/input/cli/introduction.md index e6dba28e..da656304 100644 --- a/docs/input/cli/introduction.md +++ b/docs/input/cli/introduction.md @@ -61,7 +61,7 @@ in the previous step. ```csharp public class AddPackageCommand : Command { - public override int Execute(CommandContext context, AddPackageSettings settings) + public override int Execute(CommandContext context, AddPackageSettings settings, CancellationToken cancellationToken) { // Omitted return 0; @@ -70,7 +70,7 @@ public class AddPackageCommand : Command public class AddReferenceCommand : Command { - public override int Execute(CommandContext context, AddReferenceSettings settings) + public override int Execute(CommandContext context, AddReferenceSettings settings, CancellationToken cancellationToken) { // Omitted return 0; diff --git a/docs/input/cli/unit-testing.md b/docs/input/cli/unit-testing.md index bef67f36..d174737c 100644 --- a/docs/input/cli/unit-testing.md +++ b/docs/input/cli/unit-testing.md @@ -40,7 +40,7 @@ The following example validates the exit code and terminal output of a `Spectre. _console = console; } - public override int Execute(CommandContext context) + public override int Execute(CommandContext context, CancellationToken cancellationToken) { _console.WriteLine("Hello world."); return 0; @@ -78,7 +78,7 @@ public sealed class InteractiveCommandTests _console = console; } - public override int Execute(CommandContext context) + public override int Execute(CommandContext context, CancellationToken cancellationToken) { var fruits = _console.Prompt( new MultiSelectionPrompt()