(prompt PromptHandler)
| 191 | } |
| 192 | |
| 193 | func promptParameter(prompt PromptHandler) (error, string) { |
| 194 | param := prompt.Parameter |
| 195 | label := param.Label |
| 196 | if param.Label == "" { |
| 197 | label = param.Field |
| 198 | } |
| 199 | defaultValue := param.Default |
| 200 | |
| 201 | var err error |
| 202 | var result string |
| 203 | if len(param.Options) > 0 { |
| 204 | var selectedIndex int |
| 205 | // Scope of selected does not have the label data, so we need a dynamic |
| 206 | // template with string format to put in the label in `selected` |
| 207 | optionTemplate := &promptui.SelectTemplates{ |
| 208 | Label: `{{ . }}`, |
| 209 | Active: fmt.Sprintf("%s {{ .Value | cyan }}", cyanArrow), |
| 210 | Inactive: " {{ .Value }}", |
| 211 | Selected: fmt.Sprintf("%s %s: {{ .Value }}", greenCheckMark, label), |
| 212 | } |
| 213 | |
| 214 | prompt := promptui.Select{ |
| 215 | Label: label, |
| 216 | Items: param.Options, |
| 217 | Templates: optionTemplate, |
| 218 | } |
| 219 | |
| 220 | selectedIndex, _, err = prompt.Run() |
| 221 | result = param.Options[selectedIndex].Key.(string) |
| 222 | } else { |
| 223 | prompt := promptui.Prompt{ |
| 224 | Label: label, |
| 225 | Default: defaultValue, |
| 226 | AllowEdit: true, |
| 227 | Validate: prompt.Validate, |
| 228 | } |
| 229 | result, err = prompt.Run() |
| 230 | } |
| 231 | if err != nil { |
| 232 | return err, "" |
| 233 | } |
| 234 | |
| 235 | return nil, result |
| 236 | } |
| 237 | |
| 238 | func executeCmd(command string, envVars map[string]string, envVarTranslationMap map[string]string) string { |
| 239 | cmd := exec.Command("bash", "-c", command) |
no outgoing calls
no test coverage detected