Repolode
Tyrrrz

Tyrrrz/CliWrap

A .NET library for launching command-line processes with fluent configuration, piping of stdin/stdout/stderr, and async cancellation.

Stars
5,010
Forks
285
Open issues
3
Last commit
3 days ago

What is it?

CliWrap is a .NET library that wraps System.Diagnostics.Process in a fluent, immutable API for running command-line tools. A command is built by calling Cli.Wrap with an executable path, then configuring arguments, working directory, environment variables and other options before calling ExecuteAsync or one of the higher-level execution methods.

Standard input, output and error streams can be connected to files, streams, byte arrays, strings, StringBuilder buffers, delegates or other commands, and commands can be chained with pipe operators. Helper methods collect buffered output, or expose the process as a pull-based or push-based event stream for reacting to output in real time.

The library supports cancellation with both forceful kill and graceful interrupt signals, and throws an exception on non-zero exit codes by default. It has no external dependencies and targets .NET Standard 2.0, .NET Core 3.0+ and .NET Framework 4.6.2+.

Key features

  • 01Fluent, immutable command configuration for arguments, working directory and environment variables.
  • 02Flexible piping of stdin, stdout and stderr to files, streams, strings, delegates or other commands.
  • 03Buffered execution and pull-based or push-based event streams for processing output.
  • 04Async API with forceful and graceful cancellation support.
  • 05Non-zero exit codes raise an exception by default, with validation that can be disabled.
  • 06No external dependencies.

Use cases

  • Calling external tools such as git, ffmpeg or docker from a .NET application.
  • Streaming a process's output in real time into logs or a UI.
  • Chaining command-line tools together with piped input and output.
  • Running long processes with timeouts and graceful shutdown.

Quick start

  1. 1

    Install the CliWrap NuGet package

    dotnet add package CliWrap
  2. 2

    Import the namespace and call Cli.Wrap(...) with the executable path, then ExecuteAsync() in your C# code

Things to know

  • The README requires agreement to political terms of use about Russia and Ukraine before using the project or its source code.
  • Resource policy options have varying support across platforms.
  • Credential options other than the user name are only available on Windows.

In collections

Topics

#dotnet#csharp#cli#process#piping#async#cancellation#command-line#dotnet-core#dotnet-standard

FAQ

What is CliWrap?
A .NET library for launching command-line processes with fluent configuration, piping of stdin/stdout/stderr, and async cancellation. CliWrap is a .NET library that wraps System.Diagnostics.Process in a fluent, immutable API for running command-line tools. A command is built by calling Cli.Wrap with an executable path, then configuring arguments, working directory, environment variables and other options before calling ExecuteAsync or one of the higher-level execution methods.
Is CliWrap free to use? What license does it have?
CliWrap is open source under the MIT license. Check the license terms before using it in commercial products.
Is CliWrap still maintained?
Actively maintained. The last commit to CliWrap was on Nov 4, 2026.
What can I use CliWrap for?
Calling external tools such as git, ffmpeg or docker from a .NET application. Streaming a process's output in real time into logs or a UI. Chaining command-line tools together with piped input and output. Running long processes with timeouts and graceful shutdown.
How do I install CliWrap?
Install the CliWrap NuGet package: dotnet add package CliWrap Import the namespace and call Cli.Wrap(...) with the executable path, then ExecuteAsync() in your C# code
Where can I get CliWrap?
The source code and installation instructions are on GitHub: https://github.com/Tyrrrz/CliWrap

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects