MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / getRun

Function getRun

pkg/cmd/config/get/get.go:33–57  ·  view source on GitHub ↗
(isPromptEnabled bool, ask question.Asker, key string, out io.Writer)

Source from the content-addressed store, hash-verified

31}
32
33func 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
59func promptMissing(ask question.Asker) (string, error) {
60 keys := []string{

Callers 1

NewCmdGetFunction · 0.85

Calls 2

IsValidKeyFunction · 0.92
promptMissingFunction · 0.70

Tested by

no test coverage detected