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

Function selectWorkflow

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

Source from the content-addressed store, hash-verified

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