Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}