Show/hide folder structure
.
├── .github
│ └── workflows
├── Devantler.CLIRunner
└── Devantler.CLIRunner.Tests
└── CLITests
5 directories
A simple CLI runner, that can execute CLI commands.
To get started, you can install the package from NuGet.
dotnet add package Devantler.CliRunner
Note
The template engine uses CLIWrap under the hood. So to learn more about the API, you can visit the above link.
To run a command, you can use the CLI
class.
using Devantler.CLIRunner;
var command = new Command("echo")
.WithArguments("Hello, World!");
var cancellationToken = CancellationToken.None;
var validation = CommandResultValidation.ZeroExitCode;
bool silent = false;
var (exitCode, result) = await CLI.RunAsync(command, cancellationToken, validation, silent);
Console.WriteLine(exitCode); // Will output 0, as the command was successful
Console.WriteLine(result); // Will output "Hello, World!", as that is what is printed to stdout
You can run all kinds of commands with this library, and it will handle the output and exit code for you, such that you can easily check if the command was successful or not.