Compare commits

...

2 Commits

Author SHA1 Message Date
renovate[bot]
3d3eef532b chore: Update dependency Verify.Xunit to 31.0.4 2025-10-21 21:03:56 +00:00
Cédric Luthi
e51812237e 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.
2025-10-16 22:50:52 +02:00
6 changed files with 9 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ public class HelloCommand : Command<HelloCommand.Settings>
} }
public override int Execute(CommandContext context, Settings settings) public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
{ {
AnsiConsole.MarkupLine($"Hello, [blue]{settings.Name}[/]"); AnsiConsole.MarkupLine($"Hello, [blue]{settings.Name}[/]");
return 0; return 0;

View File

@@ -55,7 +55,7 @@ in the previous step.
```csharp ```csharp
public class AddPackageCommand : Command<AddPackageSettings> public class AddPackageCommand : Command<AddPackageSettings>
{ {
public override int Execute(CommandContext context, AddPackageSettings settings) public override int Execute(CommandContext context, AddPackageSettings settings, CancellationToken cancellationToken)
{ {
// Omitted // Omitted
return 0; return 0;
@@ -64,7 +64,7 @@ public class AddPackageCommand : Command<AddPackageSettings>
public class AddReferenceCommand : Command<AddReferenceSettings> public class AddReferenceCommand : Command<AddReferenceSettings>
{ {
public override int Execute(CommandContext context, AddReferenceSettings settings) public override int Execute(CommandContext context, AddReferenceSettings settings, CancellationToken cancellationToken)
{ {
// Omitted // Omitted
return 0; return 0;

View File

@@ -33,7 +33,7 @@ internal sealed class FileSizeCommand : Command<FileSizeCommand.Settings>
public bool IncludeHidden { get; init; } 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 var searchOptions = new EnumerationOptions
{ {

View File

@@ -61,7 +61,7 @@ in the previous step.
```csharp ```csharp
public class AddPackageCommand : Command<AddPackageSettings> public class AddPackageCommand : Command<AddPackageSettings>
{ {
public override int Execute(CommandContext context, AddPackageSettings settings) public override int Execute(CommandContext context, AddPackageSettings settings, CancellationToken cancellationToken)
{ {
// Omitted // Omitted
return 0; return 0;
@@ -70,7 +70,7 @@ public class AddPackageCommand : Command<AddPackageSettings>
public class AddReferenceCommand : Command<AddReferenceSettings> public class AddReferenceCommand : Command<AddReferenceSettings>
{ {
public override int Execute(CommandContext context, AddReferenceSettings settings) public override int Execute(CommandContext context, AddReferenceSettings settings, CancellationToken cancellationToken)
{ {
// Omitted // Omitted
return 0; return 0;

View File

@@ -40,7 +40,7 @@ The following example validates the exit code and terminal output of a `Spectre.
_console = console; _console = console;
} }
public override int Execute(CommandContext context) public override int Execute(CommandContext context, CancellationToken cancellationToken)
{ {
_console.WriteLine("Hello world."); _console.WriteLine("Hello world.");
return 0; return 0;
@@ -78,7 +78,7 @@ public sealed class InteractiveCommandTests
_console = console; _console = console;
} }
public override int Execute(CommandContext context) public override int Execute(CommandContext context, CancellationToken cancellationToken)
{ {
var fruits = _console.Prompt( var fruits = _console.Prompt(
new MultiSelectionPrompt<string>() new MultiSelectionPrompt<string>()

View File

@@ -17,7 +17,7 @@
<PackageVersion Include="StyleCop.Analyzers" PrivateAssets="All" Version="1.2.0-beta.556" /> <PackageVersion Include="StyleCop.Analyzers" PrivateAssets="All" Version="1.2.0-beta.556" />
<PackageVersion Include="System.Memory" Version="4.6.3" /> <PackageVersion Include="System.Memory" Version="4.6.3" />
<PackageVersion Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" /> <PackageVersion Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" />
<PackageVersion Include="Verify.Xunit" Version="31.0.1" /> <PackageVersion Include="Verify.Xunit" Version="31.0.4" />
<PackageVersion Include="Wcwidth.Sources" Version="3.0.0" /> <PackageVersion Include="Wcwidth.Sources" Version="3.0.0" />
<PackageVersion Include="xunit" Version="2.9.3" /> <PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5"> <PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5">