feature: add replacer for ENV vars #36

Merged
vlbeaudoin merged 1 commit from feature/env-replacer into main 2024-02-19 12:12:49 -05:00
Showing only changes of commit 9eb61392a1 - Show all commits

View file

@ -3,6 +3,7 @@ package cmd
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
"codeberg.org/vlbeaudoin/serpents" "codeberg.org/vlbeaudoin/serpents"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -138,6 +139,8 @@ func initConfig() {
viper.SetConfigName(".bottin-agenda") viper.SetConfigName(".bottin-agenda")
} }
viper.SetEnvPrefix("BOTTINAGENDA")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv() // read in environment variables that match viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in. // If a config file is found, read it in.