Files
spectre.console/src/Spectre.Console.Cli/Internal/Commands/VersionCommand.cs
Cédric Luthi f5f61ca610 Add top-level CancellationToken support to Spectre.Console.Cli
Also raise CA2016 (forward the CancellationToken parameter to methods that take one) to warning

Fixes #701
2025-10-11 20:51:01 +02:00

26 lines
854 B
C#

namespace Spectre.Console.Cli;
[Description("Displays the CLI library version")]
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
internal sealed class VersionCommand : Command, IBuiltInCommand
{
private readonly IAnsiConsole _writer;
public VersionCommand(IConfiguration configuration)
{
_writer = configuration.Settings.Console.GetConsole();
}
public override int Execute(CommandContext context, CancellationToken cancellationToken)
{
_writer.MarkupLine(
"[yellow]Spectre.Cli[/] version [aqua]{0}[/]",
VersionHelper.GetVersion(typeof(VersionCommand)?.Assembly));
_writer.MarkupLine(
"[yellow]Spectre.Console[/] version [aqua]{0}[/]",
VersionHelper.GetVersion(typeof(IAnsiConsole)?.Assembly));
return 0;
}
}