MCPcopy Index your code
hub / github.com/cli/cli / collectInputs

Function collectInputs

pkg/cmd/workflow/run/run.go:212–255  ·  view source on GitHub ↗
(p iprompter, yamlContent []byte)

Source from the content-addressed store, hash-verified

210}
211
212func collectInputs(p iprompter, yamlContent []byte) (map[string]string, error) {
213 inputs, err := findInputs(yamlContent)
214 if err != nil {
215 return nil, err
216 }
217
218 providedInputs := map[string]string{}
219
220 if len(inputs) == 0 {
221 return providedInputs, nil
222 }
223
224 for _, input := range inputs {
225 var answer string
226
227 if input.Type == "choice" {
228 name := input.Name
229 if input.Required {
230 name += " (required)"
231 }
232 selected, err := p.Select(name, input.Default, input.Options)
233 if err != nil {
234 return nil, err
235 }
236 answer = input.Options[selected]
237 } else if input.Required {
238 for answer == "" {
239 answer, err = p.Input(input.Name+" (required)", input.Default)
240 if err != nil {
241 break
242 }
243 }
244 } else {
245 answer, err = p.Input(input.Name, input.Default)
246 }
247
248 if err != nil {
249 return nil, err
250 }
251
252 providedInputs[input.Name] = answer
253 }
254 return providedInputs, nil
255}
256
257func runRun(opts *RunOptions) error {
258 c, err := opts.HttpClient()

Callers 1

runRunFunction · 0.85

Calls 3

findInputsFunction · 0.85
SelectMethod · 0.65
InputMethod · 0.65

Tested by

no test coverage detected