📄 OutGridTree/OutGridTree.cs
using System.Management.Automation;
using System.Management.Automation.Internal;

namespace OutGridTree;

[Cmdlet(VerbsData.Out, "GridTree")]
[Alias("ogt")]
public sealed class OutGridTree : Cmdlet
{
    [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
    public PSObject InputObject { get; set; } = AutomationNull.Value;

    private GridTreeWindow? window;

    protected override void BeginProcessing()
    {
        window = AvaloniaManager.OpenWindow<GridTreeWindow>();
    }

    protected override void ProcessRecord()
    {
        // TODO: Add record to window
        WriteDebug($"Processing record: {InputObject}");
    }

    protected override void EndProcessing()
    {
        // TODO: Wait for window to close
        WriteDebug("End processing");
        WriteDebug("Exited");
    }

    protected override void StopProcessing()
    {
        // TODO: Close window
        WriteDebug("Stop processing");
        window?.Close();
        WriteDebug("Shutdown");
    }
}