diff options
author | Wolfy-J <[email protected]> | 2019-02-14 15:05:01 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2019-02-14 15:05:01 +0300 |
commit | 278e16855669a5112a9fa627a5db0fedd62266ec (patch) | |
tree | 3d8641f60a51346dbd044ced080a51e60f61434a /cmd/util | |
parent | dd4bc086e18cda344b75c29175885db90c8e7196 (diff) | |
parent | a9e8ff6ac4f1a20c2024312cab65dd2c12c721e8 (diff) |
Merge pull request #119 from spiral/feature/13.5
version bump
Diffstat (limited to 'cmd/util')
-rw-r--r-- | cmd/util/config.go | 4 | ||||
-rw-r--r-- | cmd/util/cprint.go | 9 |
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, "<>/")) }) |