diff options
| author | Jeff Carr <[email protected]> | 2025-10-28 21:59:48 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-28 21:59:48 -0500 |
| commit | 200b76da8a0dd95b524d44e90a92106a9699d9fd (patch) | |
| tree | fbd9110e1b464278c5b9faa93639fe887494effd | |
| parent | 05d09b7584b4cd18676c68dd161142044437a7af (diff) | |
| -rw-r--r-- | etc.go | 10 | ||||
| -rw-r--r-- | init.go | 14 | ||||
| -rw-r--r-- | path.go | 9 | ||||
| -rw-r--r-- | verbose.go | 6 |
4 files changed, 28 insertions, 11 deletions
@@ -5,14 +5,12 @@ import ( "os" "path/filepath" "strings" - - "go.wit.com/log" ) var ErrInit error = fmt.Errorf("lib/env has not been initialized") func LoadEtc() error { - log.Info("Starting LoadEtc() with appname:", APPNAME) + fmt.Printf("Starting LoadEtc() with appname: %s\n", APPNAME) if envPB == nil { return ErrInit } @@ -21,19 +19,19 @@ func LoadEtc() error { } globPattern := filepath.Join("/etc/", APPNAME+".d", "*") - log.Info("glob Pattern:", globPattern) + fmt.Printf("glob Pattern (%s)\n", globPattern) files, err := filepath.Glob(globPattern) if err != nil { fmt.Printf("%s glob error (%v)\n", globPattern, err) return err } - log.Info("found files:", files) + fmt.Printf("found files: %v\n", files) for _, file := range files { data, _ := os.ReadFile(file) _, name := filepath.Split(file) parseFileData("etc/"+name, string(data)) - log.Info("LoadEtc() file:", file) + fmt.Println("LoadEtc() file:", file) } return nil @@ -131,3 +131,17 @@ func LoadENV(filename string) error { } return err } + +func LoadAppENV(appname string) error { + configDir, err := os.UserConfigDir() + if err != nil { + return err + } + fpath := filepath.Join(configDir, appname, appname+"rc") + fmt.Printf("env.Load(%s)\n", fpath) + data, err := os.ReadFile(fpath) + if err == nil { + parseFileData(appname, string(data)) + } + return err +} @@ -1,25 +1,24 @@ package env import ( + "fmt" "os" "path/filepath" "strings" - - "go.wit.com/log" ) // adds a path to the ENV func AddPath(newpath string) bool { path := os.Getenv("PATH") for _, p := range strings.Split(path, ":") { - log.Info("Looking at path:", p) + fmt.Println("Looking at path:", p) if p == newpath { - log.Info("FOUND path:", p) + fmt.Println("FOUND path:", p) return false } } path = path + ":" + newpath - log.Info("ADDING PATH:", path) + fmt.Println("ADDING PATH:", path) os.Setenv("PATH", path) return true } @@ -1,5 +1,7 @@ package env +import "os" + // this is an experiment at this point to // see how this turns out @@ -25,6 +27,10 @@ func Verbose() bool { return true } } + + if os.Getenv("VERBOSE") == "true" { + return true + } return false } |
