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

Function listRun

pkg/cmd/issue/artifact/list/list.go:87–131  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

85}
86
87func listRun(opts *ListOptions) error {
88 repo, err := opts.BaseRepo()
89 if err != nil {
90 return err
91 }
92 if err := shared.CheckHost(repo.RepoHost()); err != nil {
93 return err
94 }
95
96 c, err := opts.Client()
97 if err != nil {
98 return err
99 }
100 if err := shared.CheckIssue(c, repo, opts.IssueNumber); err != nil {
101 return err
102 }
103
104 artifacts, err := listArtifacts(c, repo, opts.IssueNumber, opts.Type, opts.Limit)
105 if err != nil {
106 return err
107 }
108
109 if opts.Exporter != nil {
110 return opts.Exporter.Write(opts.IO, artifacts)
111 }
112
113 issueRef := fmt.Sprintf("%s#%d", ghrepo.FullName(repo), opts.IssueNumber)
114 if len(artifacts) == 0 {
115 if opts.Type != "" {
116 return cmdutil.NewNoResultsError(fmt.Sprintf("no artifacts match your search on %s", issueRef))
117 }
118 return cmdutil.NewNoResultsError(fmt.Sprintf("no artifacts found on %s", issueRef))
119 }
120
121 if err := opts.IO.StartPager(); err == nil {
122 defer opts.IO.StopPager()
123 } else {
124 fmt.Fprintf(opts.IO.ErrOut, "failed to start pager: %v\n", err)
125 }
126
127 if opts.IO.IsStdoutTTY() {
128 fmt.Fprintf(opts.IO.Out, "\n%s\n\n", listHeader(issueRef, len(artifacts), opts.Type != ""))
129 }
130 return printArtifacts(opts.IO, opts.Now(), artifacts)
131}
132
133// listArtifacts lists the artifacts of one type, or of every type when
134// artifactType is empty. gh treats generic and plan artifacts alike as

Callers 2

TestListRunFunction · 0.70
NewCmdListFunction · 0.70

Calls 13

CheckHostFunction · 0.92
CheckIssueFunction · 0.92
FullNameFunction · 0.92
NewNoResultsErrorFunction · 0.92
listArtifactsFunction · 0.85
printArtifactsFunction · 0.85
StartPagerMethod · 0.80
StopPagerMethod · 0.80
IsStdoutTTYMethod · 0.80
listHeaderFunction · 0.70
BaseRepoMethod · 0.65
RepoHostMethod · 0.65

Tested by 1

TestListRunFunction · 0.56