summaryrefslogtreecommitdiff
path: root/exit.go
blob: fdaec8a459c7046271873c01a772cd13d1165b03 (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
package env

import "os"

// this is an experiment at this point to
// see how this turns out

// argv normally sets these callbacks
// argv has timing set from when os.Args was parsed
func GoodExit(reason string) {
	if goodExit != nil {
		goodExit(reason)
	}
	os.Exit(0)
}

func BadExit(reason string, err error) {
	if badExit != nil {
		badExit(reason, err)
	}
	os.Exit(-1)
}

func Exit(reason string, err error) {
	if err == nil {
		GoodExit(reason)
		os.Exit(0)
	}
	BadExit(reason, err)
	os.Exit(-1)
}