noz-cli/NozCli/Commands/HelpCommand.cs
kryptomrx cf54165735 feat(commands): ls with detailed view, tree hierarchy, CancellationToken support
- ls: compact view with status dots and folder markers
- ls -la: table view with status, lang, date, title; folders show mini status bar
- tree: recursive hierarchy using Spectre.Console Tree widget, context-aware
- All commands: CancellationToken threaded through ExecuteAsync
- Partition() helper respects topic-relative slug depth
2026-05-16 23:20:49 +02:00

27 lines
828 B
C#

using NozCli.Repl;
using Spectre.Console;
namespace NozCli.Commands;
public class HelpCommand : ICommand
{
public string Name => "help";
public string Description => "Show available commands";
public string Usage => "help";
private readonly IReadOnlyList<ICommand> _commands;
public HelpCommand(IReadOnlyList<ICommand> commands) => _commands = commands;
public Task ExecuteAsync(string[] args, ReplContext ctx, CancellationToken ct = default)
{
var table = new Table().BorderStyle(Style.Plain).HideHeaders();
table.AddColumns("cmd", "desc");
foreach (var cmd in _commands.OrderBy(c => c.Name))
table.AddRow($"[cyan]{cmd.Usage,-28}[/]", $"[dim]{cmd.Description}[/]");
AnsiConsole.Write(table);
return Task.CompletedTask;
}
}