MCPcopy Index your code
hub / github.com/AdminTurnedDevOps/CapabilityPE / initConfig

Function initConfig

cmd/root.go:49–72  ·  view source on GitHub ↗

initConfig reads in config file and ENV variables if set.

()

Source from the content-addressed store, hash-verified

47
48// initConfig reads in config file and ENV variables if set.
49func initConfig() {
50 if cfgFile != "" {
51 // Use config file from the flag.
52 viper.SetConfigFile(cfgFile)
53 } else {
54 // Find home directory.
55 home, err := homedir.Dir()
56 if err != nil {
57 fmt.Println(err)
58 os.Exit(1)
59 }
60
61 // Search config in home directory with name ".capipe" (without extension).
62 viper.AddConfigPath(home)
63 viper.SetConfigName(".capipe")
64 }
65
66 viper.AutomaticEnv() // read in environment variables that match
67
68 // If a config file is found, read it in.
69 if err := viper.ReadInConfig(); err == nil {
70 fmt.Println("Using config file:", viper.ConfigFileUsed())
71 }
72}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected