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

Function selectWorkflow

pkg/cmd/workflow/shared/shared.go:106–126  ·  view source on GitHub ↗
(p iprompter, workflows []Workflow, promptMsg string, states []WorkflowState)

Source from the content-addressed store, hash-verified

104}
105
106func selectWorkflow(p iprompter, workflows []Workflow, promptMsg string, states []WorkflowState) (*Workflow, error) {
107 filtered := []Workflow{}
108 candidates := []string{}
109 for _, workflow := range workflows {
110 if slices.Contains(states, workflow.State) {
111 filtered = append(filtered, workflow)
112 candidates = append(candidates, fmt.Sprintf("%s (%s)", workflow.Name, workflow.Base()))
113 }
114 }
115
116 if len(candidates) == 0 {
117 return nil, FilteredAllError{errors.New("")}
118 }
119
120 selected, err := p.Select(promptMsg, "", candidates)
121 if err != nil {
122 return nil, err
123 }
124
125 return &filtered[selected], nil
126}
127
128// FindWorkflow looks up a workflow either by numeric database ID, file name, or its Name field
129func FindWorkflow(client *api.Client, repo ghrepo.Interface, workflowSelector string, states []WorkflowState) ([]Workflow, error) {

Callers 1

ResolveWorkflowFunction · 0.85

Calls 3

ContainsMethod · 0.80
BaseMethod · 0.80
SelectMethod · 0.65

Tested by

no test coverage detected