forked from plouc/go-gitlab-client
/
get_user.go
44 lines (35 loc) · 865 Bytes
/
get_user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package cmd
import (
"github.com/fatih/color"
out "github.com/plouc/go-gitlab-client/cli/output"
"github.com/spf13/cobra"
)
func init() {
getCmd.AddCommand(getUserCmd)
}
var getUserCmd = &cobra.Command{
Use: resourceCmd("user", "user"),
Aliases: []string{"u"},
Short: "Get a single user",
RunE: func(cmd *cobra.Command, args []string) error {
ids, err := config.aliasIdsOrArgs(currentAlias, "user", args)
if err != nil {
return err
}
color.Yellow("Fetching user (id: %s)…", ids["user_id"])
loader.Start()
user, meta, err := client.User(ids["user_id"])
loader.Stop()
if err != nil {
return err
}
out.User(output, outputFormat, user)
printMeta(meta, false)
relatedCommands([]*relatedCommand{
newRelatedCommand(lsUserSshKeysCmd, map[string]string{
"user_id": ids["user_id"],
}),
})
return nil
},
}