0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-24 13:10:39 +00:00
wp-plugin-go/urfave/calver.go
2022-05-29 13:41:22 +02:00

75 lines
1.6 KiB
Go

// Copyright (c) 2020, the Drone Plugins project authors.
package urfave
import (
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
"github.com/urfave/cli/v2"
)
// calVerFlags has the cli.Flags for the drone.CalVer.
func calVerFlags(category string) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "calver.version",
Usage: "calver version",
EnvVars: []string{
"DRONE_CALVER",
},
Category: category,
},
&cli.StringFlag{
Name: "calver.major",
Usage: "calver major",
EnvVars: []string{
"DRONE_CALVER_MAJOR",
},
Category: category,
},
&cli.StringFlag{
Name: "calver.minor",
Usage: "calver minor",
EnvVars: []string{
"DRONE_CALVER_MINOR",
},
Category: category,
},
&cli.StringFlag{
Name: "calver.micro",
Usage: "calver micro",
EnvVars: []string{
"DRONE_CALVER_MICRO",
},
Category: category,
},
&cli.StringFlag{
Name: "calver.modifier",
Usage: "calver modifier",
EnvVars: []string{
"DRONE_CALVER_MODIFIER",
},
Category: category,
},
&cli.StringFlag{
Name: "calver.short",
Usage: "calver short",
EnvVars: []string{
"DRONE_CALVER_SHORT",
},
Category: category,
},
}
}
// 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"),
}
}