summaryrefslogtreecommitdiff
path: root/verbose.go
blob: e3aba43bd36e2a924911b4854e1c78760a629570 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
package env

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

func Verbose() bool {
	// always use the ENV value first
	if envPB != nil {
		found := envPB.FindByVar("Verbose")
		if found == nil {
			// Verbose isn't in the ENV. do nothing here
		} else {
			// return what the ENV has
			// fmt.Println("returning from the ENV:" + found.Value)
			if found.Value == "true" {
				return true
			}
			return false
		}
	}

	// nothing in the ENV.  check argv
	for _, v := range argv {
		if v == "--verbose" {
			return true
		}
	}
	return false
}

func If(key string) bool {
	// always use the ENV value first
	if envPB != nil {
		found := envPB.FindByVar(key)
		if found == nil {
			// Verbose isn't in the ENV. do nothing here
		} else {
			// return what the ENV has
			// fmt.Println("returning from the ENV:" + found.Value)
			if found.Value == "true" {
				return true
			}
			return false
		}
	}

	// nothing in the ENV. check argv
	// todo: turn key to lowercase and check here
	for _, v := range argv {
		if v == "--verbose" {
			return true
		}
	}
	return false
}