Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/Cli/Delegates/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading;
using System.Threading.Tasks;
using Spectre.Console;
using Spectre.Console.Cli;
Expand Down Expand Up @@ -27,13 +28,13 @@ public static int Main(string[] args)
return app.Run(args);
}

private static int Foo(CommandContext context)
private static int Foo(CommandContext context, CancellationToken cancellationToken)
{
AnsiConsole.WriteLine("Foo");
return 0;
}

private static int Bar(CommandContext context, BarSettings settings)
private static int Bar(CommandContext context, BarSettings settings, CancellationToken cancellationToken)
{
for (var index = 0; index < settings.Count; index++)
{
Expand All @@ -43,13 +44,13 @@ private static int Bar(CommandContext context, BarSettings settings)
return 0;
}

private static Task<int> FooAsync(CommandContext context)
private static Task<int> FooAsync(CommandContext context, CancellationToken cancellationToken)
{
AnsiConsole.WriteLine("Foo");
return Task.FromResult(0);
}

private static Task<int> BarAsync(CommandContext context, BarSettings settings)
private static Task<int> BarAsync(CommandContext context, BarSettings settings, CancellationToken cancellationToken)
{
for (var index = 0; index < settings.Count; index++)
{
Expand Down
3 changes: 2 additions & 1 deletion examples/Cli/Demo/Commands/Add/AddPackageCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Threading;
using Demo.Utilities;
using Spectre.Console.Cli;

Expand Down Expand Up @@ -38,7 +39,7 @@ public sealed class Settings : AddSettings
public bool Interactive { get; set; }
}

public override int Execute(CommandContext context, Settings settings)
public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
{
SettingsDumper.Dump(settings);
return 0;
Expand Down
3 changes: 2 additions & 1 deletion examples/Cli/Demo/Commands/Add/AddReferenceCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Threading;
using Demo.Utilities;
using Spectre.Console.Cli;

Expand All @@ -21,7 +22,7 @@ public sealed class Settings : AddSettings
public bool Interactive { get; set; }
}

public override int Execute(CommandContext context, Settings settings)
public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
{
SettingsDumper.Dump(settings);
return 0;
Expand Down
3 changes: 2 additions & 1 deletion examples/Cli/Demo/Commands/Run/RunCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Threading;
using Demo.Utilities;
using Spectre.Console.Cli;

Expand Down Expand Up @@ -61,7 +62,7 @@ public sealed class Settings : CommandSettings
public bool Force { get; set; }
}

public override int Execute(CommandContext context, Settings settings)
public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
{
SettingsDumper.Dump(settings);
return 0;
Expand Down
3 changes: 2 additions & 1 deletion examples/Cli/Demo/Commands/Serve/ServeCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Threading;
using Demo.Utilities;
using Spectre.Console.Cli;

Expand All @@ -19,7 +20,7 @@ public sealed class Settings : CommandSettings
public FlagValue<string> OpenBrowser { get; set; }
}

public override int Execute(CommandContext context, Settings settings)
public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
{
if (settings.OpenBrowser.IsSet)
{
Expand Down
3 changes: 2 additions & 1 deletion examples/Cli/Dynamic/MyCommand.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System;
using System.Threading;
using Spectre.Console;
using Spectre.Console.Cli;

namespace Dynamic;

public sealed class MyCommand : Command
{
public override int Execute(CommandContext context)
public override int Execute(CommandContext context, CancellationToken cancellationToken)
{
if (!(context.Data is int data))
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Cli/Help/DefaultCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public DefaultCommand(IAnsiConsole console)
_console = console;
}

public override int Execute(CommandContext context)
public override int Execute(CommandContext context, CancellationToken cancellationToken)
{
_console.WriteLine("Hello world");
return 0;
Expand Down
3 changes: 2 additions & 1 deletion examples/Cli/Injection/Commands/DefaultCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Threading;
using Spectre.Console.Cli;

namespace Injection.Commands;
Expand All @@ -21,7 +22,7 @@ public DefaultCommand(IGreeter greeter)
_greeter = greeter ?? throw new ArgumentNullException(nameof(greeter));
}

public override int Execute(CommandContext context, Settings settings)
public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
{
_greeter.Greet(settings.Name);
return 0;
Expand Down
3 changes: 2 additions & 1 deletion examples/Cli/Logging/Commands/HelloCommand.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading;
using Microsoft.Extensions.Logging;
using Spectre.Console;
using Spectre.Console.Cli;
Expand All @@ -23,7 +24,7 @@ public class Settings : LogCommandSettings
}


public override int Execute(CommandContext context, Settings settings)
public override int Execute(CommandContext context, Settings settings, CancellationToken cancellationToken)
{
_logger.LogInformation("Starting my command");
AnsiConsole.MarkupLine($"Hello, [blue]{settings.Name}[/]");
Expand Down
2 changes: 1 addition & 1 deletion examples/Cli/Testing/CommandAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public HelloWorldCommand(IAnsiConsole console)
_console = console;
}

public override int Execute(CommandContext context)
public override int Execute(CommandContext context, CancellationToken cancellationToken)
{
_console.WriteLine("Hello world.");
return 0;
Expand Down
10 changes: 5 additions & 5 deletions examples/Shared/Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageReference Include="Spectre.Console.ImageSharp" Version="0.49.1" />
<PackageReference Include="Spectre.Console.Json" Version="0.49.1" />
<PackageReference Include="Spectre.Console.Testing" Version="0.49.1" />
<PackageReference Include="Spectre.Console" Version="0.53.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.53.0" />
<PackageReference Include="Spectre.Console.ImageSharp" Version="0.53.0" />
<PackageReference Include="Spectre.Console.Json" Version="0.53.0" />
<PackageReference Include="Spectre.Console.Testing" Version="0.53.0" />
</ItemGroup>

</Project>