2016-05-06 17:59:36 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/drone/drone/model"
|
2017-03-16 10:14:02 +00:00
|
|
|
"github.com/urfave/cli"
|
2016-05-06 17:59:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var userAddCmd = cli.Command{
|
2017-03-16 10:14:02 +00:00
|
|
|
Name: "add",
|
|
|
|
Usage: "adds a user",
|
|
|
|
Action: userAdd,
|
2016-05-06 17:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func userAdd(c *cli.Context) error {
|
|
|
|
login := c.Args().First()
|
|
|
|
|
|
|
|
client, err := newClient(c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
user, err := client.UserPost(&model.User{Login: login})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
fmt.Printf("Successfully added user %s\n", user.Login)
|
|
|
|
return nil
|
|
|
|
}
|