MCPcopy
hub / github.com/cli/cli / listRun

Function listRun

pkg/cmd/org/list/list.go:59–92  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

57}
58
59func listRun(opts *ListOptions) error {
60 httpClient, err := opts.HttpClient()
61 if err != nil {
62 return err
63 }
64
65 cfg, err := opts.Config()
66 if err != nil {
67 return err
68 }
69
70 host, _ := cfg.Authentication().DefaultHost()
71
72 listResult, err := listOrgs(httpClient, host, opts.Limit)
73 if err != nil {
74 return err
75 }
76
77 if err := opts.IO.StartPager(); err != nil {
78 fmt.Fprintf(opts.IO.ErrOut, "error starting pager: %v\n", err)
79 }
80 defer opts.IO.StopPager()
81
82 if opts.IO.IsStdoutTTY() {
83 header := listHeader(listResult.User, len(listResult.Organizations), listResult.TotalCount)
84 fmt.Fprintf(opts.IO.Out, "\n%s\n\n", header)
85 }
86
87 for _, org := range listResult.Organizations {
88 fmt.Fprintln(opts.IO.Out, org.Login)
89 }
90
91 return nil
92}
93
94func listHeader(user string, resultCount, totalCount int) string {
95 if totalCount == 0 {

Callers 2

TestListRunFunction · 0.70
NewCmdListFunction · 0.70

Calls 8

listOrgsFunction · 0.85
StartPagerMethod · 0.80
StopPagerMethod · 0.80
IsStdoutTTYMethod · 0.80
listHeaderFunction · 0.70
ConfigMethod · 0.65
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65

Tested by 1

TestListRunFunction · 0.56