Skip to content

Commit

Permalink
improve internal/cmdenv
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Oct 29, 2019
1 parent 7225e49 commit 05fec23
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/cmdenv/cmdenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ func Get(key string, def ...interface{}) *gvar.Var {
if len(def) > 0 {
value = def[0]
}
if v, ok := cmdOptions[key]; ok {
cmdKey := strings.ToLower(strings.Replace(key, "_", ".", -1))
if v, ok := cmdOptions[cmdKey]; ok {
value = v
} else {
key = strings.ToUpper(strings.Replace(key, ".", "_", -1))
if v := os.Getenv(key); v != "" {
envKey := strings.ToUpper(strings.Replace(key, ".", "_", -1))
if v := os.Getenv(envKey); v != "" {
value = v
}
}
Expand Down

0 comments on commit 05fec23

Please sign in to comment.