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

Method showOrganization

cli/organization.go:39–162  ·  view source on GitHub ↗
(orgContext *OrganizationContext)

Source from the content-addressed store, hash-verified

37}
38
39func (r *RootCmd) showOrganization(orgContext *OrganizationContext) *serpent.Command {
40 var (
41 stringFormat func(orgs []codersdk.Organization) (string, error)
42 formatter = cliui.NewOutputFormatter(
43 cliui.ChangeFormatterData(cliui.TextFormat(), func(data any) (any, error) {
44 typed, ok := data.([]codersdk.Organization)
45 if !ok {
46 // This should never happen
47 return "", xerrors.Errorf("expected []Organization, got %T", data)
48 }
49 return stringFormat(typed)
50 }),
51 cliui.TableFormat([]codersdk.Organization{}, []string{"id", "name", "default"}),
52 cliui.JSONFormat(),
53 )
54 onlyID = false
55 )
56 cmd := &serpent.Command{
57 Use: "show [\"selected\"|\"me\"|uuid|org_name]",
58 Short: "Show the organization. " +
59 "Using \"selected\" will show the selected organization from the \"--org\" flag. " +
60 "Using \"me\" will show all organizations you are a member of.",
61 Long: FormatExamples(
62 Example{
63 Description: "coder org show selected",
64 Command: "Shows the organizations selected with '--org=<org_name>'. " +
65 "This organization is the organization used by the cli.",
66 },
67 Example{
68 Description: "coder org show me",
69 Command: "List of all organizations you are a member of.",
70 },
71 Example{
72 Description: "coder org show developers",
73 Command: "Show organization with name 'developers'",
74 },
75 Example{
76 Description: "coder org show 90ee1875-3db5-43b3-828e-af3687522e43",
77 Command: "Show organization with the given ID.",
78 },
79 ),
80 Middleware: serpent.Chain(
81 serpent.RequireRangeArgs(0, 1),
82 ),
83 Options: serpent.OptionSet{
84 {
85 Name: "only-id",
86 Description: "Only print the organization ID.",
87 Required: false,
88 Flag: "only-id",
89 Value: serpent.BoolOf(&onlyID),
90 },
91 },
92 Handler: func(inv *serpent.Invocation) error {
93 client, err := r.InitClient(inv)
94 if err != nil {
95 return err
96 }

Callers 1

organizationsMethod · 0.95

Calls 15

InitClientMethod · 0.95
NewOutputFormatterFunction · 0.92
ChangeFormatterDataFunction · 0.92
TextFormatFunction · 0.92
TableFormatFunction · 0.92
JSONFormatFunction · 0.92
FormatExamplesFunction · 0.85
SelectedMethod · 0.80
OrganizationsByUserMethod · 0.80
OrganizationByNameMethod · 0.80
ContextMethod · 0.65
FormatMethod · 0.65

Tested by

no test coverage detected