30 lines
1.2 KiB
C#
30 lines
1.2 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Launcher.Next.App;
|
|
|
|
/// <summary>Explicit automation of the same LocalParityLaunchService used by the main-window actions.</summary>
|
|
internal static class LocalParityLaunchCli
|
|
{
|
|
public static async Task<int> RunAsync(string[] args)
|
|
{
|
|
if (args.Length != 4 || args[0] != "--mode" || args[1] != "LocalParityLaunch" || args[2] != "--config") return 2;
|
|
try
|
|
{
|
|
var service = new LocalParityLaunchService();
|
|
var prepared = await service.PrepareAsync(LocalParityLaunchService.LoadProfile(args[3]), CancellationToken.None);
|
|
var launch = await service.LaunchAsync(prepared, CancellationToken.None);
|
|
return launch.TerminalState == "Succeeded" ? 0 : 1;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
// Explicit local mode: retain a bounded diagnostic next to its supplied profile.
|
|
// Normal production and automation routes never take this path.
|
|
try { await File.WriteAllTextAsync(Path.Combine(Path.GetDirectoryName(args[3])!, "local-parity-last-error.txt"), exception.ToString()); } catch { }
|
|
return 1;
|
|
}
|
|
}
|
|
}
|