2019-04-06 21:32:14 +02:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/urfave/cli"
|
2021-06-22 12:34:35 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
2019-04-06 21:32:14 +02:00
|
|
|
|
2021-09-21 16:36:41 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
2019-04-06 21:32:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var userAddCmd = cli.Command{
|
|
|
|
Name: "add",
|
|
|
|
Usage: "adds a user",
|
|
|
|
ArgsUsage: "<username>",
|
|
|
|
Action: userAdd,
|
|
|
|
}
|
|
|
|
|
|
|
|
func userAdd(c *cli.Context) error {
|
|
|
|
login := c.Args().First()
|
|
|
|
|
|
|
|
client, err := internal.NewClient(c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
user, err := client.UserPost(&drone.User{Login: login})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
fmt.Printf("Successfully added user %s\n", user.Login)
|
|
|
|
return nil
|
|
|
|
}
|