From ed0fb341e62a94e3e467a016b955b3808d2b15c4 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Sat, 9 May 2026 02:59:46 +1000 Subject: v0.15a --- AddMediaTag.cs | 22 ++++++++++++++++++++++ GetMediaTag.cs | 22 ++++++++++++++++++++++ PowerShell.csproj | 2 +- RemoveMediaTag.cs | 22 ++++++++++++++++++++++ SetMediaTag.cs | 22 ++++++++++++++++++++++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 AddMediaTag.cs create mode 100644 GetMediaTag.cs create mode 100644 RemoveMediaTag.cs create mode 100644 SetMediaTag.cs diff --git a/AddMediaTag.cs b/AddMediaTag.cs new file mode 100644 index 0000000..35541e4 --- /dev/null +++ b/AddMediaTag.cs @@ -0,0 +1,22 @@ +using HyperBooru.ApiClient; +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; } + + [Parameter(Position = 1, Mandatory = true)] + public Guid MediaId { get; set; } + + [Parameter(Position = 2, Mandatory = true)] + public Guid[] TagId { get; set; } + + protected override void ProcessRecord() => + Session.Media.AddTagsAsync(MediaId, TagId) + .GetAwaiter() + .GetResult(); +} diff --git a/GetMediaTag.cs b/GetMediaTag.cs new file mode 100644 index 0000000..90d9835 --- /dev/null +++ b/GetMediaTag.cs @@ -0,0 +1,22 @@ +using HyperBooru.ApiClient; +using System.Management.Automation; + +namespace HyperBooru.PowerShell; + +[Alias("ghbmt")] +[Cmdlet(VerbsCommon.Get, "HyperBooruMediaTag")] +public class GetMediaTagCmdlet : PSCmdlet { + [Parameter(Position = 0, Mandatory = true)] + public required HBSession Session { get; set; } + + [Parameter(Position = 1, Mandatory = true)] + public Guid MediaId { get; set; } + + protected override void ProcessRecord() { + var tags = Session.Media.GetTagsAsync(MediaId) + .GetAwaiter() + .GetResult(); + foreach(var td in tags) + WriteObject(td); + } +} diff --git a/PowerShell.csproj b/PowerShell.csproj index ba0a927..785c97e 100644 --- a/PowerShell.csproj +++ b/PowerShell.csproj @@ -9,7 +9,7 @@ $(AssemblyVersion) HyperBooru.PowerShell Jake Mannens - 0.14-alpha + 0.15-alpha diff --git a/RemoveMediaTag.cs b/RemoveMediaTag.cs new file mode 100644 index 0000000..d41980d --- /dev/null +++ b/RemoveMediaTag.cs @@ -0,0 +1,22 @@ +using HyperBooru.ApiClient; +using System.Management.Automation; + +namespace HyperBooru.PowerShell; + +[Alias("rhbmt")] +[Cmdlet(VerbsCommon.Remove, "HyperBooruMediaTag")] +public class RemoveMediaTagCmdlet : PSCmdlet { + [Parameter(Position = 0, Mandatory = true)] + public required HBSession Session { get; set; } + + [Parameter(Position = 1, Mandatory = true)] + public Guid MediaId { get; set; } + + [Parameter(Position = 2, Mandatory = true)] + public Guid[] TagId { get; set; } + + protected override void ProcessRecord() => + Session.Media.DeleteTagsAsync(MediaId, TagId) + .GetAwaiter() + .GetResult(); +} diff --git a/SetMediaTag.cs b/SetMediaTag.cs new file mode 100644 index 0000000..8931991 --- /dev/null +++ b/SetMediaTag.cs @@ -0,0 +1,22 @@ +using HyperBooru.ApiClient; +using System.Management.Automation; + +namespace HyperBooru.PowerShell; + +[Alias("shbmt")] +[Cmdlet(VerbsCommon.Set, "HyperBooruMediaTag")] +public class SetMediaTagCmdlet : PSCmdlet { + [Parameter(Position = 0, Mandatory = true)] + public required HBSession Session { get; set; } + + [Parameter(Position = 1, Mandatory = true)] + public Guid MediaId { get; set; } + + [Parameter(Position = 2, Mandatory = true)] + public Guid[] TagId { get; set; } + + protected override void ProcessRecord() => + Session.Media.ReplaceTagsAsync(MediaId, TagId) + .GetAwaiter() + .GetResult(); +} -- cgit v1.3