-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
45 lines (38 loc) · 1.25 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
package main
import (
"context"
"flag"
"fmt"
"os"
"github.com/buchanae/github-release-notes/ghrn"
)
func main() {
conf := ghrn.Config{}
flag.StringVar(&conf.Org, "org", conf.Org, "Organization. (Required)")
flag.StringVar(&conf.Repo, "repo", conf.Repo, "Repo. (Required)")
flag.IntVar(&conf.StopAt, "stop-at", conf.StopAt, "PR number to stop at")
flag.BoolVar(&conf.IncludeCommits, "include-commits", conf.IncludeCommits, "Include commit messages")
flag.BoolVar(&conf.SinceLatestRelease, "since-latest-release", conf.SinceLatestRelease, "Stop at latest release's commit")
flag.BoolVar(&conf.IncludeAuthor, "include-author", conf.IncludeAuthor, "Include author of PR in message")
flag.StringVar(&conf.GitHubToken, "github-token", "", "Github Token. (Defaults to env GITHUB_TOKEN)")
flag.Parse()
if conf.Org == "" {
flag.Usage()
fmt.Fprintln(os.Stderr, "\nError: -org is required.")
os.Exit(1)
}
if conf.Repo == "" {
flag.Usage()
fmt.Fprintln(os.Stderr, "\nError: -repo is required.")
os.Exit(1)
}
if conf.GitHubToken == "" {
conf.GitHubToken = os.Getenv("GITHUB_TOKEN")
}
ctx := context.Background()
err := ghrn.BuildReleaseNotes(ctx, os.Stdout, conf)
if err != nil {
fmt.Fprintln(os.Stderr, "Error: "+err.Error())
os.Exit(1)
}
}