Add CLI verb to install game
This commit is contained in:
parent
3925ec4c34
commit
beecf0beee
2 changed files with 33 additions and 1 deletions
|
|
@ -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 { }
|
||||
|
||||
|
|
|
|||
|
|
@ -270,7 +270,14 @@ namespace LANCommander.Launcher
|
|||
|
||||
await client.ValidateTokenAsync();
|
||||
|
||||
var result = CommandLine.Parser.Default.ParseArguments<RunScriptCommandLineOptions, ImportCommandLineOptions>(args);
|
||||
var result = CommandLine.Parser.Default.ParseArguments
|
||||
<
|
||||
RunScriptCommandLineOptions,
|
||||
InstallCommandLineOptions,
|
||||
ImportCommandLineOptions,
|
||||
LoginCommandLineOptions,
|
||||
LogoutCommandLineOptions
|
||||
>(args);
|
||||
|
||||
await result.WithParsedAsync<RunScriptCommandLineOptions>(async (options) =>
|
||||
{
|
||||
|
|
@ -304,6 +311,24 @@ namespace LANCommander.Launcher
|
|||
}
|
||||
});
|
||||
|
||||
await result.WithParsedAsync<InstallCommandLineOptions>(async (options) =>
|
||||
{
|
||||
var client = scope.ServiceProvider.GetService<SDK.Client>();
|
||||
|
||||
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<ImportCommandLineOptions>(async (options) =>
|
||||
{
|
||||
var importService = scope.ServiceProvider.GetService<ImportService>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue