func getRepoIssues(c *cli.Context) { owner, repo, err := util.SplitOrgRepoName(c.Args().Get(0)) if err != nil { log.Fatal(err) } opts := &github.IssueListByRepoOptions{ ListOptions: github.ListOptions{PerPage: 30}, } issues, _, err := gh.Client.Issues.ListByRepo(owner, repo, opts) if err != nil { fmt.Println(err) } if len(issues) == 0 { fmt.Println("No issues found") } // PRs are considered issues. Remove all PRs from issue array. for index, issue := range issues { if issue.PullRequestLinks != nil { issues = append(issues[:index], issues[index+1:]...) } } util.PrintJson(issues) }
func getUser(c *cli.Context) { u := c.Args().First() user, _, err := gh.Client.Users.Get(u) if err != nil { fmt.Println(err) } util.PrintJson(user) }
func getOrg(c *cli.Context) { org := c.Args().First() organization, _, err := gh.Client.Organizations.Get(org) if err != nil { fmt.Println(err) } util.PrintJson(organization) }
func getTeam(c *cli.Context) { teamNum, _ := strconv.Atoi(c.Args().First()) team, _, err := gh.Client.Organizations.GetTeam(teamNum) if err != nil { fmt.Println(err) } util.PrintJson(team) }
func getOrgMembers(c *cli.Context) { org := c.Args().First() opts := &github.ListMembersOptions{ ListOptions: github.ListOptions{PerPage: 30}, } members, _, err := gh.Client.Organizations.ListMembers(org, opts) if err != nil { fmt.Println(err) } util.PrintJson(members) }
func getOrgRepos(c *cli.Context) { org := c.Args().First() opts := &github.RepositoryListByOrgOptions{ ListOptions: github.ListOptions{PerPage: 30}, } repos, _, err := gh.Client.Repositories.ListByOrg(org, opts) if err != nil { fmt.Println(err) } util.PrintJson(repos) }
func getRepo(c *cli.Context) { o, r, err := util.SplitOrgRepoName(c.Args().Get(0)) if err != nil { log.Fatal(err) } repo, _, err := gh.Client.Repositories.Get(o, r) if err != nil { log.Fatal(err) } util.PrintJson(*repo) }
func getOrgTeams(c *cli.Context) { org := c.Args().First() opts := &github.ListOptions{PerPage: 30} teams, _, err := gh.Client.Organizations.ListTeams(org, opts) if err != nil { fmt.Println(err) } if len(teams) == 0 { fmt.Println("No teams found") } util.PrintJson(teams) }
func getIssue(c *cli.Context) { owner, repo, err := util.SplitOrgRepoName(c.Args().Get(0)) if err != nil { log.Fatal(err) } number, _ := strconv.Atoi(c.Args().Get(1)) issue, _, err := gh.Client.Issues.Get(owner, repo, number) if err != nil { fmt.Println(err) } util.PrintJson(issue) }
func getOrgIssues(c *cli.Context) { org := c.Args().First() opts := &github.IssueListOptions{ ListOptions: github.ListOptions{PerPage: 30}, } issues, _, err := gh.Client.Issues.ListByOrg(org, opts) if err != nil { fmt.Println(err) } if len(issues) == 0 { fmt.Println("No issues found") } util.PrintJson(issues) }
func getRepoPullRequests(c *cli.Context) { owner, repo, err := util.SplitOrgRepoName(c.Args().Get(0)) if err != nil { log.Fatal(err) } opts := &github.PullRequestListOptions{ ListOptions: github.ListOptions{PerPage: 30}, } prs, _, err := gh.Client.PullRequests.List(owner, repo, opts) if err != nil { fmt.Println(err) } if len(prs) == 0 { fmt.Println("No PRs found") } util.PrintJson(prs) }