Geekeey.Process (1.0.0)

Published 2026-01-22 18:11:52 +00:00 by HeyGeekeey in geekeey/process

Installation

dotnet nuget add source --name geekeey --username your_username --password your_token 
dotnet add package --source geekeey --version 1.0.0 Geekeey.Process

About this package

Package Description

Process is a library for interacting with external command-line interfaces. It provides a convenient model for launching processes, redirecting input and output streams, awaiting completion, handling cancellation, and more.

Usage

Execute a command and capturing its output:

public static async Task<int> Main()
{
  var stdout = new StringBuilder();
  var cmd = new Command("git").WithArguments(["config", "--get", "user.name"]) | stdout;
  await cmd.ExecuteAsync();
  Console.WriteLine(stdout.ToString());
  return 0;
}

Execute a command and redirect its output to another command:

public static Task<int> Main()
{
  var cmd = new Command("cat").WithArguments(["file.txt"]) | new Command("wc");
  await cmd.ExecuteAsync();
  Console.WriteLine(stdout.ToString());
}

Execute a command with cancellation support:

public static async Task<int> Main()
{
  using var cts = new CancellationTokenSource();
  Console.CancelKeyPress += (s, e) =>
  {
    e.Cancel = true;
    cts.Cancel();
  };
  var cmd = new Command("long-running-command");
  // kills the process if Ctrl+C is pressed
  var app = cmd.ExecuteAsync(cts.Token);
  // manually interrupt after 5 seconds
  await Task.Delay(5000);
  app.Interrupt();
  // wait for process to exit
  var result = await app;
  return 0;
}
Details
NuGet
2026-01-22 18:11:52 +00:00
0
The Geekeey Team
92 KiB
Assets (4)
Versions (1) View all
1.0.0 2026-01-22