CmdOneLiner.NET easily executes command-line applications from .NET in a single line of code.
CmdResult cmdOut = CmdOneLiner.Run("Sleeper 5", timeout: TimeSpan.FromSeconds(20));
Console.WriteLine($"Sleeper program executed in {cmdOut?.RunningFor.TotalSeconds} seconds ({cmdOut?.TotalProcessorTime?.TotalSeconds}), used {cmdOut?.MaxRamUsedBytes / 1024 / 1024} MiB of RAM, and printed to the standard output: \"{cmdOut?.StdOut}\".");
CmdOneLiner.RunInBackground("Sleeper 5", (cmdOut) => { Console.WriteLine($"Sleeper program executed in the background in {cmdOut.RunningFor.TotalSeconds} seconds."); });
CmdResult cmdOut = await CmdOneLiner.RunAsync("Sleeper 5");
Console.WriteLine($"Sleeper program executed asynchronously in {cmdOut.RunningFor.TotalSeconds} seconds");
- Extremely easy to use.
- Multiplatform (platform agnostic).
- Measures maximum RAM usage and CPU time.
- Optional command execution timeout.
- Optional token allows cancellation from another thread.
- Can be run synchronously, asynchronously, or with a callback.