-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (49 loc) · 1.05 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"flag"
"log"
"os"
"github.com/corani/gotodo/format"
"github.com/corani/gotodo/glob"
"github.com/corani/gotodo/gotodo"
"github.com/corani/gotodo/parser"
)
func main() {
configFile := flag.String("config", "", "Path to config file")
flag.Parse()
if *configFile == "" {
flag.Usage()
return
}
config, err := gotodo.LoadConfig(*configFile)
if err != nil {
log.Fatal(err)
}
paths := glob.Glob(config)
var comments []gotodo.Comment
for _, path := range paths {
// TODO(daniel) Support other languages besides go?
p := parser.NewParserFor(parser.GoLang)
c, err := p.Parse(config, path)
if err != nil {
log.Fatalf("%v", err)
}
comments = append(comments, c...)
}
comments = config.FilterByAssignee(comments)
formatter := format.NewFormatter(config)
formatter.Format(comments)
// TODO(daniel) Make the return code configurable based on the pattern?
rc := 0
loop:
for _, comment := range comments {
switch comment.Type {
case "TODO":
rc = 1
case "FIXME":
rc = 2
break loop
}
}
os.Exit(rc)
}