Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.79 KB

README.md

File metadata and controls

57 lines (40 loc) · 1.79 KB

▶️ .NET CLI Runner

License Test codecov

Show/hide folder structure
.
├── .github
│   └── workflows
├── Devantler.CLIRunner
└── Devantler.CLIRunner.Tests
    └── CLITests

5 directories

A simple CLI runner, that can execute CLI commands.

🚀 Getting Started

To get started, you can install the package from NuGet.

dotnet add package Devantler.CliRunner

📝 Usage

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.