fix: 🐛 only parse flags if available
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
aa8b96b0b9
commit
2c8cdd7fcc
40
main.go
40
main.go
@ -11,23 +11,47 @@ import (
|
|||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
|
||||||
logrus.SetFormatter(new(formatter))
|
|
||||||
|
|
||||||
var args plugin.Args
|
var args plugin.Args
|
||||||
|
|
||||||
|
func init() {
|
||||||
if err := envconfig.Process("", &args); err != nil {
|
if err := envconfig.Process("", &args); err != nil {
|
||||||
logrus.Fatalln(err)
|
logrus.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.StringVar(&args.TitleFormat, "title-format", "", "Format to use for the release title")
|
var (
|
||||||
flag.StringVar(&args.TagFile, "tag-file", "", "File to check for tag to release")
|
titleFormat *string = flag.String("title-format", "", "Format to use for the release title")
|
||||||
flag.StringVar(&args.TagRegex, "tag-regex", "", "Regex pattern to look for tag in tag-file")
|
tagFile *string = flag.String("tag-file", "", "File to check for tag to release")
|
||||||
flag.StringVar(&args.Notes, "notes", "", "Notes to use in release")
|
tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file")
|
||||||
flag.StringVar(&args.NotesFile, "notes-file", "", "File to use for release notes")
|
notes *string = flag.String("notes", "", "Notes to use in release")
|
||||||
|
notesFile *string = flag.String("notes-file", "", "File to use for release notes")
|
||||||
|
)
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if titleFormat != nil && *titleFormat != "" {
|
||||||
|
args.TitleFormat = *titleFormat
|
||||||
|
}
|
||||||
|
|
||||||
|
if tagFile != nil && *tagFile != "" {
|
||||||
|
args.TagFile = *tagFile
|
||||||
|
}
|
||||||
|
|
||||||
|
if tagRegex != nil && *tagRegex != "" {
|
||||||
|
args.TagRegex = *tagRegex
|
||||||
|
}
|
||||||
|
|
||||||
|
if notes != nil && *notes != "" {
|
||||||
|
args.Notes = *notes
|
||||||
|
}
|
||||||
|
|
||||||
|
if notesFile != nil && *notesFile != "" {
|
||||||
|
args.NotesFile = *notesFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
logrus.SetFormatter(new(formatter))
|
||||||
|
|
||||||
switch args.Level {
|
switch args.Level {
|
||||||
case "debug":
|
case "debug":
|
||||||
logrus.SetFormatter(textFormatter)
|
logrus.SetFormatter(textFormatter)
|
||||||
|
Loading…
Reference in New Issue
Block a user