Skip to content

Commit

Permalink
Refactor Shell.Run
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwhitaker committed Jul 21, 2024
1 parent e4aa7a8 commit ef86b9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions runny/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *Config) Execute(name CommandName, args ...string) error {
// Check the If
cond := strings.TrimSpace(command.If)
if len(cond) > 0 {
err := shell.Run(cond, false, c.verbose)
err := shell.Run(cond, []string{}, false, c.verbose)
if err != nil {
// Run returns an error if the exit status is not zero. So in this case, this means the test failed.
if c.verbose {
Expand All @@ -112,7 +112,7 @@ func (c *Config) Execute(name CommandName, args ...string) error {
// Handle the Run
run := strings.TrimSpace(command.Run)
if len(run) > 0 {
err := shell.Run(run, true, c.verbose, args...)
err := shell.Run(run, args, true, c.verbose)
if err != nil {
fmt.Printf("%s %s\n", color.RedString(string(run)), secondaryColor.Sprint(err))
return err
Expand Down
4 changes: 2 additions & 2 deletions runny/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

type Shell interface {
Run(string, bool, bool, ...string) error
Run(command string, extraArgs []string, echoStdout, verbose bool) error
}

type BashShell struct {
Expand All @@ -24,7 +24,7 @@ func NewShell(command string) (Shell, error) {
return nil, fmt.Errorf("unsupported shell: %s", command)
}

func (b BashShell) Run(command string, echoStdout bool, verbose bool, extraArgs ...string) error {
func (b BashShell) Run(command string, extraArgs []string, echoStdout, verbose bool) error {
if len(extraArgs) > 0 {
command = command + " " + strings.Join(extraArgs, " ")
}
Expand Down

0 comments on commit ef86b9a

Please sign in to comment.