Example #1
0
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)
}
Example #2
0
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)
}
Example #3
0
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)
}
Example #4
0
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)
}
Example #5
0
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)
}
Example #6
0
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)
}
Example #7
0
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)
}
Example #8
0
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)
}
Example #9
0
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)
}
Example #10
0
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)
}
Example #11
0
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)
}