noz-cli/NozCli/Commands/CatCommand.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

25 lines
777 B
C#

using NozCli.Repl;
using Spectre.Console;
namespace NozCli.Commands;
public class CatCommand : ICommand
{
public string Name => "cat";
public string Description => "Print the raw markdown of a note";
public string Usage => "cat <slug>";
public async Task ExecuteAsync(string[] args, ReplContext ctx, CancellationToken ct = default)
{
var slug = args.FirstOrDefault();
if (slug is null) { AnsiConsole.MarkupLine("[red]Usage: cat <slug>[/]"); return; }
slug = ctx.ResolveSlug(slug);
Core.Models.NoteContent note = default!;
await AnsiConsole.Status().StartAsync("Fetching…", async _ =>
note = await ctx.Api.GetNoteAsync(slug, ct));
AnsiConsole.WriteLine(note.Markdown);
}
}