diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-08-25 15:47:14 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2026-05-06 04:21:54 +1000 |
| commit | 7984d2ecd4bdba7061429f98fdfae88f44f4a358 (patch) | |
| tree | 70dcda52dbd0cd955a1857442ceb0e0ae1f189b2 /GetTagDefinition.cs | |
v0.13av0.13a
Diffstat (limited to 'GetTagDefinition.cs')
| -rw-r--r-- | GetTagDefinition.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/GetTagDefinition.cs b/GetTagDefinition.cs new file mode 100644 index 0000000..9d33366 --- /dev/null +++ b/GetTagDefinition.cs @@ -0,0 +1,38 @@ +using HyperBooru.ApiClient; +using HyperBooru.ApiModels; +using System.Management.Automation; + +namespace HyperBooru.PowerShell; + +[Alias("ghbtd")] +[Cmdlet(VerbsCommon.Get, "HyperBooruTagDefinition")] +public class GetTagDefinitionCmdlet : PSCmdlet { + [Parameter(Position = 0, Mandatory = true)] + public HBSession Session { get; set; } + + [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<TagDefinition>(); + 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); + } +} |
