MCPcopy
hub / github.com/cli/cli / NewCmdList

Function NewCmdList

pkg/cmd/project/item-list/item_list.go:34–108  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(config listConfig) error)

Source from the content-addressed store, hash-verified

32}
33
34func NewCmdList(f *cmdutil.Factory, runF func(config listConfig) error) *cobra.Command {
35 opts := listOpts{}
36 listCmd := &cobra.Command{
37 Short: "List the items in a project",
38 Use: "item-list [<number>]",
39 Long: heredoc.Doc(`
40 List the items in a project.
41
42 If supported by the API host (github.com and GHES 3.20+), the --query option can
43 be used to perform advanced search. For the full syntax, see:
44 https://docs.github.com/en/issues/planning-and-tracking-with-projects/customizing-views-in-your-project/filtering-projects
45 `),
46 Example: heredoc.Doc(`
47 # List the items in the current users's project "1"
48 $ gh project item-list 1 --owner "@me"
49
50 # List items assigned to a specific user
51 $ gh project item-list 1 --owner "@me" --query "assignee:monalisa"
52
53 # List open issues assigned to yourself
54 $ gh project item-list 1 --owner "@me" --query "assignee:@me is:issue is:open"
55
56 # List items with the "bug" label that are not done
57 $ gh project item-list 1 --owner "@me" --query "label:bug -status:Done"
58 `),
59 Args: cobra.MaximumNArgs(1),
60 RunE: func(cmd *cobra.Command, args []string) error {
61 client, err := client.New(f)
62 if err != nil {
63 return err
64 }
65
66 if len(args) == 1 {
67 num, err := strconv.ParseInt(args[0], 10, 32)
68 if err != nil {
69 return cmdutil.FlagErrorf("invalid number: %v", args[0])
70 }
71 opts.number = int32(num)
72 }
73
74 config := listConfig{
75 io: f.IOStreams,
76 client: client,
77 opts: opts,
78 }
79
80 // allow testing of the command without actually running it
81 if runF != nil {
82 return runF(config)
83 }
84
85 if opts.query != "" {
86 httpClient, err := f.HttpClient()
87 if err != nil {
88 return err
89 }
90 cfg, err := f.Config()
91 if err != nil {

Callers 1

TestNewCmdListFunction · 0.70

Calls 8

NewFunction · 0.92
FlagErrorfFunction · 0.92
NewCachedHTTPClientFunction · 0.92
AddFormatFlagsFunction · 0.92
runListFunction · 0.70
ConfigMethod · 0.65
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65

Tested by 1

TestNewCmdListFunction · 0.56