MCPcopy Create free account
hub / github.com/cli/cli / collectInputs

Function collectInputs

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

Source from the content-addressed store, hash-verified

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