- Get-NozNote: list notes, filter by -Topic, -Status, -Lang - Get-NozNoteContent: fetch markdown, accepts pipeline input by Slug - Set-NozNote: update note content, accepts markdown from pipeline - New-NozNote: create note with frontmatter template - Remove-NozNote: delete note, ShouldProcess + ConfirmImpact.High for safety - NozNote output object: clean PS-friendly properties (no internal Hash field) - NozCmdletBase: shared config loading, API client lifecycle, error translation - Noz.psd1: module manifest for PS 7.2+ - Install-NozModule.ps1: build + install to user module path - NozCli.Core retargeted to net8.0 for PS 7.4 LTS compatibility
24 lines
918 B
C#
24 lines
918 B
C#
using System.Management.Automation;
|
|
|
|
namespace Noz.PowerShell.Cmdlets;
|
|
|
|
/// <summary>Delete a note from the server.</summary>
|
|
/// <example>
|
|
/// Remove-NozNote -Slug psychologie/alte-notiz
|
|
/// Get-NozNote -Status seed | Where-Object Topic -eq "draft" | Remove-NozNote -WhatIf
|
|
/// Get-NozNote -Status seed | Where-Object Topic -eq "draft" | Remove-NozNote -Confirm:$false
|
|
/// </example>
|
|
[Cmdlet(VerbsCommon.Remove, "NozNote", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
|
|
public sealed class RemoveNozNoteCmdlet : NozCmdletBase
|
|
{
|
|
[Parameter(Mandatory = true, Position = 0,
|
|
ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
|
|
public string Slug { get; set; } = "";
|
|
|
|
protected override void ProcessRecord()
|
|
{
|
|
if (!ShouldProcess(Slug, "Delete note")) return;
|
|
Run(Api.DeleteNoteAsync(Slug));
|
|
WriteVerbose($"Deleted: {Slug}");
|
|
}
|
|
}
|