From fb10b50918d67c7c12ff1b48801eb345a79f4ae0 Mon Sep 17 00:00:00 2001 From: Daniele Corsini Date: Fri, 7 Aug 2020 16:45:09 +0200 Subject: [PATCH] Fix #4, #5, #6 --- .../Corsinvest.ProxmoxVE.Pepper.csproj | 2 +- src/Corsinvest.ProxmoxVE.Pepper/Program.cs | 30 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Corsinvest.ProxmoxVE.Pepper/Corsinvest.ProxmoxVE.Pepper.csproj b/src/Corsinvest.ProxmoxVE.Pepper/Corsinvest.ProxmoxVE.Pepper.csproj index cced0a5..ede0bf4 100644 --- a/src/Corsinvest.ProxmoxVE.Pepper/Corsinvest.ProxmoxVE.Pepper.csproj +++ b/src/Corsinvest.ProxmoxVE.Pepper/Corsinvest.ProxmoxVE.Pepper.csproj @@ -1,7 +1,7 @@ Exe - 1.3.1 + 1.3.2 netcoreapp3.1 cv4pve-pepper Corsinvest Srl diff --git a/src/Corsinvest.ProxmoxVE.Pepper/Program.cs b/src/Corsinvest.ProxmoxVE.Pepper/Program.cs index 35aad00..784769d 100644 --- a/src/Corsinvest.ProxmoxVE.Pepper/Program.cs +++ b/src/Corsinvest.ProxmoxVE.Pepper/Program.cs @@ -12,6 +12,7 @@ using System.Diagnostics; using System.IO; +using System.Runtime.InteropServices; using Corsinvest.ProxmoxVE.Api.Extension.Helpers; using Corsinvest.ProxmoxVE.Api.Shell.Helpers; using McMaster.Extensions.CommandLineUtils; @@ -25,11 +26,11 @@ namespace Corsinvest.ProxmoxVE.Pepper var app = ShellHelper.CreateConsoleApp("cv4pve-pepper", "Launching SPICE on Proxmox VE"); var optVmId = app.VmIdOrNameOption().DependOn(app, CommandOptionExtension.HOST_OPTION_NAME); + var optRemoteViewer = app.Option("--viewer", "Executable SPICE client remote viewer", CommandOptionType.SingleValue) .DependOn(app, CommandOptionExtension.HOST_OPTION_NAME); - optRemoteViewer.Accepts().ExistingFile(); app.OnExecute(() => @@ -39,16 +40,27 @@ namespace Corsinvest.ProxmoxVE.Pepper if (ret) { + var startInfo = new ProcessStartInfo + { + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardOutput = false, + }; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + startInfo.FileName = "/bin/bash"; + startInfo.Arguments = $"-c \"{optRemoteViewer.Value()} {fileName}\""; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + startInfo.FileName = StringHelper.Quote(optRemoteViewer.Value()); + startInfo.Arguments = StringHelper.Quote(fileName); + } + var process = new Process { - StartInfo = new ProcessStartInfo - { - UseShellExecute = false, - CreateNoWindow = true, - RedirectStandardOutput = false, - FileName = StringHelper.Quote(optRemoteViewer.Value()), - Arguments = StringHelper.Quote(fileName) - } + StartInfo = startInfo }; if (app.DebugIsActive())