Add CLI verb for running a game
This commit is contained in:
parent
1da88da3d4
commit
66da004e5f
2 changed files with 27 additions and 0 deletions
|
|
@ -50,6 +50,16 @@ namespace LANCommander.Launcher.Models
|
|||
public Guid GameId { get; set; }
|
||||
}
|
||||
|
||||
[Verb("Run", HelpText = "Start a game")]
|
||||
public class RunCommandLineOptions
|
||||
{
|
||||
[Option("GameId", HelpText = "The GUID of the game to run")]
|
||||
public Guid GameId { get; set; }
|
||||
|
||||
[Option("ActionId", HelpText = "The GUID of the action to run")]
|
||||
public Guid ActionId { get; set; }
|
||||
}
|
||||
|
||||
[Verb("Sync", HelpText = "Sync library items from the server")]
|
||||
public class SyncCommandLineOptions { }
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ namespace LANCommander.Launcher.Services
|
|||
await result.WithParsedAsync<RunScriptCommandLineOptions>(RunScript);
|
||||
await result.WithParsedAsync<InstallCommandLineOptions>(Install);
|
||||
await result.WithParsedAsync<UninstallCommandLineOptions>(Uninstall);
|
||||
await result.WithParsedAsync<RunCommandLineOptions>(Run);
|
||||
await result.WithParsedAsync<SyncCommandLineOptions>(Sync);
|
||||
await result.WithParsedAsync<ImportCommandLineOptions>(Import);
|
||||
await result.WithParsedAsync<LoginCommandLineOptions>(Login);
|
||||
|
|
@ -121,6 +122,22 @@ namespace LANCommander.Launcher.Services
|
|||
}
|
||||
}
|
||||
|
||||
private async Task Run(RunCommandLineOptions options)
|
||||
{
|
||||
Console.WriteLine($"Running game with ID {options.GameId}...");
|
||||
|
||||
try
|
||||
{
|
||||
var game = await GameService.Get(options.GameId);
|
||||
|
||||
await GameService.Run(game, options.ActionId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Game could not run: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Sync(SyncCommandLineOptions options)
|
||||
{
|
||||
Console.WriteLine("Syncing games from server...");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue