using System.Diagnostics; using CommandLineWrapper; public static class JVCSCommandInvoker { // Structure to hold the result of a command invocation public struct InvokeResult { public int ExitCode { get; set; } public string StandardOutput { get; set; } } // Invokes a command-line process with the given arguments and optional working directory public static async Task Invoke(string[] args, string? workingDirectory = null) { var startInfo = new ProcessStartInfo { FileName = Constants.CommandLinePath.FullName, Arguments = string.Join(" ", args), RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true }; if (!string.IsNullOrEmpty(workingDirectory)) startInfo.WorkingDirectory = workingDirectory; using (var process = new Process { StartInfo = startInfo }) { process.Start(); string output = await process.StandardOutput.ReadToEndAsync(); await process.WaitForExitAsync(); return new InvokeResult { ExitCode = process.ExitCode, StandardOutput = output.Trim() }; } } }