summaryrefslogtreecommitdiff
path: root/cmd/util
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/util')
-rw-r--r--cmd/util/config.go4
-rw-r--r--cmd/util/cprint.go9
2 files changed, 11 insertions, 2 deletions
diff --git a/cmd/util/config.go b/cmd/util/config.go
index a829f44c..a354b132 100644
--- a/cmd/util/config.go
+++ b/cmd/util/config.go
@@ -66,7 +66,9 @@ func LoadConfig(cfgFile string, path []string, name string, flags []string) (*co
// If a cfg file is found, read it in.
if err := cfg.ReadInConfig(); err != nil {
- return nil, err
+ if len(flags) == 0 {
+ return nil, err
+ }
}
if len(flags) != 0 {
diff --git a/cmd/util/cprint.go b/cmd/util/cprint.go
index 0985de62..61199c4a 100644
--- a/cmd/util/cprint.go
+++ b/cmd/util/cprint.go
@@ -7,7 +7,10 @@ import (
"strings"
)
-var reg *regexp.Regexp
+var (
+ reg *regexp.Regexp
+ EnableColors bool
+)
func init() {
reg, _ = regexp.Compile(`<([^>]+)>`)
@@ -21,6 +24,10 @@ func Printf(format string, args ...interface{}) {
// Sprintf works identically to fmt.Sprintf but adds `<white+hb>color formatting support for CLI</reset>`.
func Sprintf(format string, args ...interface{}) string {
format = reg.ReplaceAllStringFunc(format, func(s string) string {
+ if !EnableColors {
+ return ""
+ }
+
return ansi.ColorCode(strings.Trim(s, "<>/"))
})