Browse Source

cli: viper.Set(HomeFlag, rootDir)

pull/1842/head
Ethan Buchman 8 years ago
parent
commit
3585a542a0
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      cli/setup.go

+ 3
- 3
cli/setup.go View File

@ -127,12 +127,12 @@ func bindFlagsLoadViper(cmd *cobra.Command, args []string) error {
// rootDir is command line flag, env variable, or default $HOME/.tlc // rootDir is command line flag, env variable, or default $HOME/.tlc
// NOTE: we support both --root and --home for now, but eventually only --home // NOTE: we support both --root and --home for now, but eventually only --home
// Also ensure we set the correct rootDir under HomeFlag so we dont need to
// repeat this logic elsewhere.
rootDir := viper.GetString(HomeFlag) rootDir := viper.GetString(HomeFlag)
// @ebuchman: viper.IsSet doesn't do what you think...
// Even a default of "" on the pflag marks it as set,
// simply by fact of having a pflag.
if rootDir == "" { if rootDir == "" {
rootDir = viper.GetString(RootFlag) rootDir = viper.GetString(RootFlag)
viper.Set(HomeFlag, rootDir)
} }
viper.SetConfigName("config") // name of config file (without extension) viper.SetConfigName("config") // name of config file (without extension)
viper.AddConfigPath(rootDir) // search root directory viper.AddConfigPath(rootDir) // search root directory


Loading…
Cancel
Save