MCPcopy
hub / github.com/cli/cli / CurrentLoginNameAndOrgs

Function CurrentLoginNameAndOrgs

api/queries_user.go:17–35  ·  view source on GitHub ↗
(client *Client, hostname string)

Source from the content-addressed store, hash-verified

15}
16
17func CurrentLoginNameAndOrgs(client *Client, hostname string) (string, []string, error) {
18 var query struct {
19 Viewer struct {
20 Login string
21 Organizations struct {
22 Nodes []Organization
23 } `graphql:"organizations(first: 100)"`
24 }
25 }
26 err := client.Query(hostname, "UserCurrent", &query, nil)
27 if err != nil {
28 return "", nil, err
29 }
30 orgNames := []string{}
31 for _, org := range query.Viewer.Organizations.Nodes {
32 orgNames = append(orgNames, org.Login)
33 }
34 return query.Viewer.Login, orgNames, nil
35}
36
37func CurrentUserID(client *Client, hostname string) (string, error) {
38 var query struct {

Callers 1

userAndOrgsFunction · 0.92

Calls 1

QueryMethod · 0.65

Tested by

no test coverage detected