mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
add m.Goshy
This commit is contained in:
parent
d8c56f8eba
commit
081dfe0795
@ -331,12 +331,12 @@ func main() {
|
|||||||
for i := 0; i < len(m.Meta["cmd_env"])-1; i += 2 {
|
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])))
|
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 {
|
if len(cmd.Env) > 0 {
|
||||||
m.Log("info", "env %v", cmd.Env)
|
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"]) {
|
if m.Options("cmd_active") || kit.Right(conf["active"]) {
|
||||||
@ -810,7 +810,7 @@ func main() {
|
|||||||
case "plugin":
|
case "plugin":
|
||||||
arg = arg[1:]
|
arg = arg[1:]
|
||||||
if len(arg) == 0 {
|
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
|
break
|
||||||
}
|
}
|
||||||
fallthrough
|
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) {
|
"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 {
|
if len(arg) == 0 {
|
||||||
m.Option("dir_root", "")
|
m.Option("dir_root", "")
|
||||||
m.Cmd("nfs.dir", m.Conf("missyou", "path")).Table(func(value map[string]string) {
|
m.Cmd("nfs.dir", m.Conf("missyou", "path"), "time", "name").Table(func(value map[string]string) {
|
||||||
name := strings.TrimSuffix(value["filename"], "/")
|
name := strings.TrimSuffix(value["name"], "/")
|
||||||
m.Add("append", "create_time", value["time"])
|
m.Add("append", "create_time", value["time"])
|
||||||
m.Add("append", "you", name)
|
m.Add("append", "you", name)
|
||||||
if m.Confs("nfs.node", name) {
|
if m.Confs("nfs.node", name) {
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-07-24 09:10:27", "com.mac_14", 216,
|
"2019-07-24 17:59:29", "ZYB-20190522USI", 242,
|
||||||
}
|
}
|
||||||
|
@ -404,3 +404,34 @@ func (m *Message) Free(cbs ...func(msg *Message) (done bool)) *Message {
|
|||||||
m.freeback = append(m.freeback, cbs...)
|
m.freeback = append(m.freeback, cbs...)
|
||||||
return m
|
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
|
||||||
|
}
|
||||||
|
@ -78,12 +78,14 @@ func dir(m *ctx.Message, root string, name string, level int, deep bool, dir_typ
|
|||||||
} else {
|
} else {
|
||||||
m.Add("append", "path", path.Join(name, f.Name()))
|
m.Add("append", "path", path.Join(name, f.Name()))
|
||||||
}
|
}
|
||||||
case "name":
|
case "file":
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
m.Add("append", "name", f.Name()+"/")
|
m.Add("append", "name", f.Name()+"/")
|
||||||
} else {
|
} else {
|
||||||
m.Add("append", "name", f.Name())
|
m.Add("append", "name", f.Name())
|
||||||
}
|
}
|
||||||
|
case "name":
|
||||||
|
m.Add("append", "name", f.Name())
|
||||||
case "tree":
|
case "tree":
|
||||||
if level == 0 {
|
if level == 0 {
|
||||||
m.Add("append", "tree", f.Name())
|
m.Add("append", "tree", f.Name())
|
||||||
|
@ -134,7 +134,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
map[string]interface{}{"type": "text", "name": "who"},
|
map[string]interface{}{"type": "text", "name": "who"},
|
||||||
map[string]interface{}{"type": "button", "value": "执行"},
|
map[string]interface{}{"type": "button", "value": "执行"},
|
||||||
},
|
},
|
||||||
"exports": []interface{}{"see", "filename", "see"},
|
"exports": []interface{}{"see", "name", "see"},
|
||||||
},
|
},
|
||||||
map[string]interface{}{"componet_name": "compile", "componet_help": "编译",
|
map[string]interface{}{"componet_name": "compile", "componet_help": "编译",
|
||||||
"componet_tmpl": "componet", "componet_view": "componet", "componet_init": "",
|
"componet_tmpl": "componet", "componet_view": "componet", "componet_init": "",
|
||||||
|
@ -1034,33 +1034,8 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
|
|
||||||
self := &ctx.Command{Name: strings.Join(arg[1:], " "), Help: []string{"pwd", "ls"}}
|
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) {
|
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)
|
|
||||||
|
|
||||||
// 解析数据
|
m.Goshy(self.Help.([]string), 0, nil)
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Target().Commands[arg[1]] = self
|
m.Target().Commands[arg[1]] = self
|
||||||
|
Loading…
x
Reference in New Issue
Block a user