MCPcopy Index your code
hub / github.com/coder/coder / listOrganizationMembers

Method listOrganizationMembers

cli/organizationmembers.go:139–185  ·  view source on GitHub ↗
(orgContext *OrganizationContext)

Source from the content-addressed store, hash-verified

137}
138
139func (r *RootCmd) listOrganizationMembers(orgContext *OrganizationContext) *serpent.Command {
140 formatter := cliui.NewOutputFormatter(
141 cliui.TableFormat([]codersdk.OrganizationMemberWithUserData{}, []string{"username", "organization roles"}),
142 cliui.JSONFormat(),
143 )
144
145 cmd := &serpent.Command{
146 Use: "list",
147 Short: "List all organization members",
148 Middleware: serpent.Chain(
149 serpent.RequireNArgs(0),
150 ),
151 Handler: func(inv *serpent.Invocation) error {
152 client, err := r.InitClient(inv)
153 if err != nil {
154 return err
155 }
156
157 ctx := inv.Context()
158 organization, err := orgContext.Selected(inv, client)
159 if err != nil {
160 return err
161 }
162
163 res, err := client.OrganizationMembers(ctx, organization.ID)
164 if err != nil {
165 return xerrors.Errorf("fetch members: %w", err)
166 }
167
168 out, err := formatter.Format(inv.Context(), res)
169 if err != nil {
170 return err
171 }
172
173 if out == "" {
174 cliui.Infof(inv.Stderr, "No organization members found.")
175 return nil
176 }
177
178 _, err = fmt.Fprintln(inv.Stdout, out)
179 return err
180 },
181 }
182 formatter.AttachOptions(&cmd.Options)
183
184 return cmd
185}

Callers 1

organizationMembersMethod · 0.95

Calls 11

InitClientMethod · 0.95
FormatMethod · 0.95
AttachOptionsMethod · 0.95
NewOutputFormatterFunction · 0.92
TableFormatFunction · 0.92
JSONFormatFunction · 0.92
InfofFunction · 0.92
SelectedMethod · 0.80
ContextMethod · 0.65
OrganizationMembersMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected