diff options
Diffstat (limited to 'GetUser.cs')
| -rw-r--r-- | GetUser.cs | 26 |
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); + } +} |
