1
0
Files
AnchorCli/Commands/HelpCommand.cs
2026-03-04 07:59:35 +01:00

34 lines
836 B
C#

using Spectre.Console;
using System.Linq;
namespace AnchorCli.Commands;
public class HelpCommand : ICommand
{
private readonly CommandRegistry _registry;
public string Name => "help";
public string Description => "Show available commands";
public HelpCommand(CommandRegistry registry)
{
_registry = registry;
}
public Task ExecuteAsync(string[] args, CancellationToken ct)
{
AnsiConsole.MarkupLine("[cyan]Available commands:[/]");
var table = new Table();
table.AddColumn("Command");
table.AddColumn("Description");
foreach (var cmd in _registry.GetAllCommands().OrderBy(c => c.Name))
{
table.AddRow($"[bold]{cmd.Name}[/]", cmd.Description);
}
AnsiConsole.Write(table);
return Task.CompletedTask;
}
}