Skip to content

Releases: twitchax/Sheller

Sheller 6.0.1

15 May 02:33
Compare
Choose a tag to compare

This release fixes:

  • Fixed a bug where some of the built-in shells and executables (e.g., IKubectl) did not properly return their interface types on method calls.

Sheller 6.0.0

05 May 05:46
Compare
Choose a tag to compare

This release changes:

  • Interfaces are now first-class return types. Concrete types of plugin IShells and IExecutables are no longer returned.

This release adds:

  • UseStartInfoTransform to IShell and IExecutable.

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

11 Apr 20:01
Compare
Choose a tag to compare

This release changes:

  • N/A.

This release adds:

  • Invocation to CommandEventType.

Sheller 5.3.0

11 Apr 06:36
Compare
Choose a tag to compare

This release changes:

  • N/A.

This release adds:

  • UseExecutable to IExecutable.
  • UseCommandPrefix to IShell.

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

17 Mar 05:40
Compare
Choose a tag to compare

This release changes:

  • N/A.

This release adds:

  • UseStandardOutputEncoding to IShell and IExecutable.
  • UseStandardErrorEncoding to IShell and IExecutable.

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

16 Mar 22:03
Compare
Choose a tag to compare

This release changes:

  • N/A.

This release adds:

  • WithCancellationToken to IShell and IExecutable.
  • ConfigureAwait(false) to all awaits.
  • 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

14 Mar 07:04
Compare
Choose a tag to compare

This release changes:

  • N/A.

This release adds:

  • WithSubscribe to IShell.
  • WithSubscribe to IExecutable.

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

19 Feb 08:36
Compare
Choose a tag to compare

This release changes:

  • The Sheller static class to Builder.
  • The Use method of the aforementioned static class to UseShell.

This release adds:

  • Succeeded to ICommandResult.
  • UseShell to IExecutable.
  • UseInputRequestHandler to IShell and IExecutable.

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

14 Feb 07:45
Compare
Choose a tag to compare

Allows for choosing to prevent the thrown Exception when the executable exit code is non-zero.

Sheller 3.4.0

06 Feb 01:50
Compare
Choose a tag to compare

Add support for passing data into the standard input stream.

Latest package is here.