summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AddMediaTag.cs22
-rw-r--r--GetMediaTag.cs22
-rw-r--r--PowerShell.csproj2
-rw-r--r--RemoveMediaTag.cs22
-rw-r--r--SetMediaTag.cs22
5 files changed, 89 insertions, 1 deletions
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 @@
<FileVersion>$(AssemblyVersion)</FileVersion>
<AssemblyTitle>HyperBooru.PowerShell</AssemblyTitle>
<Authors>Jake Mannens</Authors>
- <Version>0.14-alpha</Version>
+ <Version>0.15-alpha</Version>
</PropertyGroup>
<ItemGroup>
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();
+}