Skip to content

Commit

Permalink
shell: Extend shell interface to support running a runbook
Browse files Browse the repository at this point in the history
  • Loading branch information
joshi4 committed Apr 27, 2024
1 parent f1572fc commit dce2f92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion shell/bash.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package shell
import (
"bufio"
"context"
"errors"
"os"
"os/exec"
"os/user"
Expand All @@ -12,6 +13,7 @@ import (
"text/template"
"time"

"github.com/getsavvyinc/savvy-cli/client"
"github.com/getsavvyinc/savvy-cli/tail"
)

Expand Down Expand Up @@ -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")
}
6 changes: 6 additions & 0 deletions shell/spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down Expand Up @@ -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")
}
6 changes: 6 additions & 0 deletions shell/zsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package shell
import (
"bufio"
"context"
"errors"
"os"
"os/exec"
"os/user"
Expand All @@ -12,6 +13,7 @@ import (
"text/template"
"time"

"github.com/getsavvyinc/savvy-cli/client"
"github.com/getsavvyinc/savvy-cli/tail"
)

Expand Down Expand Up @@ -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")
}

0 comments on commit dce2f92

Please sign in to comment.