mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Tidied up environment var related code
This commit is contained in:
parent
2d982d2bb6
commit
198da56791
4 changed files with 50 additions and 7 deletions
10
cmd/root.go
10
cmd/root.go
|
|
@ -31,7 +31,6 @@ var rootCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
func Execute() {
|
||||
initialize()
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to start CLI: %s", err)
|
||||
os.Exit(1)
|
||||
|
|
@ -39,14 +38,19 @@ func Execute() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&config.Options.Verbose, "verbose", "v", false, "set the verbose flag")
|
||||
cobra.OnInitialize(initialize)
|
||||
rootCmd.PersistentFlags().BoolVarP(&config.Options.Verbose, "verbose", "v", config.Options.Verbose, "set the verbose flag")
|
||||
rootCmd.PersistentFlags().StringVarP(&confPath, "config", "c", "", "set the config path")
|
||||
rootCmd.PersistentFlags().StringVar(&config.Options.CachePath, "cache", "", "set the cache path")
|
||||
}
|
||||
|
||||
func initialize() {
|
||||
initConfig()
|
||||
initEnv()
|
||||
err := initEnv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Println("WARNING: Ignoring environment variables with errors.")
|
||||
}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue