-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommitlog.go
70 lines (56 loc) · 1.17 KB
/
commitlog.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
61
62
63
64
65
66
67
68
69
70
package commands
import (
"github.com/barelyhuman/commitlog/v3/pkg"
"github.com/urfave/cli/v2"
)
func Commitlog(c *cli.Context) (err error) {
path := c.String("path")
addPromo := c.Bool("promo")
out := c.String("out")
stdio := c.Bool("stdio")
startRef := c.String("start")
endRef := c.String("end")
categories := c.String("categories")
gOptions := []pkg.GeneratorConfigMod{}
if addPromo {
gOptions = append(gOptions,
pkg.WithPromo(),
)
}
// either write to a file or to the stdio with true by default
if len(out) > 0 {
gOptions = append(gOptions,
pkg.WithOutputToFile(out),
)
} else if stdio {
gOptions = append(gOptions,
pkg.WithOutputToStdio(),
)
}
if len(startRef) > 0 {
gOptions = append(gOptions,
pkg.WithStartReference(startRef),
)
}
if len(endRef) > 0 {
gOptions = append(gOptions,
pkg.WithEndReference(endRef),
)
}
if len(categories) > 0 {
gOptions = append(gOptions,
pkg.WithCategories(categories),
)
}
generator := pkg.CreateGenerator(path,
gOptions...)
err = generator.ReadCommmits()
if err != nil {
return err
}
err = generator.Classify()
if err != nil {
return err
}
return generator.Generate()
}