stabilizaiton work - projects rework for maintenanceability and ui livening

This commit is contained in:
master
2026-02-03 23:40:04 +02:00
parent 074ce117ba
commit 557feefdc3
3305 changed files with 186813 additions and 107843 deletions

View File

@@ -0,0 +1,54 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace StellaOps.Interop;
internal sealed class ToolProcessRunner : IToolProcessRunner
{
public async Task<ToolResult> RunAsync(
string tool,
string toolPath,
string args,
string workingDirectory,
CancellationToken ct = default)
{
var startInfo = new ProcessStartInfo
{
FileName = toolPath,
Arguments = args,
WorkingDirectory = workingDirectory,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};
try
{
using var process = Process.Start(startInfo);
if (process is null)
{
return ToolResult.Failed($"Failed to start tool: {tool}");
}
var stdOutTask = process.StandardOutput.ReadToEndAsync(ct);
var stdErrTask = process.StandardError.ReadToEndAsync(ct);
await process.WaitForExitAsync(ct).ConfigureAwait(false);
var stdout = await stdOutTask.ConfigureAwait(false);
var stderr = await stdErrTask.ConfigureAwait(false);
return process.ExitCode == 0
? ToolResult.Ok(stdout, stderr, process.ExitCode)
: ToolResult.Failed(stderr, stdout, process.ExitCode);
}
catch (Exception ex) when (ex is InvalidOperationException or Win32Exception)
{
return ToolResult.Failed(ex.Message);
}
}
}