using System; using System.Management.Automation; using System.Threading; using System.Threading.Tasks; using LANCommander.Steam.Abstractions; using LANCommander.Steam.Enums; namespace LANCommander.SDK.PowerShell.Cmdlets; [Cmdlet(VerbsCommon.Get, "SteamCmdConnectionStatus")] [OutputType(typeof(SteamCmdConnectionStatus))] public class GetSteamCmdConnectionStatusCmdlet : AsyncCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "The Steam account username to check the connection status for.")] public string Username { get; set; } = string.Empty; protected override async Task ProcessRecordAsync(CancellationToken cancellationToken) { var steamCmdService = SteamServicesProvider.GetSteamCmdService(SessionState); try { var status = await steamCmdService.GetConnectionStatusAsync(Username); WriteObject(status); } catch (Exception ex) { WriteError(new ErrorRecord(ex, "GetConnectionStatusError", ErrorCategory.OperationStopped, null)); } } }