mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 17:24:05 +08:00
tce pro ctx
This commit is contained in:
parent
c8e8b174a1
commit
3292ce386e
@ -1,3 +1,4 @@
|
|||||||
var a = 0
|
var a = 0
|
||||||
source etc/local.shy
|
source etc/local.shy
|
||||||
~aaa login root root
|
~aaa
|
||||||
|
login root root
|
||||||
|
@ -69,6 +69,18 @@ func (cli *CLI) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
|||||||
cli.Caches["back"] = &ctx.Cache{Name: "前一条指令", Value: "", Help: "前一条指令"}
|
cli.Caches["back"] = &ctx.Cache{Name: "前一条指令", Value: "", Help: "前一条指令"}
|
||||||
cli.Caches["next"] = &ctx.Cache{Name: "下一条指令", Value: "", Help: "下一条指令"}
|
cli.Caches["next"] = &ctx.Cache{Name: "下一条指令", Value: "", Help: "下一条指令"}
|
||||||
|
|
||||||
|
cli.Configs["target"] = &ctx.Config{Name: "词法解析器", Value: "cli", Help: "命令行词法解析器", Hand: func(m *ctx.Message, x *ctx.Config, arg ...string) string {
|
||||||
|
if len(arg) > 0 && len(arg[0]) > 0 { // {{{
|
||||||
|
cli, ok := m.Target().Server.(*CLI)
|
||||||
|
m.Assert(ok, "模块类型错误")
|
||||||
|
|
||||||
|
target := m.Find(arg[0])
|
||||||
|
cli.target = target.Target()
|
||||||
|
return arg[0]
|
||||||
|
}
|
||||||
|
return x.Value
|
||||||
|
// }}}
|
||||||
|
}}
|
||||||
cli.Configs["lex"] = &ctx.Config{Name: "词法解析器", Value: "", Help: "命令行词法解析器", Hand: func(m *ctx.Message, x *ctx.Config, arg ...string) string {
|
cli.Configs["lex"] = &ctx.Config{Name: "词法解析器", Value: "", Help: "命令行词法解析器", Hand: func(m *ctx.Message, x *ctx.Config, arg ...string) string {
|
||||||
if len(arg) > 0 && len(arg[0]) > 0 { // {{{
|
if len(arg) > 0 && len(arg[0]) > 0 { // {{{
|
||||||
cli, ok := m.Target().Server.(*CLI)
|
cli, ok := m.Target().Server.(*CLI)
|
||||||
@ -102,11 +114,11 @@ func (cli *CLI) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
|||||||
yac.Cmd("train", "void", "void", "[\t ]+")
|
yac.Cmd("train", "void", "void", "[\t ]+")
|
||||||
|
|
||||||
yac.Cmd("train", "key", "key", "[A-Za-z_][A-Za-z_0-9]*")
|
yac.Cmd("train", "key", "key", "[A-Za-z_][A-Za-z_0-9]*")
|
||||||
yac.Cmd("train", "num", "num", "mul{", "0", "[1-9][0-9]*", "0[0-9]+", "0x[0-9]+", "}")
|
yac.Cmd("train", "num", "num", "mul{", "0", "-?[1-9][0-9]*", "0[0-9]+", "0x[0-9]+", "}")
|
||||||
yac.Cmd("train", "str", "str", "mul{", "\"[^\"]*\"", "'[^']*'", "}")
|
yac.Cmd("train", "str", "str", "mul{", "\"[^\"]*\"", "'[^']*'", "}")
|
||||||
|
|
||||||
yac.Cmd("train", "tran", "tran", "mul{", "@", "$", "}", "opt{", "[a-zA-Z0-9_]+", "}")
|
yac.Cmd("train", "tran", "tran", "mul{", "@", "$", "}", "opt{", "[a-zA-Z0-9_]+", "}")
|
||||||
yac.Cmd("train", "word", "word", "mul{", "~", "!", "tran", "str", "[a-zA-Z0-9_/.:]+", "}")
|
yac.Cmd("train", "word", "word", "mul{", "~", "!", "=", "tran", "str", "[a-zA-Z0-9_/\\-.:]+", "}")
|
||||||
|
|
||||||
yac.Cmd("train", "op1", "op1", "mul{", "$", "@", "}")
|
yac.Cmd("train", "op1", "op1", "mul{", "$", "@", "}")
|
||||||
yac.Cmd("train", "op1", "op1", "mul{", "-z", "-n", "}")
|
yac.Cmd("train", "op1", "op1", "mul{", "-z", "-n", "}")
|
||||||
@ -129,6 +141,9 @@ func (cli *CLI) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
|||||||
yac.Cmd("train", "stm", "function", "function", "rep{", "key", "}")
|
yac.Cmd("train", "stm", "function", "function", "rep{", "key", "}")
|
||||||
yac.Cmd("train", "stm", "return", "return", "rep{", "exp", "}")
|
yac.Cmd("train", "stm", "return", "return", "rep{", "exp", "}")
|
||||||
|
|
||||||
|
yac.Cmd("train", "cmd", "cmd", "cache", "rep{", "word", "}")
|
||||||
|
yac.Cmd("train", "cmd", "cmd", "cache", "key", "rep{", "word", "}")
|
||||||
|
yac.Cmd("train", "cmd", "cmd", "cache", "key", "opt{", "=", "exp", "}")
|
||||||
yac.Cmd("train", "cmd", "cmd", "rep{", "word", "}")
|
yac.Cmd("train", "cmd", "cmd", "rep{", "word", "}")
|
||||||
yac.Cmd("train", "tran", "tran", "$", "(", "cmd", ")")
|
yac.Cmd("train", "tran", "tran", "$", "(", "cmd", ")")
|
||||||
|
|
||||||
@ -341,10 +356,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m.Options("parse") || !m.Options("time_format") {
|
if m.Options("parse") || !m.Options("time_format") {
|
||||||
m.Echo("%d", t.Unix())
|
m.Echo("%d000", t.Unix())
|
||||||
m.Echo(" ")
|
} else {
|
||||||
}
|
|
||||||
m.Echo(t.Format(f))
|
m.Echo(t.Format(f))
|
||||||
|
}
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"express": &ctx.Command{Name: "express exp", Help: "表达式运算", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"express": &ctx.Command{Name: "express exp", Help: "表达式运算", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
@ -661,18 +676,23 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"source": &ctx.Command{Name: "source file", Help: "运行脚本, file: 脚本文件名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"source": &ctx.Command{Name: "source file", Help: "运行脚本, file: 脚本文件名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
target := m.Target() // {{{
|
cli, ok := m.Source().Server.(*CLI) // {{{
|
||||||
if _, ok := m.Source().Server.(*CLI); ok {
|
if !ok {
|
||||||
target = m.Source()
|
cli, ok = m.Target().Server.(*CLI)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !m.Caps("skip") {
|
if !m.Caps("skip") {
|
||||||
msg := m.Spawn(target)
|
msg := m.Spawn(cli)
|
||||||
msg.Start(fmt.Sprintf("%s_%d_%s", key, msg.Optioni("level", msg.Capi("level")+1), arg[0]), "脚本文件", arg[0])
|
msg.Start(fmt.Sprintf("%s_%d_%s", key, msg.Optioni("level", msg.Capi("level")+1), arg[0]), "脚本文件", arg[0])
|
||||||
<-msg.Target().Exit
|
<-msg.Target().Exit
|
||||||
m.Copy(msg, "result").Copy(msg, "append")
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
nfs := msg.Sesss("nfs")
|
nfs := msg.Sesss("nfs")
|
||||||
nfs.Target().Close(nfs)
|
nfs.Target().Close(nfs)
|
||||||
|
|
||||||
|
sub, _ := msg.Target().Server.(*CLI)
|
||||||
|
if sub.target != msg.Target() {
|
||||||
|
cli.target = sub.target
|
||||||
|
}
|
||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"return": &ctx.Command{Name: "return result...", Help: "结束脚本, rusult: 返回值", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"return": &ctx.Command{Name: "return result...", Help: "结束脚本, rusult: 返回值", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
@ -13,6 +13,7 @@ import ( // {{{
|
|||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -2796,42 +2797,54 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"command": &Command{
|
"command": &Command{
|
||||||
Name: "command [all] add [key [name help]]", Help: "查看或修改命令",
|
Name: "command [all|add cmd arg...|list [begin [end]]|test [begin [end]]|delete cmd]", Help: "查看或修改命令",
|
||||||
Form: map[string]int{"all": 0, "delete": 0, "void": 0, "condition": -1},
|
Form: map[string]int{"delete": 0, "condition": -1},
|
||||||
Hand: func(m *Message, c *Context, key string, arg ...string) {
|
Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||||
all := m.Has("all") // {{{
|
all := m.Has("all") // {{{
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.BackTrace(func(m *Message) bool {
|
keys := []string{}
|
||||||
if all {
|
for k, _ := range m.target.Commands {
|
||||||
m.Echo("%s comands:\n", m.target.Name)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
for k, x := range m.target.Commands {
|
sort.Strings(keys)
|
||||||
if m.Check(m.target, "commands", k) {
|
for _, k := range keys {
|
||||||
if all {
|
m.Echo("%s: %s\n", k, m.target.Commands[k].Name)
|
||||||
m.Echo(" ")
|
|
||||||
}
|
}
|
||||||
m.Echo("%s: %s\n", k, x.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return all
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
|
case "all":
|
||||||
|
keys := []string{}
|
||||||
|
values := map[string]*Command{}
|
||||||
|
for s := m.target; s != nil; s = s.context {
|
||||||
|
for k, v := range s.Commands {
|
||||||
|
if _, ok := values[k]; !ok {
|
||||||
|
keys = append(keys, k)
|
||||||
|
values[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
for _, k := range keys {
|
||||||
|
m.Echo("%s: %s\n", k, values[k].Name)
|
||||||
|
}
|
||||||
|
return
|
||||||
case "add":
|
case "add":
|
||||||
if m.target.Caches == nil {
|
if m.target.Caches == nil {
|
||||||
m.target.Caches = map[string]*Cache{}
|
m.target.Caches = map[string]*Cache{}
|
||||||
}
|
}
|
||||||
|
if _, ok := m.target.Caches["list_count"]; !ok {
|
||||||
|
m.target.Caches["list_count"] = &Cache{Name: "list_count", Value: "0", Help: "list_count"}
|
||||||
|
m.target.Caches["list_begin"] = &Cache{Name: "list_begin", Value: "0", Help: "list_begin"}
|
||||||
|
}
|
||||||
|
|
||||||
if m.target.Commands == nil {
|
if m.target.Commands == nil {
|
||||||
m.target.Commands = map[string]*Command{}
|
m.target.Commands = map[string]*Command{}
|
||||||
}
|
}
|
||||||
|
m.target.Commands[m.Cap("list_count")] = &Command{
|
||||||
if _, ok := m.target.Caches["part"]; !ok {
|
Name: strings.Join(arg[1:], " "),
|
||||||
m.target.Caches["part"] = &Cache{Name: "part", Value: "0", Help: "part"}
|
Help: "list_command",
|
||||||
}
|
Hand: func(m *Message, c *Context, key string, args ...string) {
|
||||||
m.target.Commands[m.Cap("part")] = &Command{
|
|
||||||
Name: strings.Join(arg[1:], " "), Help: "part", Hand: func(m *Message, c *Context, key string, args ...string) {
|
|
||||||
list := []string{}
|
list := []string{}
|
||||||
j := 0
|
j := 0
|
||||||
for i := 1; i < len(arg); i++ {
|
for i := 1; i < len(arg); i++ {
|
||||||
@ -2844,14 +2857,14 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
}
|
}
|
||||||
list = append(list, args[j:]...)
|
list = append(list, args[j:]...)
|
||||||
|
|
||||||
msg := m.Spawn(m.target).Cmd(list)
|
msg := m.Spawn().Cmd(list)
|
||||||
m.Copy(msg, "result").Copy(msg, "append")
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
m.Capi("part", 1)
|
m.Capi("list_count", 1)
|
||||||
return
|
return
|
||||||
case "list":
|
case "list":
|
||||||
begin, end := m.Confi("command_list_base"), m.Capi("part")
|
begin, end := m.Capi("list_begin"), m.Capi("list_count")
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
n, e := strconv.Atoi(arg[1])
|
n, e := strconv.Atoi(arg[1])
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
@ -2869,7 +2882,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
case "test":
|
case "test":
|
||||||
begin, end := 0, m.Capi("part")
|
begin, end := 0, m.Capi("list_count")
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
n, e := strconv.Atoi(arg[1])
|
n, e := strconv.Atoi(arg[1])
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
@ -2880,20 +2893,20 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
end = n
|
end = n
|
||||||
}
|
}
|
||||||
|
|
||||||
success, failure := 0, 0
|
success, failure := 0, 0
|
||||||
for i := begin; i < end; i++ {
|
for i := begin; i < end; i++ {
|
||||||
key := fmt.Sprintf("%d", i)
|
key := fmt.Sprintf("%d", i)
|
||||||
if c, ok := m.target.Commands[key]; ok {
|
if c, ok := m.target.Commands[key]; ok {
|
||||||
msg := m.Spawn(m.Target())
|
msg := m.Spawn().Cmd(key)
|
||||||
msg.Cmd(key)
|
|
||||||
if m.Options("condition") {
|
if m.Options("condition") {
|
||||||
done := true
|
done := true
|
||||||
condition := m.Meta["condition"]
|
condition := m.Meta["condition"]
|
||||||
for j := 0; j < len(condition)-1; j += 2 {
|
for j := 0; j < len(condition)-1; j += 2 {
|
||||||
if !msg.Has(condition[j]) || msg.Append(condition[j]) != condition[j+1] {
|
if !msg.Has(condition[j]) || msg.Append(condition[j]) != condition[j+1] {
|
||||||
m.Echo("\033[31m%s %s %s\033[0m\n", key, " fail", c.Name)
|
m.Color(31, "%s %s %s\n", key, " fail", c.Name)
|
||||||
failure++
|
|
||||||
done = false
|
done = false
|
||||||
|
failure++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if done {
|
if done {
|
||||||
@ -2910,8 +2923,14 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo("\033[32msuccess: %d\033[0m, \033[31mfailure: %d\033[0m, \033[33mtotal: %d\033[0m", success, failure, success+failure)
|
m.Color(32, "success: %d, ", success)
|
||||||
|
m.Color(31, "failure: %d, ", failure)
|
||||||
|
m.Color(33, "total: %d", success+failure)
|
||||||
return
|
return
|
||||||
|
case "delete":
|
||||||
|
if _, ok := m.target.Commands[arg[1]]; ok {
|
||||||
|
delete(m.target.Commands, arg[1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch len(arg) {
|
switch len(arg) {
|
||||||
@ -2919,11 +2938,6 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
case 1:
|
case 1:
|
||||||
switch {
|
switch {
|
||||||
case m.Has("delete"):
|
case m.Has("delete"):
|
||||||
if _, ok := m.target.Commands[arg[0]]; ok {
|
|
||||||
if m.target.Owner == nil || m.master.Owner == m.target.Owner {
|
|
||||||
delete(m.target.Commands, arg[0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case m.Has("void"):
|
case m.Has("void"):
|
||||||
if x, ok := m.target.Commands[arg[0]]; ok {
|
if x, ok := m.target.Commands[arg[0]]; ok {
|
||||||
if m.target.Owner == nil || m.master.Owner == m.target.Owner {
|
if m.target.Owner == nil || m.master.Owner == m.target.Owner {
|
||||||
@ -2987,120 +3001,101 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"config": &Command{
|
"config": &Command{
|
||||||
Name: "config [all] [[delete|void] key [value]|[name value help]]",
|
Name: "config [all|key [value]|key name value help|delete key]",
|
||||||
Help: "删除、置空、查看、修改或添加配置",
|
Help: "查看、读写、添加配置变量",
|
||||||
Form: map[string]int{"all": 0, "delete": 0, "void": 0},
|
|
||||||
Hand: func(m *Message, c *Context, key string, arg ...string) {
|
Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||||
all := m.Has("all") // {{{
|
switch len(arg) { //{{{
|
||||||
|
|
||||||
switch len(arg) {
|
|
||||||
case 0:
|
case 0:
|
||||||
m.BackTrace(func(m *Message) bool {
|
keys := []string{}
|
||||||
if all {
|
for k, _ := range m.target.Configs {
|
||||||
m.Echo("%s configs:\n", m.target.Name)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
for k, x := range m.target.Configs {
|
sort.Strings(keys)
|
||||||
if m.Check(m.target, "configs", k) {
|
for _, k := range keys {
|
||||||
if all {
|
m.Echo("%s(%s): %s\n", k, m.Conf(k), m.target.Configs[k].Name)
|
||||||
m.Echo(" ")
|
|
||||||
}
|
}
|
||||||
m.Echo("%s(%s): %s\n", k, x.Value, x.Name)
|
return
|
||||||
}
|
|
||||||
}
|
|
||||||
return all
|
|
||||||
})
|
|
||||||
case 1:
|
case 1:
|
||||||
switch {
|
if arg[0] == "all" {
|
||||||
case m.Has("delete"):
|
keys := []string{}
|
||||||
if _, ok := m.target.Configs[arg[0]]; ok {
|
values := map[string]*Config{}
|
||||||
if m.target.Owner == nil || m.master.Owner == m.target.Owner {
|
for s := m.target; s != nil; s = s.context {
|
||||||
delete(m.target.Configs, arg[0])
|
for k, v := range s.Configs {
|
||||||
|
if _, ok := values[k]; !ok {
|
||||||
|
keys = append(keys, k)
|
||||||
|
values[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case m.Has("void"):
|
|
||||||
m.Conf(arg[0], "")
|
|
||||||
}
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
m.BackTrace(func(m *Message) bool {
|
for _, k := range keys {
|
||||||
// if all {
|
m.Echo("%s(%s): %s\n", k, m.Conf(k), values[k].Name)
|
||||||
// m.Echo("%s config:\n", m.target.Name)
|
|
||||||
// }
|
|
||||||
if x, ok := m.target.Configs[arg[0]]; ok {
|
|
||||||
if m.Check(m.target, "configs", arg[0]) {
|
|
||||||
// if all {
|
|
||||||
// m.Echo(" ")
|
|
||||||
// }
|
|
||||||
// m.Echo("%s: %s\n", x.Name, x.Help)
|
|
||||||
m.Echo("%s", x.Value)
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
// return all
|
|
||||||
})
|
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
if arg[0] == "delete" {
|
||||||
|
if _, ok := m.target.Configs[arg[1]]; ok {
|
||||||
|
delete(m.target.Configs, arg[1])
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
m.Conf(arg[0], arg[1])
|
m.Conf(arg[0], arg[1])
|
||||||
case 3:
|
case 3:
|
||||||
m.Conf(arg[0], arg[2])
|
m.Conf(arg[0], arg[0], arg[2], arg[0])
|
||||||
case 4:
|
default:
|
||||||
m.Conf(arg[0], arg[1:]...)
|
m.Conf(arg[0], arg[1:]...)
|
||||||
}
|
}
|
||||||
|
m.Echo("%s", m.Conf(arg[0]))
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"cache": &Command{
|
"cache": &Command{
|
||||||
Name: "cache [all] [[delete|void] key [value]|[name value help]]",
|
Name: "cache [all|key [value]|key = value|key name value help|delete key]",
|
||||||
Help: "删除、置空、查看、修改或添加缓存",
|
Help: "查看、读写、赋值、新建、删除缓存变量",
|
||||||
Form: map[string]int{"all": 0, "delete": 0, "void": 0},
|
|
||||||
Hand: func(m *Message, c *Context, key string, arg ...string) {
|
Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||||
all := m.Has("all") // {{{
|
switch len(arg) { //{{{
|
||||||
|
|
||||||
switch len(arg) {
|
|
||||||
case 0:
|
case 0:
|
||||||
m.BackTrace(func(m *Message) bool {
|
keys := []string{}
|
||||||
if all {
|
for k, _ := range m.target.Caches {
|
||||||
m.Echo("%s configs:\n", m.target.Name)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
for k, x := range m.target.Caches {
|
sort.Strings(keys)
|
||||||
if m.Check(m.target, "caches", k) {
|
for _, k := range keys {
|
||||||
if all {
|
m.Echo("%s(%s): %s\n", k, m.Cap(k), m.target.Caches[k].Name)
|
||||||
m.Echo(" ")
|
|
||||||
}
|
}
|
||||||
m.Echo("%s(%s): %s\n", k, m.Cap(k), x.Name)
|
return
|
||||||
}
|
|
||||||
}
|
|
||||||
return all
|
|
||||||
})
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
switch {
|
if arg[0] == "all" {
|
||||||
case m.Has("delete"):
|
keys := []string{}
|
||||||
if _, ok := m.target.Caches[arg[0]]; ok {
|
values := map[string]*Cache{}
|
||||||
if m.target.Owner == nil || m.master.Owner == m.target.Owner {
|
for s := m.target; s != nil; s = s.context {
|
||||||
delete(m.target.Caches, arg[0])
|
for k, v := range s.Caches {
|
||||||
|
if _, ok := values[k]; !ok {
|
||||||
|
keys = append(keys, k)
|
||||||
|
values[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case m.Has("void"):
|
|
||||||
m.Cap(arg[0], "")
|
|
||||||
}
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
// if m.source == m.source.master {
|
for _, k := range keys {
|
||||||
// m.source, m.target = m.target, m.source
|
m.Echo("%s(%s): %s\n", k, m.Cap(k), values[k].Name)
|
||||||
// }
|
}
|
||||||
m.Echo("%s", m.Cap(arg[0]))
|
return
|
||||||
|
}
|
||||||
case 2:
|
case 2:
|
||||||
// if m.source == m.source.master {
|
if arg[0] == "delete" {
|
||||||
// m.source, m.target = m.target, m.source
|
if _, ok := m.target.Caches[arg[1]]; ok {
|
||||||
// }
|
delete(m.target.Caches, arg[1])
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
m.Cap(arg[0], arg[1])
|
m.Cap(arg[0], arg[1])
|
||||||
case 3:
|
case 3:
|
||||||
if m.source == m.source.master {
|
m.Cap(arg[0], arg[0], arg[2], arg[0])
|
||||||
m.source, m.target = m.target, m.source
|
default:
|
||||||
}
|
|
||||||
m.Cap(arg[0], arg[2])
|
|
||||||
case 4:
|
|
||||||
m.Cap(arg[0], arg[1:]...)
|
m.Cap(arg[0], arg[1:]...)
|
||||||
}
|
}
|
||||||
|
m.Echo("%s", m.Cap(arg[0]))
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"right": &Command{
|
"right": &Command{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user