summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exit.go5
-rw-r--r--verbose.go31
2 files changed, 32 insertions, 4 deletions
diff --git a/exit.go b/exit.go
index 8e70a55..01ac9a5 100644
--- a/exit.go
+++ b/exit.go
@@ -4,13 +4,12 @@ package config
// see how this turns out
import (
+ "fmt"
"os"
-
- "go.wit.com/log"
)
// todo: figure out how to pass this back to argv
func BadExit(reason string, err error) {
- log.Exit("lib/config exiting here", reason, err)
+ fmt.Println("lib/config bad exit. no app callback here. FIXME", reason, err)
os.Exit(-1)
}
diff --git a/verbose.go b/verbose.go
index 4658dcf..d08885c 100644
--- a/verbose.go
+++ b/verbose.go
@@ -7,8 +7,36 @@ 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
+ }
+ }
- if found != nil {
+ // 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
}
@@ -17,6 +45,7 @@ func Verbose() bool {
}
// nothing in the config file. check argv
+ // todo: turn key to lowercase and check here
for _, v := range argv {
if v == "--verbose" {
return true