blob: 916f1b799c1c43e06211a1c17f6ebc60de595078 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
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<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);
}
}
|