Ejemplo n.º 1
0
func edit(client *github.Client, args []string) {
	fs := flag.NewFlagSet("edit", flag.ExitOnError)
	fs.Usage = func() {
		fmt.Print(`Usage issues edit <owner>/<repo> <number> [options]

Options:
  --title
  --body (set EDITOR if you want to use editor)
`)
	}

	var title, body string
	fs.StringVar(&title, "t", "", "title")
	fs.StringVar(&title, "title", "", "title")
	fs.StringVar(&body, "b", "", "body")
	fs.StringVar(&body, "body", "", "body")

	owner, repo, args := getOwnerAndRepo(fs, args)
	number, args := getNumber(fs, args)
	fs.Parse(args)

	if body == "EDITOR" {
		body = getStringByEditor()
	}

	issue, err := client.EditIssue(owner, repo, number, &github.IssueEditParams{
		Title: title,
		Body:  body,
	})
	if err != nil {
		log.Fatal(err)
	}
	printIssue(issue)
}
Ejemplo n.º 2
0
func search(client *github.Client, args []string) {
	fs := flag.NewFlagSet("search", flag.ExitOnError)
	fs.Usage = func() {
		fmt.Println(`Usage issues search <owner>/<repo>`)
	}
	owner, repo, args := getOwnerAndRepo(fs, args)
	issues, err := client.SearchIssues(owner, repo)
	if err != nil {
		log.Fatal(err)
	}
	printIssueList(issues)
}
Ejemplo n.º 3
0
func reopen(client *github.Client, args []string) {
	fs := flag.NewFlagSet("close", flag.ExitOnError)
	fs.Usage = func() {
		fmt.Println(`Usage issues reopen <owner>/<repo> <number>`)
	}
	owner, repo, args := getOwnerAndRepo(fs, args)
	number, args := getNumber(fs, args)
	issue, err := client.EditIssue(owner, repo, number, &github.IssueEditParams{State: "open"})
	if err != nil {
		log.Fatal(err)
	}
	printIssue(issue)
}
Ejemplo n.º 4
0
func show(client *github.Client, args []string) {
	fs := flag.NewFlagSet("show", flag.ExitOnError)
	fs.Usage = func() {
		fmt.Println(`Usage issues show <owner>/<repo> <number>`)
	}
	owner, repo, args := getOwnerAndRepo(fs, args)
	number, args := getNumber(fs, args)
	issue, err := client.GetIssue(owner, repo, number)
	if err != nil {
		log.Fatal(err)
	}
	printIssue(issue)
}