- 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
31 lines
1 KiB
C#
31 lines
1 KiB
C#
using System.Management.Automation;
|
|
|
|
namespace Noz.PowerShell.Cmdlets;
|
|
|
|
/// <summary>Update the markdown content of an existing note.</summary>
|
|
/// <example>
|
|
/// Set-NozNote -Slug psychologie/test -Markdown "# Test`n`nHello."
|
|
/// Get-Content note.md -Raw | Set-NozNote -Slug psychologie/test
|
|
/// </example>
|
|
[Cmdlet(VerbsCommon.Set, "NozNote", SupportsShouldProcess = true)]
|
|
[OutputType(typeof(NozNote))]
|
|
public sealed class SetNozNoteCmdlet : NozCmdletBase
|
|
{
|
|
[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true)]
|
|
public string Slug { get; set; } = "";
|
|
|
|
[Parameter(Mandatory = true, Position = 1, ValueFromPipeline = true)]
|
|
public string Markdown { get; set; } = "";
|
|
|
|
protected override void ProcessRecord()
|
|
{
|
|
if (!ShouldProcess(Slug, "Update note")) return;
|
|
|
|
Run(Api.PutNoteAsync(Slug, Markdown));
|
|
|
|
var notes = Run(Api.GetNotesAsync());
|
|
var updated = notes.FirstOrDefault(n => n.Slug == Slug);
|
|
if (updated is not null)
|
|
WriteObject(NozNote.From(updated));
|
|
}
|
|
}
|