1
0
forked from x/ContextOS

add version

This commit is contained in:
shaoying 2019-06-27 09:54:48 +08:00
parent 6ead3cbfe4
commit b7eabdcbcc

View File

@ -8,6 +8,7 @@ import (
"os/exec" "os/exec"
"os/user" "os/user"
"path" "path"
"reflect"
"toolkit" "toolkit"
"fmt" "fmt"
@ -658,9 +659,17 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
return return
}}, }},
"version": &ctx.Command{Name: "version", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { "version": &ctx.Command{Name: "version", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) { if len(arg) == 0 {
m.Append("time", version.time) types := reflect.TypeOf(version)
m.Append("host", version.host) value := reflect.ValueOf(version)
for i := 0; i < types.NumField(); i++ {
key := types.Field(i)
val := value.Field(i)
m.Add("append", "name", key.Name)
m.Add("append", "type", key.Type.Name())
m.Add("append", "value", fmt.Sprintf("%v", val))
}
m.Table() m.Table()
return return
} }
@ -668,10 +677,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
var version = struct { var version = struct {
time string time string
host string host string
self int
}{ }{
"%s", "%s", "%s", "%s", %d,
} }
`, m.Time(), m.Conf("runtime", "node.route"))) `, m.Time(), m.Conf("runtime", "node.route"), version.self+1))
return return
}}, }},