1
0
forked from x/ContextOS
Change-Id: Ibdf18e3160efac9d3a1ae5554cbe551b46615f4d
This commit is contained in:
shaoying 2019-02-15 00:08:24 +08:00
parent bdc46d5869
commit f6f959c3c2

View File

@ -194,7 +194,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
}},
"system": &ctx.Command{Name: "system word...", Help: []string{"调用系统命令, word: 命令",
"cmd_active(true/false): 是否交互", "cmd_timeout: 命令超时", "cmd_env: 环境变量", "cmd_dir: 工作目录"},
Form: map[string]int{"cmd_active": 1, "cmd_timeout": 1, "cmd_env": 2, "cmd_dir": 1, "cmd_error": 0, "cmd_parse": 1},
Form: map[string]int{"cmd_active": 1, "cmd_timeout": 1, "cmd_env": 2, "cmd_dir": 1, "cmd_error": 0, "cmd_parse": 1, "cmd_temp": -1},
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
for _, v := range m.Meta["result"] {
if strings.TrimSpace(v) != "" {
@ -261,6 +261,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
if e := cmd.Run(); e != nil {
m.Echo("error: ").Echo("%s\n", e).Echo(err.String())
} else {
if m.Options("cmd_temp") {
m.Put("option", "data", out.String()).Cmdy("mdb.temp", "script", strings.Join(arg, " "), "data", "data", m.Meta["cmd_temp"])
} else {
switch m.Option("cmd_parse") {
case "json":
var data interface{}
@ -284,6 +288,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
m.Echo(out.String())
}
}
}
wait <- true
})