1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

add m.Goshy

This commit is contained in:
shaoying 2019-07-24 21:09:42 +08:00
parent d8c56f8eba
commit 081dfe0795
7 changed files with 43 additions and 35 deletions

View File

@ -331,12 +331,12 @@ func main() {
for i := 0; i < len(m.Meta["cmd_env"])-1; i += 2 {
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", m.Meta["cmd_env"][i], m.Parse(m.Meta["cmd_env"][i+1])))
}
for _, k := range []string{"PATH", "HOME"} {
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, os.Getenv(k)))
}
if len(cmd.Env) > 0 {
m.Log("info", "env %v", cmd.Env)
}
for _, k := range []string{"PATH", "HOME"} {
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, os.Getenv(k)))
}
// 交互命令
if m.Options("cmd_active") || kit.Right(conf["active"]) {
@ -810,7 +810,7 @@ func main() {
case "plugin":
arg = arg[1:]
if len(arg) == 0 {
m.Cmdy("nfs.dir", m.Conf("project", "plugin.path"))
m.Cmdy("nfs.dir", m.Conf("project", "plugin.path"), "time", "line", "name")
break
}
fallthrough
@ -1035,8 +1035,8 @@ func main() {
"missyou": &ctx.Command{Name: "missyou [name [stop]]", Help: "任务管理", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) == 0 {
m.Option("dir_root", "")
m.Cmd("nfs.dir", m.Conf("missyou", "path")).Table(func(value map[string]string) {
name := strings.TrimSuffix(value["filename"], "/")
m.Cmd("nfs.dir", m.Conf("missyou", "path"), "time", "name").Table(func(value map[string]string) {
name := strings.TrimSuffix(value["name"], "/")
m.Add("append", "create_time", value["time"])
m.Add("append", "you", name)
if m.Confs("nfs.node", name) {

View File

@ -4,5 +4,5 @@ var version = struct {
host string
self int
}{
"2019-07-24 09:10:27", "com.mac_14", 216,
"2019-07-24 17:59:29", "ZYB-20190522USI", 242,
}

View File

@ -404,3 +404,34 @@ func (m *Message) Free(cbs ...func(msg *Message) (done bool)) *Message {
m.freeback = append(m.freeback, cbs...)
return m
}
func (m *Message) Goshy(input []string, index int, stack *kit.Stack) *kit.Stack {
if stack == nil {
stack = &kit.Stack{}
stack.Push("source", true, 0)
}
m.Optionv("bio.stack", stack)
m.Optionv("bio.input", input)
for i := index; i < len(input); i++ {
line := input[i]
m.Optioni("stack.pos", i)
// 执行语句
msg := m.Cmd("yac.parse", line+"\n")
// 跳转语句
if msg.Appends("bio.pos0") {
i = int(msg.Appendi("bio.pos0")) - 1
msg.Append("bio.pos0", "")
}
// 结束脚本
if msg.Appends("bio.end") {
m.Copy(msg, "append").Copy(msg, "result")
msg.Appends("bio.end", "")
break
}
}
return stack
}

View File

@ -78,12 +78,14 @@ func dir(m *ctx.Message, root string, name string, level int, deep bool, dir_typ
} else {
m.Add("append", "path", path.Join(name, f.Name()))
}
case "name":
case "file":
if f.IsDir() {
m.Add("append", "name", f.Name()+"/")
} else {
m.Add("append", "name", f.Name())
}
case "name":
m.Add("append", "name", f.Name())
case "tree":
if level == 0 {
m.Add("append", "tree", f.Name())

View File

@ -134,7 +134,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "text", "name": "who"},
map[string]interface{}{"type": "button", "value": "执行"},
},
"exports": []interface{}{"see", "filename", "see"},
"exports": []interface{}{"see", "name", "see"},
},
map[string]interface{}{"componet_name": "compile", "componet_help": "编译",
"componet_tmpl": "componet", "componet_view": "componet", "componet_init": "",

View File

@ -1034,33 +1034,8 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
self := &ctx.Command{Name: strings.Join(arg[1:], " "), Help: []string{"pwd", "ls"}}
self.Hand = func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
stack := &kit.Stack{}
stack.Push("fun", true, 0)
m.Optionv("bio.stack", stack)
help := self.Help.([]string)
// 解析数据
for i := 0; i < len(help); i++ {
line := help[i]
m.Optioni("stack.pos", i)
// 执行语句
msg := m.Cmd("yac.parse", line+"\n")
// 跳转语句
if msg.Appends("bio.pos0") {
i = int(msg.Appendi("bio.pos0")) - 1
msg.Append("bio.pos0", "")
}
// 结束脚本
if msg.Appends("bio.end") {
m.Copy(msg, "append")
m.Copy(msg, "result")
msg.Appends("bio.end", "")
break
}
}
m.Goshy(self.Help.([]string), 0, nil)
return
}
m.Target().Commands[arg[1]] = self