https://github.com/lemutec/flucli
Library for interacting with external command-line interfaces.
https://github.com/lemutec/flucli
fluent-cli fluent-process
Last synced: 4 months ago
JSON representation
Library for interacting with external command-line interfaces.
- Host: GitHub
- URL: https://github.com/lemutec/flucli
- Owner: lemutec
- License: mit
- Created: 2024-09-06T18:50:38.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-11-10T18:51:28.000Z (over 1 year ago)
- Last Synced: 2025-10-26T03:58:38.394Z (8 months ago)
- Topics: fluent-cli, fluent-process
- Language: C#
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://nuget.org/packages/Flucli) [](https://github.com/lemutec/Flucli/blob/master/LICENSE) [](https://github.com/lemutec/Flucli/actions/workflows/library.nuget.yml)
# Flucli
Library for interacting with external command-line interfaces.
Ported from [CliWrap](https://github.com/Tyrrrz/CliWrap) and support `.netstandard 2.0` without other dependencies.
Support `Verb="runas"` and simplify some APIs.
## Usage
### Command
```c#
CliResult result = await "cmd"
.WithArguments("/c echo Hello World!")
.ExecuteAsync();
Console.WriteLine("ExitCode is " + result.ExitCode);
```
### Piper
```c#
StringBuilder stdout = new();
StringBuilder stderr = new();
var command1 = "cmd"
.WithArguments("/c echo Hello World!");
var command2 = "cmd"
.WithArguments("/c findstr o")
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdout, Encoding.UTF8))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stderr, Encoding.UTF8));
CliResult result = await (command1 | command2).ExecuteAsync();
Console.WriteLine("STDOUT: " + stdout.ToString());
Console.WriteLine("STDERR: " + stderr.ToString());
Console.WriteLine("ExitCode is " + result.ExitCode);
```
### Parser
```c#
StringBuilder stdout = new();
StringBuilder stderr = new();
Cli command = "cmd /c echo Follow | cmd /c findstr F | cmd /c findstr l*"
.ParseCli()
.PipeTail // Switch to tail command
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdout, Encoding.UTF8))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stderr, Encoding.UTF8))
.PipeHeader; // Switch to header command
CliResult result = await command.ExecutePipeAsync();
Console.WriteLine("STDOUT: " + stdout.ToString());
Console.WriteLine("STDERR: " + stderr.ToString());
Console.WriteLine("ExitCode is " + result.ExitCode);
```