-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (51 loc) · 1.22 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
package main
import (
"fmt"
"os"
"github.com/AlecAivazis/survey/v2"
"github.com/cli/go-gh"
)
func _main() error {
var org = ""
var err = survey.AskOne(&survey.Input{
Message: "Enter the name of the org you want to revoke access to:",
}, &org)
if err != nil {
return err
} else if org == "" {
return fmt.Errorf("org cannot be empty")
}
appId := ""
err = survey.AskOne(&survey.Password{
Message: "Enter the github personal access token to be revoked:",
}, &appId)
if err != nil {
return err
} else if appId == "" {
return fmt.Errorf("appId cannot be empty")
}
return nil
}
type AppInstallation struct {
ID int `json:"id"`
AppID int `json:"app_id"`
AppSlug string `json:"app_slug"`
}
func getAppInstllations(org string) error {
client, err := gh.RESTClient(nil)
response := []AppInstallation{}
client.Get(fmt.Sprintf("orgs/%s/installations", org), &response)
if err != nil {
return fmt.Errorf("failed to create client: %w", err)
}
// print response
fmt.Println(response)
return nil
}
func main() {
if err := _main(); err != nil {
fmt.Fprintf(os.Stderr, "X %s", err.Error())
}
}
// For more examples of using go-gh, see:
// https://github.com/cli/go-gh/blob/trunk/example_gh_test.go