summaryrefslogtreecommitdiff
path: root/GetUser.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2026-05-08 01:28:31 +1000
committerJake Mannens <jake@asger.xyz>2026-05-08 01:28:31 +1000
commit8ef09f9fed656bacc3a25e790796e9f144a5fac8 (patch)
treedb940e9fe93eaf7cb226037d8d7ab1b1f6704c78 /GetUser.cs
parent7984d2ecd4bdba7061429f98fdfae88f44f4a358 (diff)
v0.14av0.14a
Diffstat (limited to 'GetUser.cs')
-rw-r--r--GetUser.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/GetUser.cs b/GetUser.cs
new file mode 100644
index 0000000..63c5af7
--- /dev/null
+++ b/GetUser.cs
@@ -0,0 +1,26 @@
+using HyperBooru.ApiClient;
+using System.Management.Automation;
+
+namespace HyperBooru.PowerShell;
+
+[Alias("ghbu")]
+[Cmdlet(VerbsCommon.Get, "HyperBooruUser")]
+public class GetUserCmdlet : PSCmdlet {
+ [Parameter(Position = 0, Mandatory = true)]
+ public HBSession Session { get; set; }
+
+ [Parameter(Position = 1)]
+ public Guid? UserId { get; set; }
+
+ protected override void ProcessRecord() {
+ ApiModels.User[] users;
+
+ if(UserId is not null)
+ users = [ Session.User.GetUserAsync((Guid) UserId).GetAwaiter().GetResult() ];
+ else
+ users = Session.User.GetAllUsersAsync().GetAwaiter().GetResult();
+
+ foreach(var u in users)
+ WriteObject(u);
+ }
+}