|
|
|
@ -2,6 +2,7 @@ |
|
|
|
using System.Diagnostics; |
|
|
|
using System.IO; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
|
|
|
|
namespace Volo.Abp.Cli.Utils; |
|
|
|
@ -10,6 +11,13 @@ public class CmdHelper : ICmdHelper, ITransientDependency |
|
|
|
{ |
|
|
|
private const int SuccessfulExitCode = 0; |
|
|
|
|
|
|
|
protected AbpCliOptions CliOptions { get; } |
|
|
|
|
|
|
|
public CmdHelper(IOptionsSnapshot<AbpCliOptions> cliOptions) |
|
|
|
{ |
|
|
|
CliOptions = cliOptions.Value; |
|
|
|
} |
|
|
|
|
|
|
|
public void OpenWebPage(string url) |
|
|
|
{ |
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
|
|
|
@ -27,10 +35,15 @@ public class CmdHelper : ICmdHelper, ITransientDependency |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Run(string file, string arguments) |
|
|
|
{ |
|
|
|
var procStartInfo = new ProcessStartInfo(file, arguments); |
|
|
|
|
|
|
|
if (CliOptions.AlwaysHideExternalCommandOutput) |
|
|
|
{ |
|
|
|
HideNewCommandWindow(procStartInfo); |
|
|
|
} |
|
|
|
|
|
|
|
Process.Start(procStartInfo)?.WaitForExit(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -46,6 +59,11 @@ public class CmdHelper : ICmdHelper, ITransientDependency |
|
|
|
GetArguments(command) |
|
|
|
); |
|
|
|
|
|
|
|
if (CliOptions.AlwaysHideExternalCommandOutput) |
|
|
|
{ |
|
|
|
HideNewCommandWindow(procStartInfo); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(workingDirectory)) |
|
|
|
{ |
|
|
|
procStartInfo.WorkingDirectory = workingDirectory; |
|
|
|
@ -66,10 +84,14 @@ public class CmdHelper : ICmdHelper, ITransientDependency |
|
|
|
GetArguments(command) |
|
|
|
); |
|
|
|
|
|
|
|
if (CliOptions.AlwaysHideExternalCommandOutput) |
|
|
|
{ |
|
|
|
HideNewCommandWindow(procStartInfo); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(workingDirectory)) |
|
|
|
{ |
|
|
|
procStartInfo.WorkingDirectory = workingDirectory; |
|
|
|
procStartInfo.CreateNoWindow = false; |
|
|
|
} |
|
|
|
|
|
|
|
return Process.Start(procStartInfo); |
|
|
|
@ -98,6 +120,7 @@ public class CmdHelper : ICmdHelper, ITransientDependency |
|
|
|
Arguments = GetArguments(command), |
|
|
|
UseShellExecute = false, |
|
|
|
CreateNoWindow = true, |
|
|
|
WindowStyle = ProcessWindowStyle.Hidden, |
|
|
|
RedirectStandardOutput = true, |
|
|
|
RedirectStandardError = true |
|
|
|
}; |
|
|
|
@ -137,6 +160,11 @@ public class CmdHelper : ICmdHelper, ITransientDependency |
|
|
|
{ |
|
|
|
procStartInfo.WorkingDirectory = workingDirectory; |
|
|
|
} |
|
|
|
|
|
|
|
if (CliOptions.AlwaysHideExternalCommandOutput) |
|
|
|
{ |
|
|
|
HideNewCommandWindow(procStartInfo); |
|
|
|
} |
|
|
|
|
|
|
|
Process.Start(procStartInfo); |
|
|
|
Environment.Exit(0); |
|
|
|
@ -178,4 +206,10 @@ public class CmdHelper : ICmdHelper, ITransientDependency |
|
|
|
$"Framework: {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} | " + |
|
|
|
$"Process Architecture{System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}"); |
|
|
|
} |
|
|
|
|
|
|
|
private void HideNewCommandWindow(ProcessStartInfo procStartInfo) |
|
|
|
{ |
|
|
|
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden; |
|
|
|
procStartInfo.CreateNoWindow = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|