Skip to content

Commit

Permalink
Remove unused code regarding config
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkpickering committed Feb 4, 2023
1 parent 5bcb415 commit c846b43
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
"os"

"github.com/spf13/cobra"

"github.com/spf13/viper"
)

var cfgFile string
Expand All @@ -53,32 +51,4 @@ func init() {
panic(fmt.Errorf("failed to get working directory: %w", err))
}
deckDirectory = localDeckDirectory

cobra.OnInitialize(initConfig)
configHelp := "config file (default is $HOME/.clsr.yaml)"
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", configHelp)
}

// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := os.UserHomeDir()
cobra.CheckErr(err)

// Search config in home directory with name ".clsr" (without extension).
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName(".clsr")
}

viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
}

0 comments on commit c846b43

Please sign in to comment.