Skip to content

Commit

Permalink
allow control of window style
Browse files Browse the repository at this point in the history
  • Loading branch information
adamralph committed Dec 11, 2021
1 parent 18098ce commit bae997c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ string? windowsArgs = null,
string? echoPrefix = null,
Action<IDictionary<string, string>>? configureEnvironment = null,
bool createNoWindow = false,
ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal,
Func<int, bool>? handleExitCode = null,
CancellationToken cancellationToken = default,
```
Expand Down
11 changes: 9 additions & 2 deletions SimpleExec/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static class Command
/// <param name="echoPrefix">The prefix to use when echoing the command line and working directory (if specified) to standard error (stderr).</param>
/// <param name="configureEnvironment">An action which configures environment variables for the command.</param>
/// <param name="createNoWindow">Whether to run the command in a new window.</param>
/// <param name="windowStyle">The window style to use when the command is run.</param>
/// <param name="handleExitCode">
/// A delegate which accepts an <see cref="int"/> representing exit code of the command and
/// returns <see langword="true"/> when it has handled the exit code and default exit code handling should be suppressed, and
Expand All @@ -51,6 +52,7 @@ public static void Run(
string? echoPrefix = null,
Action<IDictionary<string, string>>? configureEnvironment = null,
bool createNoWindow = false,
ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal,
Func<int, bool>? handleExitCode = null,
CancellationToken cancellationToken = default)
{
Expand All @@ -64,7 +66,8 @@ public static void Run(
workingDirectory,
false,
configureEnvironment ?? defaultAction,
createNoWindow);
createNoWindow,
windowStyle);

process.Run(noEcho, echoPrefix ?? defaultEchoPrefix, cancellationToken);

Expand All @@ -87,6 +90,7 @@ public static void Run(
/// <param name="echoPrefix">The prefix to use when echoing the command line and working directory (if specified) to standard error (stderr).</param>
/// <param name="configureEnvironment">An action which configures environment variables for the command.</param>
/// <param name="createNoWindow">Whether to run the command in a new window.</param>
/// <param name="windowStyle">The window style to use when the command is run.</param>
/// <param name="handleExitCode">
/// A delegate which accepts an <see cref="int"/> representing exit code of the command and
/// returns <see langword="true"/> when it has handled the exit code and default exit code handling should be suppressed, and
Expand All @@ -109,6 +113,7 @@ public static async Task RunAsync(
string? echoPrefix = null,
Action<IDictionary<string, string>>? configureEnvironment = null,
bool createNoWindow = false,
ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal,
Func<int, bool>? handleExitCode = null,
CancellationToken cancellationToken = default)
{
Expand All @@ -122,7 +127,8 @@ public static async Task RunAsync(
workingDirectory,
false,
configureEnvironment ?? defaultAction,
createNoWindow);
createNoWindow,
windowStyle);

await process.RunAsync(noEcho, echoPrefix ?? defaultEchoPrefix, cancellationToken).ConfigureAwait(false);

Expand Down Expand Up @@ -179,6 +185,7 @@ public static async Task<Result> ReadAsync(
true,
configureEnvironment ?? defaultAction,
true,
ProcessWindowStyle.Normal,
encoding);

var runProcess = process.RunAsync(true, defaultEchoPrefix, cancellationToken);
Expand Down
2 changes: 2 additions & 0 deletions SimpleExec/ProcessStartInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static System.Diagnostics.ProcessStartInfo Create(
bool redirectStandardStreams,
Action<IDictionary<string, string>> configureEnvironment,
bool createNoWindow,
System.Diagnostics.ProcessWindowStyle windowStyle,
Encoding? encoding = null)
{
var startInfo = new System.Diagnostics.ProcessStartInfo
Expand All @@ -27,6 +28,7 @@ public static System.Diagnostics.ProcessStartInfo Create(
CreateNoWindow = createNoWindow,
StandardErrorEncoding = encoding,
StandardOutputEncoding = encoding,
WindowStyle = windowStyle,
};

configureEnvironment(startInfo.Environment);
Expand Down
4 changes: 2 additions & 2 deletions SimpleExec/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ SimpleExec.Result.Result(string! standardOutput, string! standardError) -> void
SimpleExec.Result.StandardError.get -> string!
SimpleExec.Result.StandardOutput.get -> string!
static SimpleExec.Command.ReadAsync(string! name, string! args = "", string! workingDirectory = "", string? windowsName = null, string? windowsArgs = null, System.Action<System.Collections.Generic.IDictionary<string!, string!>!>? configureEnvironment = null, System.Text.Encoding? encoding = null, System.Func<int, bool>? handleExitCode = null, string? standardInput = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<SimpleExec.Result!>!
static SimpleExec.Command.Run(string! name, string! args = "", string! workingDirectory = "", bool noEcho = false, string? windowsName = null, string? windowsArgs = null, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string!, string!>!>? configureEnvironment = null, bool createNoWindow = false, System.Func<int, bool>? handleExitCode = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void
static SimpleExec.Command.RunAsync(string! name, string! args = "", string! workingDirectory = "", bool noEcho = false, string? windowsName = null, string? windowsArgs = null, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string!, string!>!>? configureEnvironment = null, bool createNoWindow = false, System.Func<int, bool>? handleExitCode = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
static SimpleExec.Command.Run(string! name, string! args = "", string! workingDirectory = "", bool noEcho = false, string? windowsName = null, string? windowsArgs = null, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string!, string!>!>? configureEnvironment = null, bool createNoWindow = false, System.Diagnostics.ProcessWindowStyle windowStyle = System.Diagnostics.ProcessWindowStyle.Normal, System.Func<int, bool>? handleExitCode = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void
static SimpleExec.Command.RunAsync(string! name, string! args = "", string! workingDirectory = "", bool noEcho = false, string? windowsName = null, string? windowsArgs = null, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string!, string!>!>? configureEnvironment = null, bool createNoWindow = false, System.Diagnostics.ProcessWindowStyle windowStyle = System.Diagnostics.ProcessWindowStyle.Normal, System.Func<int, bool>? handleExitCode = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!

0 comments on commit bae997c

Please sign in to comment.