summaryrefslogtreecommitdiff
path: root/SetTagDefinition.cs
blob: b1ef14bb43b5bffbc9ec351138d034f1ac6c3b4a (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
using HyperBooru.ApiModels;
using System.Management.Automation;

namespace HyperBooru.PowerShell;

[Alias("shbtd")]
[Cmdlet(VerbsCommon.Set, "HyperBooruTagDefinition")]
public class SetTagDefinitionCmdlet : SessionCmdlet {
    [Parameter(Mandatory = true)]
    public required Guid TagDefinitionId { get; set; }

    [Parameter] public string? Namespace { get; set; }
    [Parameter] public string? Name      { get; set; }
    [Parameter] public string? Alias     { get; set; }

    protected override void ProcessRecord() {
        var tagDefinition = Session.Tag.UpdateTagDefinitionAsync(
            TagDefinitionId,
            new TagUpdateRequest {
                Namespace = Namespace,
                Name      = Name,
                Alias     = Alias
            }).GetAwaiter().GetResult();

        WriteObject(tagDefinition);
    }
}