mirror of
https://github.com/luscis/openlan.git
synced 2025-12-24 11:10:54 +08:00
clone from danieldin95
This commit is contained in:
40
cmd/api/v5/version.go
Executable file
40
cmd/api/v5/version.go
Executable file
@@ -0,0 +1,40 @@
|
||||
package v5
|
||||
|
||||
import (
|
||||
"github.com/luscis/openlan/cmd/api"
|
||||
"github.com/luscis/openlan/pkg/schema"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
type Version struct {
|
||||
Cmd
|
||||
}
|
||||
|
||||
func (v Version) Url(prefix, name string) string {
|
||||
return prefix + "/api/version"
|
||||
}
|
||||
|
||||
func (v Version) Tmpl() string {
|
||||
return `Version : {{ .Version }}
|
||||
Build at: {{ .Date}}
|
||||
`
|
||||
}
|
||||
|
||||
func (v Version) List(c *cli.Context) error {
|
||||
url := v.Url(c.String("url"), "")
|
||||
clt := v.NewHttp(c.String("token"))
|
||||
var item schema.Version
|
||||
if err := clt.GetJSON(url, &item); err != nil {
|
||||
return err
|
||||
}
|
||||
return v.Out(item, c.String("format"), v.Tmpl())
|
||||
}
|
||||
|
||||
func (v Version) Commands(app *api.App) {
|
||||
app.Command(&cli.Command{
|
||||
Name: "version",
|
||||
Aliases: []string{"v"},
|
||||
Usage: "show version information",
|
||||
Action: v.List,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user