package main

import (
	"Study/pkg/github"
	"html/template"
	"log"
	"os"
)

var IssueList = template.Must(template.New("issuelist").Parse(`
<h1>{{.TotalCount}} issues</h1>
<table>
<tr style='text-align: left'>
  <th>#</th>
  <th>State</th>
  <th>User</th>
  <th>Title</th>
</tr>
{{range .Items}}
<tr>
  <td><a href='{{.HTMLURL}}'>{{.Number}}</a></td>
  <td>{{.State}}</td>
  <td><a href='{{.User.HTMLURL}}'>{{.User.Login}}</a></td>
  <td><a href='{{.HTMLURL}}'>{{.Title}}</a></td>
</tr>
{{end}}
</table>
`))

func main() {
	res, err := github.SearchIssues([]string{"repo:golang/go", "3133", "10535"})
	if err != nil {
		log.Fatal(err)
	}
	//if err := report.ExecuteTemplate(os.Stdout, "temple", res); err != nil {
	if err := IssueList.Execute(os.Stdout, res); err != nil {
		log.Fatal(err)
	}

}
