-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
144 lines (138 loc) · 3.62 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package main
import (
_ "embed"
"fmt"
"os"
"time"
"github.com/barelyhuman/commitlog/v3/commands"
"github.com/urfave/cli/v2"
)
//go:embed .commitlog.release
var version string
func main() {
app := &cli.App{
Name: "commitlog",
Usage: "commits to changelogs",
CommandNotFound: cli.ShowCommandCompletions,
Action: func(c *cli.Context) error {
fmt.Println(
"[commitlog] we no longer support direct invocation, please use the subcommand `generate` to generate a log or `release` to manage your .commitlog.release",
)
return nil
},
Version: version,
Compiled: time.Now(),
HideVersion: false,
Commands: []*cli.Command{
{
Name: "generate",
Aliases: []string{"g"},
Usage: "commits to changelogs",
Action: func(c *cli.Context) error {
return commands.Commitlog(c)
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Value: ".",
Aliases: []string{"p"},
Usage: "root with the '.git' folder `PATH`",
},
&cli.BoolFlag{
Name: "promo",
Usage: "add promo text to the end of output",
},
&cli.StringFlag{
Name: "out",
Aliases: []string{"o"},
Usage: "path to the output `FILE`",
},
&cli.BoolFlag{
Name: "stdio",
Value: true,
Usage: "print to the stdout",
},
&cli.StringFlag{
Name: "categories",
Value: "",
Usage: "categories to use, includes all commits by default. any text you add here will be used to create categories out of the commits",
},
&cli.StringFlag{
Name: "start",
Aliases: []string{"s"},
Usage: "`START` reference for the commit to include commits from," +
"This is inclusive of the given commit reference",
},
&cli.StringFlag{
Name: "end",
Aliases: []string{"e"},
Usage: "`END` reference for the commit to stop including commits at." +
"This is exclusive of the given commit reference",
},
},
},
{
Name: "release",
Aliases: []string{"r"},
Usage: "manage .commitlog.release version",
Action: func(c *cli.Context) error {
return commands.Release(c)
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "init",
Value: false,
Usage: "initialise commitlog release",
},
&cli.StringFlag{
Name: "path",
Value: ".",
Aliases: []string{"p"},
Usage: "`PATH` to a folder where .commitlog.release exists or is to be created." +
"(note: do not use `--commit` or `--push` if the file isn't in the root)",
},
&cli.BoolFlag{
Name: "pre",
Value: false,
Usage: "create a pre-release version. will default to patch increment unless" +
"specified and not already a pre-release",
},
&cli.StringFlag{
Name: "pre-tag",
Value: "beta",
Usage: "create a pre-release version",
},
&cli.BoolFlag{
Name: "major",
Value: false,
Usage: "create a major version",
},
&cli.BoolFlag{
Name: "minor",
Value: false,
Usage: "create a minor version",
},
&cli.BoolFlag{
Name: "patch",
Value: false,
Usage: "create a patch version",
},
&cli.BoolFlag{
Name: "commit",
Value: false,
Usage: "if true will create a commit and tag, of the changed version",
},
&cli.BoolFlag{
Name: "push",
Value: false,
Usage: "if true will create push the created release commit + tag on origin",
},
},
},
},
}
err := app.Run(os.Args)
if err != nil {
fmt.Fprintf(os.Stderr, "[commitlog] %v", err)
}
}