summaryrefslogtreecommitdiff
path: root/RemoveImplicitTag.cs
blob: a76c54faba2d507ebd3152be3a2307762b7eafa2 (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
using System.Management.Automation;

namespace HyperBooru.PowerShell;

[Alias("rhbit")]
[Cmdlet(VerbsCommon.Remove, "HyperBooruImplicitTag")]
public class RemoveImplicitTagCmdlet : SessionCmdlet {
    [Parameter(Mandatory = true)] public required Guid   TagDefinitionId { get; set; }
    [Parameter(Mandatory = true)] public required Guid[] ImplicitTagId   { get; set; }

    protected override void ProcessRecord() {
        Session.Tag.DeleteImplicitTagAsync(TagDefinitionId, ImplicitTagId)
            .GetAwaiter()
            .GetResult();

        var id   = TagDefinitionId.ToString().ToUpper();
        var impl = ImplicitTagId
            .Order()
            .Distinct()
            .Select(t => t.ToString().ToUpper());

        WriteVerbose(
            $"Removed implicit tags {string.Join(", ", impl)} from tag {id}");
    }
}