(orgContext *OrganizationContext)
| 37 | } |
| 38 | |
| 39 | func (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 | } |
no test coverage detected