Larcanum.ShellToolkit
1.0.2
dotnet add package Larcanum.ShellToolkit --version 1.0.2
NuGet\Install-Package Larcanum.ShellToolkit -Version 1.0.2
<PackageReference Include="Larcanum.ShellToolkit" Version="1.0.2" />
paket add Larcanum.ShellToolkit --version 1.0.2
#r "nuget: Larcanum.ShellToolkit, 1.0.2"
// Install Larcanum.ShellToolkit as a Cake Addin #addin nuget:?package=Larcanum.ShellToolkit&version=1.0.2 // Install Larcanum.ShellToolkit as a Cake Tool #tool nuget:?package=Larcanum.ShellToolkit&version=1.0.2
Overview
The goal of this library is to provide a set of tools to start and interact with processes on the host system in a way that is similarly easy to use as Bash or oder shells. First and foremost this means providing a convenient API on top of the rather crusty and awkward System.Diagnostics.Process
and System.Diagnostics.ProcessStartInfo
. On top of that, the library provides methods for building pipelines of commands similar to how pipes work in Bash.
One common use case and the reason for creating this library is the creation of custom .NET command line tools that rely on other programs like git
, 7z
, dotnet
, jq
, sed
, awk
, etc. to avoid reinventing the wheel.
Examples
The examples here are assuming that the following command line tools are available in your system PATH
Capturing and Processing simple Command Output
var runner = CommandRunner.Create();
var version = Version.Parse((await runner.CaptureAsync(Command.Create("dotnet", ["--version"]))).Output!);
// version.Major = 8
// version.Minor = 0
// version.Build = 200
Running Command Output through Filters and into a File
var runner = CommandRunner.Create();
var tempFile = new FileInfo(Path.GetTempFileName());
var pipeline = Command.Create("dotnet", ["list", @"C:\path\to\ShellToolkit.csproj", "package", "--format", "json"])
.Pipe(Command.Create("jq", [".projects.[].frameworks.[].topLevelPackages.[].id"]))
.Pipe(tempFile);
if (await runner.ExecAsync(pipeline) != 0)
{
throw new Exception("Pipeline failed");
}
var result = await File.ReadAllTextAsync(tempFile.FullName);
// result = "Microsoft.Extensions.Logging.Abstractions"
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.