1
0
mirror of https://github.com/drone/drone-cli.git synced 2024-11-26 14:13:47 +01:00
drone-cli/drone/autoscale/autoscale_version.go

47 lines
860 B
Go
Raw Permalink Normal View History

2018-03-01 20:23:03 +01:00
package autoscale
import (
"os"
"text/template"
"github.com/drone/drone-cli/drone/internal"
"github.com/drone/funcmap"
"github.com/urfave/cli"
2018-03-01 20:23:03 +01:00
)
var autoscaleVersionCmd = cli.Command{
Name: "version",
Usage: "server version",
Action: autoscaleVersion,
Flags: []cli.Flag{
cli.StringFlag{
2019-07-18 23:43:42 +02:00
Name: "format",
Usage: "format output",
Value: tmplAutoscaleVersion,
2018-03-01 20:23:03 +01:00
},
},
}
func autoscaleVersion(c *cli.Context) error {
client, err := internal.NewAutoscaleClient(c)
if err != nil {
return err
}
version, err := client.AutoscaleVersion()
if err != nil {
return err
}
tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format") + "\n")
2018-03-01 20:23:03 +01:00
if err != nil {
return err
}
return tmpl.Execute(os.Stdout, version)
}
var tmplAutoscaleVersion = `Version: {{ .Version }}
Commit: {{ .Commit }}
Source: {{ .Source }}
`