25 lines
720 B
C#
25 lines
720 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)
|
|
{
|
|
var slug = args.FirstOrDefault();
|
|
if (slug is null) { AnsiConsole.MarkupLine("[red]Usage: cat <slug>[/]"); return; }
|
|
|
|
slug = ctx.ResolveSlug(slug);
|
|
|
|
await AnsiConsole.Status().StartAsync("Fetching…", async _ =>
|
|
{
|
|
var note = await ctx.Api.GetNoteAsync(slug);
|
|
AnsiConsole.WriteLine(note.Markdown);
|
|
});
|
|
}
|
|
}
|