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

Function selectWorkflow

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

Source from the content-addressed store, hash-verified

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

Callers 1

ResolveWorkflowFunction · 0.85

Calls 2

BaseMethod · 0.80
SelectMethod · 0.65

Tested by

no test coverage detected