chore: remove org context switcher in the cli (#13674)

* chore: remove org context switcher in the cli
This commit is contained in:
Steven Masley
2024-07-01 16:04:45 -05:00
committed by GitHub
parent 4a0fd7466c
commit 5bf46f360a
52 changed files with 353 additions and 362 deletions
+3 -1
View File
@@ -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
}
+3 -1
View File
@@ -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
}
+3 -1
View File
@@ -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
}
+3 -1
View File
@@ -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.
+5 -1
View File
@@ -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.