summaryrefslogtreecommitdiff
path: root/verbose.go
blob: 438475a6ec7e558b5179905376d0bca6b9f6241b (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 config

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

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

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

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

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