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

Function NewCmdList

pkg/cmd/workflow/list/list.go:35–67  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*ListOptions) error)

Source from the content-addressed store, hash-verified

33}
34
35func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command {
36 opts := &ListOptions{
37 IO: f.IOStreams,
38 HttpClient: f.HttpClient,
39 }
40
41 cmd := &cobra.Command{
42 Use: "list",
43 Short: "List workflows",
44 Long: "List workflow files, hiding disabled workflows by default.",
45 Aliases: []string{"ls"},
46 Args: cobra.NoArgs,
47 RunE: func(cmd *cobra.Command, args []string) error {
48 // support `-R, --repo` override
49 opts.BaseRepo = f.BaseRepo
50
51 if opts.Limit < 1 {
52 return cmdutil.FlagErrorf("invalid limit: %v", opts.Limit)
53 }
54
55 if runF != nil {
56 return runF(opts)
57 }
58
59 return listRun(opts)
60 },
61 }
62
63 cmd.Flags().IntVarP(&opts.Limit, "limit", "L", defaultLimit, "Maximum number of workflows to fetch")
64 cmd.Flags().BoolVarP(&opts.All, "all", "a", false, "Include disabled workflows")
65 cmdutil.AddJSONFlags(cmd, &opts.Exporter, workflowFields)
66 return cmd
67}
68
69func listRun(opts *ListOptions) error {
70 repo, err := opts.BaseRepo()

Callers 1

TestNewCmdListFunction · 0.70

Calls 3

FlagErrorfFunction · 0.92
AddJSONFlagsFunction · 0.92
listRunFunction · 0.70

Tested by 1

TestNewCmdListFunction · 0.56