Skip to content

devantler/dotnet-cli-runner

Repository files navigation

▶️ .NET CLI Runner

License Test codecov

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

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 CliRunner 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 CLIRunner.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.

About

A simple CLI runner, that can execute CLI commands.

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Languages