- 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
28 lines
905 B
C#
28 lines
905 B
C#
using NozCli.Repl;
|
|
using Spectre.Console;
|
|
|
|
namespace NozCli.Commands;
|
|
|
|
public class RmCommand : ICommand
|
|
{
|
|
public string Name => "rm";
|
|
public string Description => "Delete a note from the server";
|
|
public string Usage => "rm <slug>";
|
|
|
|
public async Task ExecuteAsync(string[] args, ReplContext ctx, CancellationToken ct = default)
|
|
{
|
|
var slug = args.FirstOrDefault();
|
|
if (slug is null) { AnsiConsole.MarkupLine("[red]Usage: rm <slug>[/]"); return; }
|
|
|
|
slug = ctx.ResolveSlug(slug);
|
|
|
|
if (!AnsiConsole.Confirm($"[red]Delete[/] {slug} from server?", defaultValue: false))
|
|
return;
|
|
|
|
await AnsiConsole.Status().StartAsync("Deleting…", async _ =>
|
|
await ctx.Api.DeleteNoteAsync(slug, ct));
|
|
|
|
ctx.NoteCache.RemoveAll(n => n.Slug == slug);
|
|
AnsiConsole.MarkupLine($"[green]✓[/] {slug} deleted");
|
|
}
|
|
}
|