forked from plouc/go-gitlab-client
/
get_group.go
51 lines (40 loc) · 1.17 KB
/
get_group.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
45
46
47
48
49
50
51
package cmd
import (
"github.com/fatih/color"
out "github.com/plouc/go-gitlab-client/cli/output"
"github.com/spf13/cobra"
)
var groupWithCustomAttributes bool
func init() {
getCmd.AddCommand(getGroupCmd)
getGroupCmd.Flags().BoolVarP(&groupWithCustomAttributes, "with-custom-attributes", "x", false, "Include custom attributes (admins only)")
}
var getGroupCmd = &cobra.Command{
Use: resourceCmd("group", "group"),
Aliases: []string{"g"},
Short: "Get all details of a group",
RunE: func(cmd *cobra.Command, args []string) error {
ids, err := config.aliasIdsOrArgs(currentAlias, "group", args)
if err != nil {
return err
}
color.Yellow("Fetching group (id: %s)…", ids["group_id"])
loader.Start()
group, meta, err := client.Group(ids["group_id"], groupWithCustomAttributes)
loader.Stop()
if err != nil {
return err
}
out.Group(output, outputFormat, group)
printMeta(meta, false)
relatedCommands([]*relatedCommand{
newRelatedCommand(lsGroupMergeRequestsCmd, map[string]string{
"group_id": ids["group_id"],
}),
newRelatedCommand(lsGroupVariablesCmd, map[string]string{
"group_id": ids["group_id"],
}),
})
return nil
},
}