Skip to content

Commit

Permalink
v1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
pefish committed Aug 29, 2024
1 parent e8c5ae1 commit 86f5a73
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
18 changes: 16 additions & 2 deletions commander.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/pefish/go-commander/pkg/persistence"
go_config "github.com/pefish/go-config"
go_file "github.com/pefish/go-file"
go_format "github.com/pefish/go-format"
i_logger "github.com/pefish/go-interface/i-logger"
t_logger "github.com/pefish/go-interface/t-logger"
Expand Down Expand Up @@ -225,7 +224,11 @@ Global Options:
return nil
}

if go_file.FileInstance.Exists(*envFile) {
exist, err := fileExists(*envFile)
if err != nil {
return errors.Wrap(err, "Env file exist error.")
}
if exist {
err = go_config.ConfigManagerInstance.SetEnvFile(*envFile)
if err != nil {
return errors.Errorf("Set env file error - %s", err)
Expand Down Expand Up @@ -444,3 +447,14 @@ func parseConfigToFlagSet(flagSet *flag.FlagSet, config interface{}) error {

return nil
}

func fileExists(fileOrPath string) (bool, error) {
_, err := os.Stat(fileOrPath)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ go 1.21
toolchain go1.21.0

require (
github.com/pefish/go-config v0.5.0
github.com/pefish/go-file v0.2.3
github.com/pefish/go-config v0.5.3
github.com/pefish/go-format v0.3.3
github.com/pefish/go-interface v0.1.2
github.com/pefish/go-logger v0.6.1
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pefish/go-config v0.5.0 h1:PFRwIRZQxl2Wz953Rp51nEZwIcbNrdORlyGypqJ238w=
github.com/pefish/go-config v0.5.0/go.mod h1:/faSDVn75OrYYib8v8cfpZ58mhRRu7V5F/NS7gxAwt0=
github.com/pefish/go-file v0.2.3 h1:glBhRD2Gn2YZB6Krw3I8rlkcDhf/BlSDA6PN8FIU0sc=
github.com/pefish/go-file v0.2.3/go.mod h1:SsTQNSzKWUrpHJVZD1wyOjRAiXx4cIUgjSYMTHD1zxI=
github.com/pefish/go-config v0.5.3 h1:rOi2Uu6kqsGLmV1oYdb090PIeylpZ5B1HmWUuicR+dA=
github.com/pefish/go-config v0.5.3/go.mod h1:jqUbG0pniZPMALmCIRtOA3tnilp/xZGHb2gFoMeSs+4=
github.com/pefish/go-format v0.3.3 h1:sSeovavK/hQvbHQDKLMYZcTSbqv7oZKpfSjHW9Xcfe8=
github.com/pefish/go-format v0.3.3/go.mod h1:1AepmLAmAReyaqdlG3VEyzcjVxs1+6hdQuynsSO6008=
github.com/pefish/go-interface v0.1.2 h1:CmBUP7e/mwFrqy2UiTb2637HzP4T1QlZPimgOOsWCQw=
Expand Down

0 comments on commit 86f5a73

Please sign in to comment.