1
0
mirror of https://github.com/drone/drone-cli.git synced 2024-11-23 17:22:09 +01:00
drone-cli/drone/user/user_block.go

38 lines
619 B
Go
Raw Normal View History

2019-01-17 18:20:16 +01:00
package user
import (
"fmt"
"github.com/urfave/cli"
"github.com/drone/drone-cli/drone/internal"
"github.com/drone/drone-go/drone"
)
var userBlockCmd = cli.Command{
Name: "block",
Usage: "block a user",
ArgsUsage: "<username>",
Action: userBlock,
}
func userBlock(c *cli.Context) error {
login := c.Args().First()
client, err := internal.NewClient(c)
if err != nil {
return err
}
active := false
opts := &drone.UserPatch{
Active: &active,
}
_, err = client.UserUpdate(login, opts)
if err != nil {
return err
}
fmt.Printf("Successfully blocked user %s\n", login)
return nil
}