File: file_launcher.go

package info (click to toggle)
golang-github-approvals-go-approval-tests 0.0~git20180620.6ae1ec6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 296 kB
  • sloc: xml: 16; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 523 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}