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
IShell
s andIExecutable
s are no longer returned.
This release adds:
UseStartInfoTransform
toIShell
andIExecutable
.
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:
Invocation
toCommandEventType
.
Sheller 5.3.0
This release changes:
- N/A.
This release adds:
UseExecutable
toIExecutable
.UseCommandPrefix
toIShell
.
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:
UseStandardOutputEncoding
toIShell
andIExecutable
.UseStandardErrorEncoding
toIShell
andIExecutable
.
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:
WithCancellationToken
toIShell
andIExecutable
.ConfigureAwait(false)
to allawait
s.- 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:
WithSubscribe
toIShell
.WithSubscribe
toIExecutable
.
WithSubscribe
allows the developer to subscribe to events using IObservable
s (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
Sheller
static class toBuilder
. - The
Use
method of the aforementioned static class toUseShell
.
This release adds:
Succeeded
toICommandResult
.UseShell
toIExecutable
.UseInputRequestHandler
toIShell
andIExecutable
.
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.