Skip to content

Repository files navigation

MedallionShell

MedallionShell is a lightweight library that vastly simplifies working with processes in .NET apps.

Download the NuGet package

Built on top of the powerful, yet clunkySystem.Diagnostics.Process API, the MedallionShell API streamlines common use-cases, removes pitfalls, and integrates Process handling with .NET async/await and Tasks.

// processes are created and interacted with using the Command classvarcmd=Command.Run("path_to_grep","some REGEX");cmd.StandardInput.PipeFromAsync(newFileInfo("some path"));// by default, all output streams are buffered, so there's no need to worry// about deadlockvaroutputLines=cmd.StandardOutput.GetLines().ToList();varerrorText=cmd.StandardError.ReadToEnd();// by default, the underlying Process is automatically disposed // so no using block is required// and complex arguments are automatically escapedvarcmd=Command.Run("path_to_grep","\\ some \"crazy\" REGEX \\");// we can also do this inline using bash-style operator overloadsvarlines=newList<string>();varcmd=Command.Run("path_to_grep","some REGEX")<newFileInfo("some path")>lines;cmd.Wait();// and we can even chain commands together with the pipe operatorvarpipeline=Command.Run("path_to_grep","some REGEX")|Command.Run("path_to_grep","another REGEX");// we can check a command's exit status using it's resultif(cmd.Result.Success){ ...}// and perform async operations via its associated taskawaitcmd.Task;// commands are also highly configurablevarcmd=Command.Run("path_to_grep",new[]{"some REGEX"},options: o =>o// arbitrarily configure the ProcessStartInfo.StartInfo(si =>si.RedirectStandardError=false)// option to turn a non-zero exit code into an exception.ThrowOnError()// option to kill the command and throw TimeoutException if it doesn't finish.Timeout(TimeSpan.FromMinutes(1))
...);// and if we want to keep using a common set of configuration options, we // can package them up in a Shell objectvarshell=newShell(o =>o.ThrowOnError()...);shell.Run("path_to_grep","some REGEX");

About

A .NET library simplifying the execution and chaining of processes

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages