-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
68 lines (55 loc) · 1.21 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"github.com/google/go-github/github"
)
func main() {
username := ""
pat := ""
flag.StringVar(&username, "u", "", "github user name for backing item store")
flag.StringVar(&pat, "p", "", "PAT for github user")
flag.Parse()
if pat == "" || username == "" {
return
}
bat := github.BasicAuthTransport{username, pat, "", nil}
client := github.NewClient(bat.Client())
// ([]Membership, *Response, error)
memberships, _, err := client.Organizations.ListOrgMemberships(nil)
if err != nil {
log.Fatal(err)
}
fmt.Println("Memberships:")
for _, m := range memberships {
st := "<unset>"
if m.State != nil {
st = *m.State
}
rl := "<unset>"
if m.Role != nil {
rl = *m.Role
}
/*
ttl := "<?>"
switch {
case m.Organization.Name != nil:
ttl = *m.Organization.Name
case m.Organization.Company != nil:
ttl = "company - " + *m.Organization.Company
}
*/
// (*User, *Response, error)
u, _, e := client.Users.Get(*m.Organization.Login)
if e != nil {
log.Fatal(e)
}
b, e := json.MarshalIndent(u, " ", " ")
if e != nil {
log.Fatal(e)
}
fmt.Printf(" %s - %s:\n %s\n", st, rl, string(b))
}
}