packer-cn/vendor/github.com/approvals/go-approval-tests/reporters/file_launcher.go

28 lines
523 B
Go
Raw Normal View History

2016-07-11 18:08:28 -04:00
package reporters
import (
"os/exec"
"runtime"
)
type fileLauncher struct{}
// NewFileLauncherReporter launches registered application of the received file's type only.
func NewFileLauncherReporter() Reporter {
return &fileLauncher{}
}
func (s *fileLauncher) Report(approved, received string) bool {
var cmd *exec.Cmd
switch runtime.GOOS {
case "windows":
cmd = exec.Command("cmd", "/C", "start", "Needed Title", received, "/B")
default:
cmd = exec.Command("open", received)
}
cmd.Start()
return true
}