Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 2 KB

Readme.md

File metadata and controls

56 lines (43 loc) · 2 KB

CliCommander

Build status codecov NuGet Badge

A shared API between CliWrap and RawCli that enables the creation of commands that can be executed by either library.

Usage:

var command = Commander.Wrap("docker")
    .WithArguments(a => a
        .Add("build")
        .Add("--progress")
        .Add("auto"));

// Docker will build with progress=plain since TTY is not supported when output is redirected.
BufferedCommandResult bufferedResult = command.ToCliWrap()
    .ExecuteBuffered();

// Docker will build with progress=tty since the output is not redirected.
CommandResult result = command.ToRawCli()
    .Execute();

Helper methods:

CliCommander contains the .When helper method for conditional modification of commands:

public void Execute(bool shouldThrowOnExitCode)
{
    await Commander.Wrap("docker")
        .When(!shouldThrowOnExitCode, c => c.WithValidation(CommandResultValidation.None))
        ...
}

RawCli

NuGet Badge

A fork of CliWrap that enables outputting native process output at the cost of output redirection.

The point of Rawcli is to support the following use case: Tyrrrz#199 without having to use the raw Process object.

Usage:

CommandResult result = Raw.CliWrap("docker")
    .WithArguments(a => a
        .Add("build")
        .Add("--progress")
        .Add("tty"))
    .Execute();

Standard input redirection is still enabled by default. It can be disabled with: .WithStandardInputRedirect(false)