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

Function listRun

pkg/cmd/run/list/list.go:104–190  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

102}
103
104func listRun(opts *ListOptions) error {
105 baseRepo, err := opts.BaseRepo()
106 if err != nil {
107 return fmt.Errorf("failed to determine base repo: %w", err)
108 }
109
110 c, err := opts.HttpClient()
111 if err != nil {
112 return fmt.Errorf("failed to create http client: %w", err)
113 }
114 client := api.NewClientFromHTTP(c)
115
116 filters := &shared.FilterOptions{
117 Branch: opts.Branch,
118 Actor: opts.Actor,
119 Status: opts.Status,
120 Event: opts.Event,
121 Created: opts.Created,
122 Commit: opts.Commit,
123 }
124
125 opts.IO.StartProgressIndicator()
126 defer opts.IO.StopProgressIndicator()
127
128 if opts.WorkflowSelector != "" {
129 // initially the workflow state is limited to 'active'
130 states := []workflowShared.WorkflowState{workflowShared.Active}
131 if opts.All {
132 // the all flag tells us to add the remaining workflow states
133 // note: this will be incomplete if more workflow states are added to `workflowShared`
134 states = append(states, workflowShared.DisabledManually, workflowShared.DisabledInactivity)
135 }
136 if workflow, err := workflowShared.ResolveWorkflow(opts.Prompter, opts.IO, client, baseRepo, false, opts.WorkflowSelector, states); err == nil {
137 filters.WorkflowID = workflow.ID
138 filters.WorkflowName = workflow.Name
139 } else {
140 return err
141 }
142 }
143 runsResult, err := shared.GetRuns(client, baseRepo, filters, opts.Limit)
144 opts.IO.StopProgressIndicator()
145 if err != nil {
146 return fmt.Errorf("failed to get runs: %w", err)
147 }
148 runs := runsResult.WorkflowRuns
149 if len(runs) == 0 && opts.Exporter == nil {
150 return cmdutil.NewNoResultsError("no runs found")
151 }
152
153 if err := opts.IO.StartPager(); err == nil {
154 defer opts.IO.StopPager()
155 } else {
156 fmt.Fprintf(opts.IO.ErrOut, "failed to start pager: %v\n", err)
157 }
158
159 if opts.Exporter != nil {
160 return opts.Exporter.Write(opts.IO, runs)
161 }

Callers 2

TestListRunFunction · 0.70
NewCmdListFunction · 0.70

Calls 15

NewClientFromHTTPFunction · 0.92
NewNoResultsErrorFunction · 0.92
NewFunction · 0.92
WithHeaderFunction · 0.92
StartPagerMethod · 0.80
StopPagerMethod · 0.80
ColorSchemeMethod · 0.80
IsTTYMethod · 0.80
WorkflowNameMethod · 0.80
DurationMethod · 0.80
AddTimeFieldMethod · 0.80
StartedTimeMethod · 0.80

Tested by 1

TestListRunFunction · 0.56