From dce2f925f764b1cc0d2f6535a65b8d30dffb3325 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Thu, 25 Apr 2024 12:42:28 -1000 Subject: [PATCH] shell: Extend shell interface to support running a runbook --- shell/bash.go | 8 +++++++- shell/spawn.go | 6 ++++++ shell/zsh.go | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/shell/bash.go b/shell/bash.go index 0cd568f..c480fe6 100644 --- a/shell/bash.go +++ b/shell/bash.go @@ -3,6 +3,7 @@ package shell import ( "bufio" "context" + "errors" "os" "os/exec" "os/user" @@ -12,6 +13,7 @@ import ( "text/template" "time" + "github.com/getsavvyinc/savvy-cli/client" "github.com/getsavvyinc/savvy-cli/tail" ) @@ -177,7 +179,11 @@ func (b *bash) SpawnHistoryExpander(ctx context.Context) (*exec.Cmd, error) { } cmd := exec.CommandContext(ctx, b.shellCmd, "--rcfile", bashrc.Name()) - cmd.Env = append(os.Environ()) + cmd.Env = os.Environ() cmd.WaitDelay = 500 * time.Millisecond return cmd, nil } + +func (b *bash) SpawnRunbookRunner(ctx context.Context, runbook *client.Runbook) (*exec.Cmd, error) { + return nil, errors.New("savvy doesn't support your current shell") +} diff --git a/shell/spawn.go b/shell/spawn.go index 5786deb..848e5ce 100644 --- a/shell/spawn.go +++ b/shell/spawn.go @@ -5,6 +5,7 @@ import ( "errors" "os/exec" + "github.com/getsavvyinc/savvy-cli/client" "github.com/getsavvyinc/savvy-cli/shell/internal/detect" "github.com/getsavvyinc/savvy-cli/shell/kind" ) @@ -13,6 +14,7 @@ type Shell interface { Spawn(ctx context.Context) (*exec.Cmd, error) TailHistory(ctx context.Context) ([]string, error) SpawnHistoryExpander(ctx context.Context) (*exec.Cmd, error) + SpawnRunbookRunner(ctx context.Context, runbook *client.Runbook) (*exec.Cmd, error) } func New(logTarget string) Shell { @@ -48,3 +50,7 @@ func (t *todo) TailHistory(ctx context.Context) ([]string, error) { func (t *todo) SpawnHistoryExpander(ctx context.Context) (*exec.Cmd, error) { return nil, errors.New("savvy doesn't support your current shell") } + +func (t *todo) SpawnRunbookRunner(ctx context.Context, runbook *client.Runbook) (*exec.Cmd, error) { + return nil, errors.New("savvy doesn't support your current shell") +} diff --git a/shell/zsh.go b/shell/zsh.go index 97e369e..ae04626 100644 --- a/shell/zsh.go +++ b/shell/zsh.go @@ -3,6 +3,7 @@ package shell import ( "bufio" "context" + "errors" "os" "os/exec" "os/user" @@ -12,6 +13,7 @@ import ( "text/template" "time" + "github.com/getsavvyinc/savvy-cli/client" "github.com/getsavvyinc/savvy-cli/tail" ) @@ -284,3 +286,7 @@ func (z *zsh) TailHistory(ctx context.Context) ([]string, error) { } return result, nil } + +func (z *zsh) SpawnRunbookRunner(ctx context.Context, runbook *client.Runbook) (*exec.Cmd, error) { + return nil, errors.New("savvy doesn't support your current shell") +}