diff --git a/LANCommander.Launcher/Models/CommandLineOptions.cs b/LANCommander.Launcher/Models/CommandLineOptions.cs index 1ab318b0..a9072649 100644 --- a/LANCommander.Launcher/Models/CommandLineOptions.cs +++ b/LANCommander.Launcher/Models/CommandLineOptions.cs @@ -27,6 +27,13 @@ namespace LANCommander.Launcher.Models public string NewKey { get; set; } } + [Verb("Install", HelpText = "Install a game from the server")] + public class InstallCommandLineOptions + { + [Option("GameId", HelpText = "The GUID of the game to install")] + public Guid GameId { get; set; } + } + [Verb("Import", HelpText = "Import library items from the server")] public class ImportCommandLineOptions { } diff --git a/LANCommander.Launcher/Program.cs b/LANCommander.Launcher/Program.cs index 83b42d76..3dbff5c0 100644 --- a/LANCommander.Launcher/Program.cs +++ b/LANCommander.Launcher/Program.cs @@ -270,7 +270,14 @@ namespace LANCommander.Launcher await client.ValidateTokenAsync(); - var result = CommandLine.Parser.Default.ParseArguments(args); + var result = CommandLine.Parser.Default.ParseArguments + < + RunScriptCommandLineOptions, + InstallCommandLineOptions, + ImportCommandLineOptions, + LoginCommandLineOptions, + LogoutCommandLineOptions + >(args); await result.WithParsedAsync(async (options) => { @@ -304,6 +311,24 @@ namespace LANCommander.Launcher } }); + await result.WithParsedAsync(async (options) => + { + var client = scope.ServiceProvider.GetService(); + + Console.WriteLine($"Downloading and installing game with ID {options.GameId}..."); + + try + { + var installDirectory = await client.Games.InstallAsync(options.GameId); + + Console.WriteLine($"Game successfully installed to {installDirectory}"); + } + catch (Exception ex) + { + Console.WriteLine($"Game could not be installed: {ex.Message}"); + } + }); + await result.WithParsedAsync(async (options) => { var importService = scope.ServiceProvider.GetService();