Compare commits
No commits in common. "a6f1140b1f114184a82bf1742d3c3096f1a4424c" and "d5629a49a9b3623a9452edbfb2f1954e6a588b78" have entirely different histories.
a6f1140b1f
...
d5629a49a9
45 changed files with 49 additions and 70 deletions
|
|
@ -5,7 +5,7 @@ indent_style = tab
|
|||
indent_size = 4
|
||||
tab_width = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 120
|
||||
|
||||
|
|
|
|||
|
|
@ -13,5 +13,4 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="System.CommandLine" PrivateAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ internal sealed class Output : IDisposable
|
|||
Stderr.Dispose();
|
||||
Stdin.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,4 +23,4 @@ internal static class OutputTargetExtensions
|
|||
yield return output.Stderr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,4 +49,4 @@ public static class Program
|
|||
cts.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,4 +28,4 @@ internal sealed class EchoCommand : Command
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,4 +43,4 @@ internal sealed class EchoStdinCommand : Command
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,4 +31,4 @@ internal sealed class EnvironmentCommand : Command
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,4 +20,4 @@ internal sealed class ExitCommand : Command
|
|||
await output.Stderr.WriteLineAsync($"Exit code set to {code}");
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,4 +43,4 @@ internal sealed class GenerateBlobCommand : Command
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,4 +44,4 @@ internal sealed class GenerateClobCommand : Command
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -42,4 +42,4 @@ internal sealed class LengthCommand : Command
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,4 +34,4 @@ internal sealed class SleepCommand : Command
|
|||
await output.Stdout.FlushAsync(CancellationToken.None);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,4 +24,4 @@ internal sealed class WorkingDirectoryCommand : Command
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -178,4 +178,4 @@ internal sealed class CancellationTests
|
|||
await Assert.That(stdout.ToString()).Contains("Done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -270,4 +270,4 @@ internal sealed class CommandTests
|
|||
await Assert.That(cmd.StandardErrorPipe).IsNotEqualTo(pipeTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -136,4 +136,4 @@ internal sealed class ExecuteTests
|
|||
await Assert.That(lines).Contains("keep");
|
||||
await Assert.That(lines).Contains("overwritten");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,4 +78,4 @@ internal sealed class LineBreakTests
|
|||
// Assert
|
||||
await Assert.That(stdOutLines).IsEquivalentTo(["Foo", "", "Bar", "", "Baz"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,4 +47,4 @@ internal sealed class PathResolutionTests
|
|||
await Assert.That(result.StandardOutput.Trim()).IsEqualTo("hi");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -533,4 +533,4 @@ internal sealed class PipingTests
|
|||
await Assert.That(stream3.ToArray()).IsEquivalentTo(stream4.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -55,4 +55,4 @@ internal sealed class ValidationTests
|
|||
await Assert.That(result.IsSuccess).IsFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,4 +32,4 @@ internal sealed class PlatformAttribute : SkipAttribute
|
|||
{
|
||||
return Task.FromResult(!_os.Any(OperatingSystem.IsOSPlatform));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,4 +18,4 @@ internal static class ProcessTree
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,4 +29,4 @@ internal sealed class TestEnvironment : IDisposable
|
|||
{
|
||||
_action();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,4 +31,4 @@ internal sealed class TestTempDirectory : IDisposable
|
|||
}
|
||||
catch (DirectoryNotFoundException) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -150,4 +150,4 @@ public partial class ArgumentsBuilder
|
|||
|
||||
return buffer.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -88,4 +88,4 @@ public static class BufferedCommandExtensions
|
|||
return command.ExecuteBufferedAsync(Console.OutputEncoding, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,4 +48,4 @@ public partial class BufferedCommandResult
|
|||
{
|
||||
return result.StandardOutput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -126,4 +126,4 @@ public sealed partial class Command
|
|||
return new Command(TargetFilePath, Arguments, WorkingDirPath, Environment, Validation,
|
||||
StandardInputPipe, StandardOutputPipe, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -228,4 +228,4 @@ public sealed partial class Command
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -196,4 +196,4 @@ public sealed partial class Command
|
|||
{
|
||||
return PipeSource.FromCommand(source) | target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,4 +81,4 @@ public sealed partial class Command
|
|||
{
|
||||
return $"{TargetFilePath} {Arguments}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,4 +27,4 @@ public class CommandExecutionException : Exception
|
|||
/// Exit code returned by the process.
|
||||
/// </summary>
|
||||
public int ExitCode { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -61,4 +61,4 @@ public partial class CommandResult
|
|||
{
|
||||
return result.IsSuccess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,4 +91,4 @@ public sealed partial class CommandTask<TResult>
|
|||
{
|
||||
return commandTask.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,4 +47,4 @@ public sealed class EnvironmentVariablesBuilder
|
|||
{
|
||||
return new Dictionary<string, string?>(_vars, _vars.Comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<InternalsVisibleTo Include="Geekeey.Process.Tests" />
|
||||
<InternalsVisibleTo Include="$(AssemblyName).Tests" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -131,4 +131,4 @@ internal sealed class MemoryBufferStream : Stream
|
|||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -121,4 +121,4 @@ public abstract partial class PipeSource
|
|||
return Create(async (destination, cancellationToken) =>
|
||||
await command.WithStandardOutputPipe(PipeTarget.ToStream(destination)).ExecuteAsync(cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -311,4 +311,4 @@ public partial class PipeTarget
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,4 +43,4 @@ internal sealed partial class Process
|
|||
SIGALRM = 14,
|
||||
SIGTERM = 15,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,4 +30,4 @@ internal sealed partial class Process
|
|||
CTRL_LOGOFF_EVENT = 5, // SIGHUP
|
||||
CTRL_SHUTDOWN_EVENT = 6, // SIGTERM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -178,4 +178,4 @@ internal sealed partial class Process : IDisposable
|
|||
{
|
||||
_process.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,4 +18,4 @@ public enum ValidationMode
|
|||
/// Ensure that the command returned a zero exit code.
|
||||
/// </summary>
|
||||
ZeroExitCode = 0b1,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +1,9 @@
|
|||
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.
|
||||
|
||||
## Features
|
||||
## Usage
|
||||
|
||||
- **Input and Output redirection:** flexible piping model, that allows to redirect the process's streams.
|
||||
- **Immutability:** The `Command` object is immutable, ensuring thread safely and allowing sharing of a base
|
||||
configuration.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Install the NuGet package:
|
||||
|
||||
```shell
|
||||
dotnet add package Geekeey.Request
|
||||
```
|
||||
|
||||
You may need to add our NuGet feed to your nuget.config this can be done by running the following command:
|
||||
|
||||
```shell
|
||||
dotnet nuget add source -n geekeey https://code.geekeey.de/api/packages/geekeey/nuget/index.json
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
#### Execute a command and capturing its output:
|
||||
### Execute a command and capturing its output:
|
||||
|
||||
```csharp
|
||||
public static async Task<int> Main()
|
||||
|
|
@ -36,7 +16,7 @@ public static async Task<int> Main()
|
|||
}
|
||||
```
|
||||
|
||||
#### Execute a command and redirect its output to another command:
|
||||
### Execute a command and redirect its output to another command:
|
||||
|
||||
```csharp
|
||||
public static Task<int> Main()
|
||||
|
|
@ -47,7 +27,7 @@ public static Task<int> Main()
|
|||
}
|
||||
```
|
||||
|
||||
#### Execute a command with cancellation support:
|
||||
### Execute a command with cancellation support:
|
||||
|
||||
```csharp
|
||||
public static async Task<int> Main()
|
||||
|
|
@ -68,4 +48,4 @@ public static async Task<int> Main()
|
|||
var result = await app;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue