Skip to content

Baune8D/CliCommander

 
 

Repository files navigation

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)

About

CliWrap fork with raw CLI output

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 93.9%
  • PowerShell 3.3%
  • Shell 2.6%
  • Batchfile 0.2%