drone-plugin-lib/urfave/calver.go

75 lines
1.6 KiB
Go
Raw Normal View History

2020-09-11 13:36:36 +00:00
// Copyright (c) 2020, the Drone Plugins project authors.
package urfave
import (
2022-05-03 20:03:37 +00:00
"github.com/thegeeklab/drone-plugin-lib/drone"
2020-09-11 13:36:36 +00:00
"github.com/urfave/cli/v2"
)
// calVerFlags has the cli.Flags for the drone.CalVer.
2022-05-29 11:15:31 +00:00
func calVerFlags(category string) []cli.Flag {
2020-09-11 13:36:36 +00:00
return []cli.Flag{
&cli.StringFlag{
Name: "calver.version",
Usage: "calver version",
EnvVars: []string{
"DRONE_CALVER",
},
2022-05-29 11:15:31 +00:00
Category: category,
2020-09-11 13:36:36 +00:00
},
&cli.StringFlag{
Name: "calver.major",
Usage: "calver major",
EnvVars: []string{
"DRONE_CALVER_MAJOR",
},
2022-05-29 11:15:31 +00:00
Category: category,
2020-09-11 13:36:36 +00:00
},
&cli.StringFlag{
Name: "calver.minor",
Usage: "calver minor",
EnvVars: []string{
"DRONE_CALVER_MINOR",
},
2022-05-29 11:15:31 +00:00
Category: category,
2020-09-11 13:36:36 +00:00
},
&cli.StringFlag{
Name: "calver.micro",
Usage: "calver micro",
EnvVars: []string{
"DRONE_CALVER_MICRO",
},
2022-05-29 11:15:31 +00:00
Category: category,
2020-09-11 13:36:36 +00:00
},
&cli.StringFlag{
Name: "calver.modifier",
Usage: "calver modifier",
EnvVars: []string{
"DRONE_CALVER_MODIFIER",
},
2022-05-29 11:15:31 +00:00
Category: category,
2020-09-11 13:36:36 +00:00
},
&cli.StringFlag{
Name: "calver.short",
Usage: "calver short",
EnvVars: []string{
"DRONE_CALVER_SHORT",
},
2022-05-29 11:15:31 +00:00
Category: category,
2020-09-11 13:36:36 +00:00
},
}
}
// calVerFromContext creates a drone.CalVer from the cli.Context.
func calVerFromContext(ctx *cli.Context) drone.CalVer {
return drone.CalVer{
Version: ctx.String("calver.version"),
Major: ctx.String("calver.major"),
Minor: ctx.String("calver.minor"),
Micro: ctx.String("calver.micro"),
Modifier: ctx.String("calver.modifier"),
Short: ctx.String("calver.short"),
}
}