Skip to content

Commit

Permalink
Merge pull request #6 from mattn/windows
Browse files Browse the repository at this point in the history
Windows
  • Loading branch information
sachaos authored Aug 19, 2021
2 parents 9f7ed46 + 87be43d commit c985d5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Arguments struct {
}

var (
NoCommand = errors.New("command is required")
NoCommand = errors.New("command is required")
IntervalTooSmall = errors.New("interval too small")
)

Expand Down Expand Up @@ -76,7 +76,7 @@ LOOP:
return &argument, NoCommand
}

if argument.interval < 10 * time.Millisecond {
if argument.interval < 10*time.Millisecond {
return nil, IntervalTooSmall
}

Expand All @@ -102,4 +102,4 @@ Options:
-h, --help display this help and exit
-v, --version output version information and exit`)
}
}
14 changes: 11 additions & 3 deletions snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import (
"bytes"
"errors"
"fmt"
"github.com/fatih/color"
"github.com/sergi/go-diff/diffmatchpatch"
"io"
"os"
"os/exec"
"runtime"
"strings"
"time"
"unicode"

"github.com/fatih/color"
"github.com/sergi/go-diff/diffmatchpatch"

"github.com/rivo/tview"
)

Expand Down Expand Up @@ -92,7 +95,12 @@ func (s *Snapshot) run(finishedQueue chan<- int64) error {
commands := []string{s.command}
commands = append(commands, s.args...)

command := exec.Command("sh", "-c", strings.Join(commands, " "))
var command *exec.Cmd
if runtime.GOOS == "windows" {
command = exec.Command(os.Getenv("COMSPEC"), "/c", strings.Join(commands, " "))
} else {
command = exec.Command("sh", "-c", strings.Join(commands, " "))
}
command.Stdout = &b

if err := command.Start(); err != nil {
Expand Down

0 comments on commit c985d5d

Please sign in to comment.