MCPcopy
hub / github.com/cli/cli / runList

Function runList

pkg/cmd/project/item-list/item_list.go:110–146  ·  view source on GitHub ↗
(config listConfig)

Source from the content-addressed store, hash-verified

108}
109
110func runList(config listConfig) error {
111 if config.opts.query != "" {
112 features, err := config.detector.ProjectFeatures()
113 if err != nil {
114 return err
115 }
116 if !features.ProjectItemQuery {
117 return fmt.Errorf("the `--query` flag is not supported on this GitHub host")
118 }
119 }
120
121 canPrompt := config.io.CanPrompt()
122 owner, err := config.client.NewOwner(canPrompt, config.opts.owner)
123 if err != nil {
124 return err
125 }
126
127 // no need to fetch the project if we already have the number
128 if config.opts.number == 0 {
129 project, err := config.client.NewProject(canPrompt, owner, config.opts.number, false)
130 if err != nil {
131 return err
132 }
133 config.opts.number = project.Number
134 }
135
136 project, err := config.client.ProjectItems(owner, config.opts.number, config.opts.limit, config.opts.query)
137 if err != nil {
138 return err
139 }
140
141 if config.opts.exporter != nil {
142 return config.opts.exporter.Write(config.io, project.DetailedItems())
143 }
144
145 return printResults(config, project.Items.Nodes, owner.Login)
146}
147
148func printResults(config listConfig, items []queries.ProjectItem, login string) error {
149 if len(items) == 0 {

Callers 8

TestRunList_User_ttyFunction · 0.70
TestRunList_UserFunction · 0.70
TestRunList_OrgFunction · 0.70
TestRunList_MeFunction · 0.70
TestRunList_JSONFunction · 0.70
TestRunList_WithQueryFunction · 0.70
NewCmdListFunction · 0.70

Calls 9

DetailedItemsMethod · 0.95
CanPromptMethod · 0.80
NewOwnerMethod · 0.80
NewProjectMethod · 0.80
ProjectItemsMethod · 0.80
printResultsFunction · 0.70
ProjectFeaturesMethod · 0.65
ErrorfMethod · 0.65
WriteMethod · 0.65

Tested by 7

TestRunList_User_ttyFunction · 0.56
TestRunList_UserFunction · 0.56
TestRunList_OrgFunction · 0.56
TestRunList_MeFunction · 0.56
TestRunList_JSONFunction · 0.56
TestRunList_WithQueryFunction · 0.56