Library for interacting with external command-line interfaces.
Ported from CliWrap and support .netstandard 2.0
without other dependencies.
Support Verb="runas"
and simplify some APIs.
CliResult result = await "cmd"
.WithArguments("/c echo Hello World!")
.ExecuteAsync();
Console.WriteLine("ExitCode is " + result.ExitCode);
StringBuilder stdout = new();
StringBuilder stderr = new();
var command1 = "cmd"
.WithArguments("/c echo Hello World!");
var command2 = "cmd"
.WithArguments("/c findstr o")
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdout, Encoding.UTF8))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stderr, Encoding.UTF8));
CliResult result = await (command1 | command2).ExecuteAsync();
Console.WriteLine("STDOUT: " + stdout.ToString());
Console.WriteLine("STDERR: " + stderr.ToString());
Console.WriteLine("ExitCode is " + result.ExitCode);
StringBuilder stdout = new();
StringBuilder stderr = new();
Cli command = "cmd /c echo Follow | cmd /c findstr F | cmd /c findstr l*"
.ParseCli()
.PipeTail // Switch to tail command
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdout, Encoding.UTF8))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stderr, Encoding.UTF8))
.PipeHeader; // Switch to header command
CliResult result = await command.ExecutePipeAsync();
Console.WriteLine("STDOUT: " + stdout.ToString());
Console.WriteLine("STDERR: " + stderr.ToString());
Console.WriteLine("ExitCode is " + result.ExitCode);