mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 13:06:30 +02:00
Add prefix to env variable lookup, replace . with _
e.g. $PACKWIZ_INIT_REINIT is equivalent to the -r flag
This commit is contained in:
parent
99d0af14c4
commit
beef8c6692
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@ -92,7 +93,10 @@ func initConfig() {
|
|||||||
viper.SetConfigName(".packwiz")
|
viper.SetConfigName(".packwiz")
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.AutomaticEnv() // read in environment variables that match
|
// Read in environment variables that match
|
||||||
|
viper.SetEnvPrefix("packwiz")
|
||||||
|
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||||
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
// If a config file is found, read it in.
|
// If a config file is found, read it in.
|
||||||
if err := viper.ReadInConfig(); err == nil {
|
if err := viper.ReadInConfig(); err == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user