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"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logrus.SetFormatter(new(formatter))
|
||||
|
||||
var args plugin.Args
|
||||
|
||||
func init() {
|
||||
if err := envconfig.Process("", &args); err != nil {
|
||||
logrus.Fatalln(err)
|
||||
}
|
||||
|
||||
flag.StringVar(&args.TitleFormat, "title-format", "", "Format to use for the release title")
|
||||
flag.StringVar(&args.TagFile, "tag-file", "", "File to check for tag to release")
|
||||
flag.StringVar(&args.TagRegex, "tag-regex", "", "Regex pattern to look for tag in tag-file")
|
||||
flag.StringVar(&args.Notes, "notes", "", "Notes to use in release")
|
||||
flag.StringVar(&args.NotesFile, "notes-file", "", "File to use for release notes")
|
||||
var (
|
||||
titleFormat *string = flag.String("title-format", "", "Format to use for the release title")
|
||||
tagFile *string = flag.String("tag-file", "", "File to check for tag to release")
|
||||
tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file")
|
||||
notes *string = flag.String("notes", "", "Notes to use in release")
|
||||
notesFile *string = flag.String("notes-file", "", "File to use for release notes")
|
||||
)
|
||||
|
||||
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 {
|
||||
case "debug":
|
||||
logrus.SetFormatter(textFormatter)
|
||||
|
Loading…
Reference in New Issue
Block a user