- 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
25 lines
777 B
C#
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);
|
|
}
|
|
}
|