summaryrefslogtreecommitdiff
path: root/windowMain.go
blob: 0d46dc6c67ef3a52092b25b17d60666549d53eb5 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main

import (
	"os"

	"go.wit.com/lib/gui/shell"
	"go.wit.com/log"
)

func doesExist(path string) bool {
	if _, err := os.Stat(path); err != nil {
		if os.IsNotExist(err) {
			return false
		}
	}
	return true
}

// only errors on bad errors
func quickCmd(fullpath string, cmd []string) bool {
	if me.autoDryRun.Checked() {
		log.Warn("RUN --dry-run", fullpath, cmd)
		return false
	} else {
		log.Warn("RUN:", fullpath, cmd)
	}

	result := shell.PathRun(fullpath, cmd)
	if result.Error != nil {
		log.Warn("quickCmd() cmd =", cmd)
		log.Warn("quickCmd() err =", result.Error)
		log.Warn("quickCmd() b =", result.Exit)
		log.Warn("quickCmd() output =", result.Stdout)
		return false
	} else if result.Exit != 0 {
		log.Warn("quickCmd() b =", result.Exit)
		log.Warn("quickCmd() output =", result.Stdout)
		return true
	}
	log.Warn("quickCmd() output = ", result.Stdout)
	return true
}