1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 17:44:05 +08:00

opt web.space

This commit is contained in:
shylinux 2020-02-20 14:42:23 +08:00
parent 5745db2c6b
commit d640c1c4d6
4 changed files with 44 additions and 11 deletions

View File

@ -29,7 +29,7 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
// 模块列表 // 模块列表
p.Travel(func(p *ice.Context, s *ice.Context) { p.Travel(func(p *ice.Context, s *ice.Context) {
if p != nil { if p != nil {
m.Push("ups", p.Name) m.Push("ups", kit.Select("shy", p.Cap(ice.CTX_FOLLOW)))
} else { } else {
m.Push("ups", "shy") m.Push("ups", "shy")
} }
@ -38,7 +38,23 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
m.Push(ice.CTX_STREAM, s.Cap(ice.CTX_STREAM)) m.Push(ice.CTX_STREAM, s.Cap(ice.CTX_STREAM))
m.Push("help", s.Help) m.Push("help", s.Help)
}) })
return
} else if len(arg) == 1 {
m.Cmdy(ice.CTX_COMMAND, arg[0]+".")
} else {
m.Search(arg[0]+".", func(p *ice.Context, s *ice.Context, key string) {
msg := m.Spawn(s)
switch arg[1] {
case "command":
msg.Cmdy(ice.CTX_COMMAND, arg[0], arg[2:])
case "config":
msg.Cmdy(ice.CTX_CONFIG, arg[2:])
case "cache":
}
m.Copy(msg)
})
} }
}}, }},
ice.CTX_COMMAND: {Name: "command [all] [context [command run arg...]]", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.CTX_COMMAND: {Name: "command [all] [context [command run arg...]]", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
all := false all := false
@ -82,6 +98,7 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
m.Search(chain, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) { m.Search(chain, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
if len(arg) == 0 { if len(arg) == 0 {
// 命令列表 // 命令列表
m.Push("key", key)
m.Push("name", cmd.Name) m.Push("name", cmd.Name)
m.Push("help", kit.Format(cmd.Help)) m.Push("help", kit.Format(cmd.Help))
m.Push("meta", kit.Format(cmd.Meta)) m.Push("meta", kit.Format(cmd.Meta))
@ -97,7 +114,7 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
} }
}) })
}}, }},
ice.CTX_CONFIG: {Name: "config [all] save|load", Help: "配置", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.CTX_CONFIG: {Name: "config [all] [save|load] chain key arg...", Help: "配置", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
all := false all := false
if len(arg) > 0 && arg[0] == "all" { if len(arg) > 0 && arg[0] == "all" {
all, arg = true, arg[1:] all, arg = true, arg[1:]
@ -154,7 +171,7 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
} }
if len(arg) > 1 { if len(arg) > 1 {
// 读取配置 // 读取配置
m.Echo(msg.Conf(arg[0], arg[1])) m.Echo(kit.Formats(msg.Confv(arg[0], arg[1])))
} else { } else {
// 读取配置 // 读取配置
m.Echo(kit.Formats(msg.Confv(arg[0]))) m.Echo(kit.Formats(msg.Confv(arg[0])))

View File

@ -760,6 +760,13 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
default: default:
if len(arg) == 1 { if len(arg) == 1 {
list := []string{}
m.Cmdy(ice.WEB_SPACE, arg[0], "space").Table(func(index int, value map[string]string, head []string) {
list = append(list, arg[0]+"."+value["name"])
})
m.Append("name", list)
break
// 节点详情 // 节点详情
m.Richs(ice.WEB_SPACE, nil, arg[0], func(key string, value map[string]interface{}) { m.Richs(ice.WEB_SPACE, nil, arg[0], func(key string, value map[string]interface{}) {
m.Push("detail", value) m.Push("detail", value)
@ -780,7 +787,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
id := kit.Format(c.ID()) id := kit.Format(c.ID())
m.Optionv(ice.MSG_SOURCE, []string{id}) m.Optionv(ice.MSG_SOURCE, []string{id})
m.Optionv(ice.MSG_TARGET, target[1:]) m.Optionv(ice.MSG_TARGET, target[1:])
for _, k := range []string{"top", "hot"} { for _, k := range []string{"top", "hot", ice.MSG_USERNAME} {
if m.Options(k) { if m.Options(k) {
m.Option(k, m.Option(k)) m.Option(k, m.Option(k))
} }
@ -863,7 +870,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
ice.WEB_FAVOR: {Name: "favor", Help: "收藏夹", Meta: kit.Dict("remote", "you", "exports", []string{"hot", "favor"}, ice.WEB_FAVOR: {Name: "favor", Help: "收藏夹", Meta: kit.Dict("remote", "you", "exports", []string{"hot", "favor"},
"detail", []string{"执行", "编辑", "收录", "导出", "下载"}), List: kit.List( "detail", []string{"执行", "编辑", "收录", "导出", "下载"}), List: kit.List(
kit.MDB_INPUT, "text", "name", "hot", "action", "auto", kit.MDB_INPUT, "text", "name", "favor", "action", "auto",
kit.MDB_INPUT, "text", "name", "id", "action", "auto", kit.MDB_INPUT, "text", "name", "id", "action", "auto",
kit.MDB_INPUT, "button", "value", "查看", "action", "auto", kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last", kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
@ -1068,7 +1075,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
}}, }},
ice.WEB_STORY: {Name: "story", Help: "故事会", Meta: kit.Dict("remote", "you", "exports", []string{"top", "story"}, ice.WEB_STORY: {Name: "story", Help: "故事会", Meta: kit.Dict("remote", "you", "exports", []string{"top", "story"},
"detail", []string{"归档", "共享", "导出", "下载"}), List: kit.List( "detail", []string{"归档", "共享", "导出", "下载"}), List: kit.List(
kit.MDB_INPUT, "text", "name", "top", "action", "auto", kit.MDB_INPUT, "text", "name", "story", "action", "auto",
kit.MDB_INPUT, "text", "name", "list", "action", "auto", kit.MDB_INPUT, "text", "name", "list", "action", "auto",
kit.MDB_INPUT, "button", "value", "查看", "action", "auto", kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last", kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",

View File

@ -83,7 +83,8 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
}}, }},
"status": {Name: "status repos", Help: "状态", Meta: kit.Dict( "status": {Name: "status repos", Help: "状态", Meta: kit.Dict(
"detail", []interface{}{"add", "reset", "remove", kit.Dict("name", "commit", "args", kit.List( "detail", []interface{}{"add", "reset", "remove", kit.Dict("name", "commit", "args", kit.List(
kit.MDB_INPUT, "text", "name", "repos", kit.MDB_INPUT, "select", "name", "type", "values", []string{"add", "opt"},
kit.MDB_INPUT, "text", "name", "name", "value", "some",
))}, ))},
), List: kit.List( ), List: kit.List(
kit.MDB_INPUT, "text", "name", "repos", "action", "auto", kit.MDB_INPUT, "text", "name", "repos", "action", "auto",
@ -97,15 +98,16 @@ var Index = &ice.Context{Name: "git", Help: "代码管理",
m.Option("cmd_dir", kit.Value(value, "meta.path")) m.Option("cmd_dir", kit.Value(value, "meta.path"))
switch arg[1] { switch arg[1] {
case "add": case "add":
m.Cmd(prefix, arg[1], arg[3]) m.Cmdy(prefix, arg[1], m.Option("file"))
case "reset": case "reset":
m.Cmd(prefix, arg[1], arg[3]) m.Cmdy(prefix, arg[1], m.Option("file"))
case "checkout": case "checkout":
m.Cmd(prefix, arg[1], arg[3]) m.Cmdy(prefix, arg[1], m.Option("file"))
case "commit": case "commit":
m.Cmdy(prefix, arg[1], "-m", m.Option("comment"))
} }
}) })
arg = []string{} return
} }
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) { m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {

View File

@ -947,6 +947,13 @@ func (m *Message) Search(key interface{}, cb interface{}) *Message {
switch cb := cb.(type) { switch cb := cb.(type) {
case func(p *Context, s *Context, key string, cmd *Command): case func(p *Context, s *Context, key string, cmd *Command):
if key == "" {
for k, v := range p.Commands {
cb(p.context, p, k, v)
}
break
}
for _, p = range []*Context{p, m.target, m.source} { for _, p = range []*Context{p, m.target, m.source} {
for c := p; c != nil; c = c.context { for c := p; c != nil; c = c.context {
if cmd, ok := c.Commands[key]; ok { if cmd, ok := c.Commands[key]; ok {