forked from lizzyaustad/find-issues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (35 loc) · 921 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/ghc-tdd/find-issues/issues"
flags "github.com/jessevdk/go-flags"
)
type opts struct {
// Creator string `long:"creator" description:"Filter issues based on their creator."`
Label string `long:"label" description:"Filter issues based on their labels."`
}
func main() {
var options opts
parser := flags.NewParser(&options, flags.HelpFlag|flags.PrintErrors)
remainingArgs, err := parser.ParseArgs(os.Args)
if err != nil {
log.Fatal(err)
}
var repo string
if len(remainingArgs) == 0 {
log.Fatal("Missing repo. Pass in something like `ghc-tdd/find-issues`!")
}
repo = remainingArgs[1]
httpClient := &http.Client{}
service := issues.NewService(repo, httpClient)
issues, err := service.Get(options.Label)
if err != nil {
log.Fatal(err)
}
for _, issue := range issues {
fmt.Printf("#%d: %s\n", issue.Number, issue.Title)
}
}