示例#1
0
文件: issues.go 项目: seikichi/gopl
func create(client *github.Client, args []string) {
	fs := flag.NewFlagSet("edit", flag.ExitOnError)
	fs.Usage = func() {
		fmt.Print(`Usage issues create <owner>/<repo> [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)
	fs.Parse(args)

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

	issue, err := client.CreateIssue(owner, repo, &github.IssueCreateParams{
		Title: title,
		Body:  body,
	})
	if err != nil {
		log.Fatal(err)
	}
	printIssue(issue)
}