mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: remove org context switcher in the cli (#13674)
* chore: remove org context switcher in the cli
This commit is contained in:
@@ -16,6 +16,7 @@ func (r *RootCmd) groupCreate() *serpent.Command {
|
||||
var (
|
||||
avatarURL string
|
||||
displayName string
|
||||
orgContext = agpl.NewOrganizationContext()
|
||||
)
|
||||
|
||||
client := new(codersdk.Client)
|
||||
@@ -29,7 +30,7 @@ func (r *RootCmd) groupCreate() *serpent.Command {
|
||||
Handler: func(inv *serpent.Invocation) error {
|
||||
ctx := inv.Context()
|
||||
|
||||
org, err := agpl.CurrentOrganization(&r.RootCmd, inv, client)
|
||||
org, err := orgContext.Selected(inv, client)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("current organization: %w", err)
|
||||
}
|
||||
@@ -63,6 +64,7 @@ func (r *RootCmd) groupCreate() *serpent.Command {
|
||||
Value: serpent.StringOf(&displayName),
|
||||
},
|
||||
}
|
||||
orgContext.AttachOptions(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func (r *RootCmd) groupDelete() *serpent.Command {
|
||||
orgContext := agpl.NewOrganizationContext()
|
||||
client := new(codersdk.Client)
|
||||
cmd := &serpent.Command{
|
||||
Use: "delete <name>",
|
||||
@@ -27,7 +28,7 @@ func (r *RootCmd) groupDelete() *serpent.Command {
|
||||
groupName = inv.Args[0]
|
||||
)
|
||||
|
||||
org, err := agpl.CurrentOrganization(&r.RootCmd, inv, client)
|
||||
org, err := orgContext.Selected(inv, client)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("current organization: %w", err)
|
||||
}
|
||||
@@ -46,6 +47,7 @@ func (r *RootCmd) groupDelete() *serpent.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
orgContext.AttachOptions(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ func (r *RootCmd) groupEdit() *serpent.Command {
|
||||
displayName string
|
||||
addUsers []string
|
||||
rmUsers []string
|
||||
orgContext = agpl.NewOrganizationContext()
|
||||
)
|
||||
client := new(codersdk.Client)
|
||||
cmd := &serpent.Command{
|
||||
@@ -37,7 +38,7 @@ func (r *RootCmd) groupEdit() *serpent.Command {
|
||||
groupName = inv.Args[0]
|
||||
)
|
||||
|
||||
org, err := agpl.CurrentOrganization(&r.RootCmd, inv, client)
|
||||
org, err := orgContext.Selected(inv, client)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("current organization: %w", err)
|
||||
}
|
||||
@@ -116,6 +117,7 @@ func (r *RootCmd) groupEdit() *serpent.Command {
|
||||
Value: serpent.StringArrayOf(&rmUsers),
|
||||
},
|
||||
}
|
||||
orgContext.AttachOptions(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ func (r *RootCmd) groupList() *serpent.Command {
|
||||
cliui.TableFormat([]groupTableRow{}, nil),
|
||||
cliui.JSONFormat(),
|
||||
)
|
||||
orgContext := agpl.NewOrganizationContext()
|
||||
|
||||
client := new(codersdk.Client)
|
||||
cmd := &serpent.Command{
|
||||
@@ -30,7 +31,7 @@ func (r *RootCmd) groupList() *serpent.Command {
|
||||
Handler: func(inv *serpent.Invocation) error {
|
||||
ctx := inv.Context()
|
||||
|
||||
org, err := agpl.CurrentOrganization(&r.RootCmd, inv, client)
|
||||
org, err := orgContext.Selected(inv, client)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("current organization: %w", err)
|
||||
}
|
||||
@@ -58,6 +59,7 @@ func (r *RootCmd) groupList() *serpent.Command {
|
||||
}
|
||||
|
||||
formatter.AttachOptions(&cmd.Options)
|
||||
orgContext.AttachOptions(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ USAGE:
|
||||
Create a user group
|
||||
|
||||
OPTIONS:
|
||||
-O, --org string, $CODER_ORGANIZATION
|
||||
Select which organization (uuid or name) to use.
|
||||
|
||||
-u, --avatar-url string, $CODER_AVATAR_URL
|
||||
Set an avatar for a group.
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
coder v0.0.0-devel
|
||||
|
||||
USAGE:
|
||||
coder groups delete <name>
|
||||
coder groups delete [flags] <name>
|
||||
|
||||
Delete a user group
|
||||
|
||||
Aliases: rm
|
||||
|
||||
OPTIONS:
|
||||
-O, --org string, $CODER_ORGANIZATION
|
||||
Select which organization (uuid or name) to use.
|
||||
|
||||
———
|
||||
Run `coder --help` for a list of global options.
|
||||
|
||||
@@ -6,6 +6,9 @@ USAGE:
|
||||
Edit a user group
|
||||
|
||||
OPTIONS:
|
||||
-O, --org string, $CODER_ORGANIZATION
|
||||
Select which organization (uuid or name) to use.
|
||||
|
||||
-a, --add-users string-array
|
||||
Add users to the group. Accepts emails or IDs.
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ USAGE:
|
||||
List user groups
|
||||
|
||||
OPTIONS:
|
||||
-O, --org string, $CODER_ORGANIZATION
|
||||
Select which organization (uuid or name) to use.
|
||||
|
||||
-c, --column string-array (default: name,display name,organization id,members,avatar url)
|
||||
Columns to display in table output. Available columns: name, display
|
||||
name, organization id, members, avatar url.
|
||||
|
||||
Reference in New Issue
Block a user