using HyperBooru.ApiModels; using System.Management.Automation; namespace HyperBooru.PowerShell; [Alias("ghbtd")] [Cmdlet(VerbsCommon.Get, "HyperBooruTagDefinition")] public class GetTagDefinitionCmdlet : SessionCmdlet { [Parameter(Position = 1, Mandatory = true, ParameterSetName = "AllTags")] public SwitchParameter All { get; set; } [Parameter(Position = 1, Mandatory = true, ParameterSetName = "IndividualTag")] public Guid TagDefinitionId { get; set; } protected override void ProcessRecord() { var tagDefinitions = Array.Empty(); switch(ParameterSetName) { case "AllTags": tagDefinitions = Session.Tag.GetTagDefinitionAsync() .GetAwaiter() .GetResult(); break; case "IndividualTag": tagDefinitions = [ Session.Tag.GetTagDefinitionAsync(TagDefinitionId) .GetAwaiter() .GetResult() ]; break; } if(tagDefinitions?.Count() > 0) foreach(var td in tagDefinitions) WriteObject(td); } }