diff options
Diffstat (limited to 'AddMediaTag.cs')
| -rw-r--r-- | AddMediaTag.cs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/AddMediaTag.cs b/AddMediaTag.cs index 35541e4..2ced119 100644 --- a/AddMediaTag.cs +++ b/AddMediaTag.cs @@ -1,22 +1,27 @@ -using HyperBooru.ApiClient; -using System.Management.Automation; +using System.Management.Automation; namespace HyperBooru.PowerShell; [Alias("ahbmt")] [Cmdlet(VerbsCommon.Add, "HyperBooruMediaTag")] -public class AddMediaTagCmdlet : PSCmdlet { - [Parameter(Position = 0, Mandatory = true)] - public required HBSession Session { get; set; } - +public class AddMediaTagCmdlet : SessionCmdlet { [Parameter(Position = 1, Mandatory = true)] public Guid MediaId { get; set; } [Parameter(Position = 2, Mandatory = true)] public Guid[] TagId { get; set; } - protected override void ProcessRecord() => + protected override void ProcessRecord() { Session.Media.AddTagsAsync(MediaId, TagId) .GetAwaiter() .GetResult(); + + var id = MediaId.ToString().ToUpper(); + var tags = TagId + .Order() + .Distinct() + .Select(t => t.ToString().ToUpper()); + + WriteVerbose($"Added tags {string.Join(", ", tags)} to media item {id}"); + } } |
