2026-01-24 16:37:07 -06:00
using System ;
using System.Management.Automation ;
using System.Threading ;
using System.Threading.Tasks ;
using LANCommander.Steam.Abstractions ;
using LANCommander.Steam.Models ;
namespace LANCommander.SDK.PowerShell.Cmdlets ;
[Cmdlet(VerbsLifecycle.Install, "SteamContent")]
[OutputType(typeof(SteamCmdInstallJob))]
2026-01-28 01:59:27 -06:00
public class InstallSteamContentCmdlet : AsyncCmdlet
2026-01-24 16:37:07 -06:00
{
2026-05-08 02:02:33 -05:00
[Parameter(Mandatory = true, Position = 0, HelpMessage = "The Steam application ID to install.")]
2026-01-24 16:37:07 -06:00
public uint AppId { get ; set ; }
2026-05-08 02:02:33 -05:00
[Parameter(Mandatory = true, Position = 1, HelpMessage = "The directory path where the content should be installed.")]
2026-01-24 16:37:07 -06:00
public string InstallDirectory { get ; set ; } = string . Empty ;
2026-05-08 02:02:33 -05:00
[Parameter(Mandatory = false, HelpMessage = "The Steam account username to use for downloading. If omitted, the default or anonymous account is used.")]
2026-01-24 16:37:07 -06:00
public string? Username { get ; set ; }
2026-01-28 01:59:27 -06:00
protected override async Task ProcessRecordAsync ( CancellationToken cancellationToken )
2026-01-24 16:37:07 -06:00
{
2026-01-28 01:59:27 -06:00
var steamCmdService = SteamServicesProvider . GetSteamCmdService ( SessionState ) ;
2026-01-24 16:37:07 -06:00
try
{
2026-01-28 01:59:27 -06:00
await steamCmdService . InstallContentAsync ( AppId , InstallDirectory , Username ) ;
2026-01-24 16:37:07 -06:00
}
catch ( Exception ex )
{
WriteError ( new ErrorRecord ( ex , "InstallContentError" , ErrorCategory . OperationStopped , null ) ) ;
}
}
}