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

Function NewCmdList

pkg/cmd/agent-task/list/list.go:32–61  ·  view source on GitHub ↗

NewCmdList creates the list command

(f *cmdutil.Factory, runF func(*ListOptions) error)

Source from the content-addressed store, hash-verified

30
31// NewCmdList creates the list command
32func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command {
33 opts := &ListOptions{
34 IO: f.IOStreams,
35 CapiClient: shared.CapiClientFunc(f),
36 Limit: defaultLimit,
37 Browser: f.Browser,
38 }
39
40 cmd := &cobra.Command{
41 Use: "list",
42 Short: "List agent tasks (preview)",
43 Args: cobra.NoArgs,
44 RunE: func(cmd *cobra.Command, args []string) error {
45 if opts.Limit < 1 {
46 return cmdutil.FlagErrorf("invalid limit: %v", opts.Limit)
47 }
48 if runF != nil {
49 return runF(opts)
50 }
51 return listRun(opts)
52 },
53 }
54
55 cmd.Flags().IntVarP(&opts.Limit, "limit", "L", defaultLimit, "Maximum number of agent tasks to fetch")
56 cmd.Flags().BoolVarP(&opts.Web, "web", "w", false, "Open agent tasks in the browser")
57
58 cmdutil.AddJSONFlags(cmd, &opts.Exporter, capi.SessionFields)
59
60 return cmd
61}
62
63func listRun(opts *ListOptions) error {
64 if opts.Web {

Callers 1

TestNewCmdListFunction · 0.70

Calls 3

FlagErrorfFunction · 0.92
AddJSONFlagsFunction · 0.92
listRunFunction · 0.70

Tested by 1

TestNewCmdListFunction · 0.56