diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 21:09:14 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 22:07:14 +1100 |
commit | e36ee0b4f10e43734c61f537322b594a05ad20e5 (patch) | |
tree | efdd2847277a5acbf8eef51ca92ad3f13fa860fe /pkg/commands/os.go | |
parent | 3c1322914518168374be02a78cee968cf1d13730 (diff) |
give RunCommand the same input signature as fmt.Sprintf
Diffstat (limited to 'pkg/commands/os.go')
-rw-r--r-- | pkg/commands/os.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go index df1b56efd..fed34a408 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -1,6 +1,7 @@ package commands import ( + "fmt" "io/ioutil" "os" "os/exec" @@ -9,6 +10,7 @@ import ( "strings" "sync" + "github.com/davecgh/go-spew/spew" "github.com/go-errors/errors" "github.com/jesseduffield/lazygit/pkg/config" @@ -58,7 +60,11 @@ func (c *OSCommand) SetCommand(cmd func(string, ...string) *exec.Cmd) { } // RunCommandWithOutput wrapper around commands returning their output and error -func (c *OSCommand) RunCommandWithOutput(command string) (string, error) { +func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...interface{}) (string, error) { + command := formatString + if len(formatArgs) > 0 { + command = fmt.Sprintf(formatString, formatArgs...) + } c.Log.WithField("command", command).Info("RunCommand") cmd := c.ExecutableFromString(command) return sanitisedCommandOutput(cmd.CombinedOutput()) @@ -114,8 +120,8 @@ func (c *OSCommand) DetectUnamePass(command string, ask func(string) string) err } // RunCommand runs a command and just returns the error -func (c *OSCommand) RunCommand(command string) error { - _, err := c.RunCommandWithOutput(command) +func (c *OSCommand) RunCommand(formatString string, formatArgs ...interface{}) error { + _, err := c.RunCommandWithOutput(formatString, formatArgs...) return err } |