mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 10:21:00 +00:00
31 lines
604 B
Go
31 lines
604 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/codegangsta/cli"
|
|
"github.com/drone/drone/client"
|
|
)
|
|
|
|
// NewWhoamiCommand returns the CLI command for "whoami".
|
|
func NewWhoamiCommand() cli.Command {
|
|
return cli.Command{
|
|
Name: "whoami",
|
|
Usage: "outputs the current user",
|
|
Flags: []cli.Flag{},
|
|
Action: func(c *cli.Context) {
|
|
handle(c, whoamiCommandFunc)
|
|
},
|
|
}
|
|
}
|
|
|
|
// whoamiCommandFunc executes the "logout" command.
|
|
func whoamiCommandFunc(c *cli.Context, client *client.Client) error {
|
|
user, err := client.Users.GetCurrent()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println(user.Login)
|
|
return nil
|
|
}
|