mirror of
https://github.com/coder/coder.git
synced 2026-10-28 02:42:54 +08:00
@@ -3,30 +3,30 @@ package cli
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
agpl "github.com/coder/coder/cli"
|
||||
"github.com/coder/coder/cli/clibase"
|
||||
"github.com/coder/coder/cli/cliui"
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func groupDelete() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
func (r *RootCmd) groupDelete() *clibase.Cmd {
|
||||
client := new(codersdk.Client)
|
||||
cmd := &clibase.Cmd{
|
||||
Use: "delete <name>",
|
||||
Short: "Delete a user group",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
Middleware: clibase.Chain(
|
||||
clibase.RequireNArgs(1),
|
||||
r.InitClient(client),
|
||||
),
|
||||
Handler: func(inv *clibase.Invocation) error {
|
||||
var (
|
||||
ctx = cmd.Context()
|
||||
groupName = args[0]
|
||||
ctx = inv.Context()
|
||||
groupName = inv.Args[0]
|
||||
)
|
||||
|
||||
client, err := agpl.CreateClient(cmd)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("create client: %w", err)
|
||||
}
|
||||
|
||||
org, err := agpl.CurrentOrganization(cmd, client)
|
||||
org, err := agpl.CurrentOrganization(inv, client)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("current organization: %w", err)
|
||||
}
|
||||
@@ -41,7 +41,7 @@ func groupDelete() *cobra.Command {
|
||||
return xerrors.Errorf("delete group: %w", err)
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Successfully deleted group %s!\n", cliui.Styles.Keyword.Render(group.Name))
|
||||
_, _ = fmt.Fprintf(inv.Stdout, "Successfully deleted group %s!\n", cliui.Styles.Keyword.Render(group.Name))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user