MCPcopy Index your code
hub / github.com/rilldata/rill / ListCmd

Function ListCmd

cli/cmd/project/list.go:9–52  ·  view source on GitHub ↗
(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

7)
8
9func ListCmd(ch *cmdutil.Helper) *cobra.Command {
10 var pageSize uint32
11 var pageToken string
12
13 listCmd := &cobra.Command{
14 Use: "list",
15 Short: "List all the projects",
16 RunE: func(cmd *cobra.Command, args []string) error {
17 client, err := ch.Client()
18 if err != nil {
19 return err
20 }
21
22 res, err := client.ListProjectsForOrganization(cmd.Context(), &adminv1.ListProjectsForOrganizationRequest{
23 Org: ch.Org,
24 PageSize: pageSize,
25 PageToken: pageToken,
26 })
27 if err != nil {
28 return err
29 }
30
31 if len(res.Projects) == 0 {
32 ch.PrintfWarn("No projects found\n")
33 return nil
34 }
35
36 ch.PrintfSuccess("Projects list\n")
37 ch.PrintProjects(res.Projects)
38
39 if res.NextPageToken != "" {
40 cmd.Println()
41 cmd.Printf("Next page token: %s\n", res.NextPageToken)
42 }
43
44 return nil
45 },
46 }
47
48 listCmd.Flags().Uint32Var(&pageSize, "page-size", 50, "Number of projects to return per page")
49 listCmd.Flags().StringVar(&pageToken, "page-token", "", "Pagination token")
50
51 return listCmd
52}

Callers 1

ProjectCmdFunction · 0.70

Calls 8

PrintfWarnMethod · 0.80
PrintfSuccessMethod · 0.80
PrintProjectsMethod · 0.80
PrintlnMethod · 0.80
PrintfMethod · 0.80
ContextMethod · 0.65
ClientMethod · 0.45

Tested by

no test coverage detected