(isPromptEnabled bool, ask question.Asker, key string, out io.Writer)
| 31 | } |
| 32 | |
| 33 | func getRun(isPromptEnabled bool, ask question.Asker, key string, out io.Writer) error { |
| 34 | if key != "" { |
| 35 | if !config.IsValidKey(key) { |
| 36 | return fmt.Errorf("the key '%s' is not a valid", key) |
| 37 | } |
| 38 | } |
| 39 | value := "" |
| 40 | configFile := viper.New() |
| 41 | configFile.SetConfigFile(viper.ConfigFileUsed()) |
| 42 | configFile.ReadInConfig() |
| 43 | if isPromptEnabled && key == "" { |
| 44 | k, err := promptMissing(ask) |
| 45 | if err != nil { |
| 46 | return err |
| 47 | } |
| 48 | key = k |
| 49 | } |
| 50 | value = configFile.GetString(key) |
| 51 | if value == "" && !configFile.InConfig(key) { |
| 52 | return fmt.Errorf("unable to get value for key: %s", key) |
| 53 | } |
| 54 | |
| 55 | fmt.Fprintln(out, value) |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func promptMissing(ask question.Asker) (string, error) { |
| 60 | keys := []string{ |
no test coverage detected