Skip to content

Commit

Permalink
make command runner configurable (#196)
Browse files Browse the repository at this point in the history
Co-authored-by: knqyf263 <[email protected]>
  • Loading branch information
cking and knqyf263 authored May 8, 2023
1 parent 803bc98 commit 9b3e0fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 5 additions & 6 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ func editFile(command, file string) error {
func run(command string, r io.Reader, w io.Writer) error {
var cmd *exec.Cmd
if len(config.Conf.General.Cmd) > 0 {
cmd = exec.Command(config.Conf.General.Cmd[0], append(config.Conf.General.Cmd[1:], command)...)
line := append(config.Conf.General.Cmd, command)
cmd = exec.Command(line[0], line[1:]...)
} else if runtime.GOOS == "windows" {
cmd = exec.Command("cmd", "/c", command)
} else {
if runtime.GOOS == "windows" {
cmd = exec.Command("cmd", "/c", command)
} else {
cmd = exec.Command("sh", "-c", command)
}
cmd = exec.Command("sh", "-c", command)
}
cmd.Stderr = os.Stderr
cmd.Stdout = w
Expand Down
7 changes: 4 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os/exec"
"path/filepath"
"runtime"

"github.com/BurntSushi/toml"
"github.com/pkg/errors"
)
Expand All @@ -15,9 +16,9 @@ var Conf Config

// Config is a struct of config
type Config struct {
General GeneralConfig `toml:"General"`
Gist GistConfig `toml:"Gist"`
GitLab GitLabConfig `toml:"GitLab"`
General GeneralConfig `toml:"General"`
Gist GistConfig `toml:"Gist"`
GitLab GitLabConfig `toml:"GitLab"`
}

// GeneralConfig is a struct of general config
Expand Down

0 comments on commit 9b3e0fa

Please sign in to comment.