Releases: twitchax/Sheller
Sheller 6.0.1
Sheller 6.0.0
This release changes:
- Interfaces are now first-class return types. Concrete types of plugin
IShells andIExecutables are no longer returned.
This release adds:
UseStartInfoTransformtoIShellandIExecutable.
Developers can now easily write IShell and IExecutable plugins. For example, we could write a kubectl plugin like this.
public interface IKubectl : IExecutable
{
IKubectl WithKubeConfig(string configPath);
IKubectl WithApply(string yamlPath);
}
public class Kubectl : Executable<IKubectl>, IKubectl
{
// Allows the `Executable` base class to "create and clone" a new instance for chanining.
protected override Executable<IKubectl> Create() => new Kubectl();
// Sets the underlying executable of this executable type.
public Kubectl() : base("kubectl") {}
public IKubectl WithKubeConfig(string configPath) => this.WithArgument($"--kubeconfig={configPath}");
public IKubectl WithApply(string yamlPath) => this.WithArgument("apply", "-f", yamlPath);
}
...
var result = await Builder
.UseShell<Bash>()
.UseExecutable<Kubectl>()
.WithKubeConfig("kube_config.yaml")
.WithApply("my_app.yaml")
.ExecuteAsync();Developers can now transform the StartInfo before the command executes.
var echoValue = await Builder
.UseShell<Bash>()
.UseExecutable<Echo>()
.WithArgument(expected)
.UseStartInfoTransform(si =>
{
si.WorkingDirectory = "/";
})
.ExecuteAsync();Sheller 5.4.0
This release changes:
- N/A.
This release adds:
InvocationtoCommandEventType.
Sheller 5.3.0
This release changes:
- N/A.
This release adds:
UseExecutabletoIExecutable.UseCommandPrefixtoIShell.
UseExecutable allows the developer to override the executable string of an execution context.
UseCommandPrefix allows the developer to provide a "prefix" to every command run in the shell (e.g., to use socksify, or the like).
Sheller 5.2.0
This release changes:
- N/A.
This release adds:
UseStandardOutputEncodingtoIShellandIExecutable.UseStandardErrorEncodingtoIShellandIExecutable.
UseStandardOutputEncoding allows the developer to set the output encoding of the execution process.
var echoValue = await Builder
.UseShell<Bash>()
.UseExecutable<Echo>()
.WithArgument("😋")
.UseStandardOutputEncoding(Encoding.ASCII)
.ExecuteAsync();Sheller 5.1.1
This release changes:
- N/A.
This release adds:
WithCancellationTokentoIShellandIExecutable.ConfigureAwait(false)to allawaits.- A bunch more examples to the README.
WithCancellationToken allows the developer to provide cancellation tokens to the execution context.
using (var ctSource = new CancellationTokenSource())
{
ctSource.CancelAfter(TimeSpan.FromSeconds(5));
Builder
.UseShell<Bash>()
.UseExecutable<Sleep>()
.WithArgument("5")
.WithCancellationToken(ctSource.Token)
.ExecuteAsync();
}Sheller 5.0.0
This release changes:
- N/A.
This release adds:
WithSubscribetoIShell.WithSubscribetoIExecutable.
WithSubscribe allows the developer to subscribe to events using IObservables (nice for reactive extensions).
await Builder
.UseShell<Bash>()
.UseExecutable("echo")
.WithArgument(expected)
.WithSubscribe(o =>
{
o.Where(ev => ev.Type == CommandEventType.StandardOutput).Select(ev => ev.Data).Do(data =>
{
Console.WriteLine($"Standard Output: '{data}'.");
}).Subscribe();
})
.ExecuteAsync();Sheller 4.0.0
This release changes:
- The
Shellerstatic class toBuilder. - The
Usemethod of the aforementioned static class toUseShell.
This release adds:
SucceededtoICommandResult.UseShelltoIExecutable.UseInputRequestHandlertoIShellandIExecutable.
UseInputRequestHandler allows the developer to recognize when the executable is waiting for input, and allow the developer to respond to that required user input with text. It looks kind of like this.
await Builder
.UseShell<Bash>()
.UseExecutable($"read var1; echo $var1")
.UseInputRequestHandler((stdout, stderr) =>
{
return Task.FromResult("hello_var1");
})
.ExecuteAsync();Sheller 3.5.0
Allows for choosing to prevent the thrown Exception when the executable exit code is non-zero.
Sheller 3.4.0
Add support for passing data into the standard input stream.
Latest package is here.