1
0
forked from x/icebergs

opt xterm.go

This commit is contained in:
harveyshao 2022-07-25 08:11:17 +08:00
parent ab05ddc76d
commit cbdabc9a74
59 changed files with 172 additions and 167 deletions

View File

@ -129,7 +129,7 @@ func init() {
}},
STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
m.OptionFields(m.Config(mdb.FIELD))
m.Cmd(mdb.SELECT, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH)).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(mdb.SELECT, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH)).Tables(func(value ice.Maps) {
m.Cmd(mdb.MODIFY, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH), STATUS, STOP)
m.Cmdy(SYSTEM, KILL, value[PID])
})
@ -138,7 +138,7 @@ func init() {
}
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Set(ctx.ACTION).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m, arg...).Set(ctx.ACTION).Tables(func(value ice.Maps) {
switch value[STATUS] {
case START:
m.PushButton(RESTART, STOP)

View File

@ -82,7 +82,6 @@ func _system_find(m *ice.Message, bin string, dir ...string) string {
return bin
}
if strings.HasPrefix(bin, nfs.PWD) {
// return kit.Path(m.Option(CMD_DIR), bin)
return bin
}
if len(dir) == 0 {
@ -131,6 +130,10 @@ func IsSuccess(m *ice.Message) bool {
return m.Append(CODE) == "0" || m.Append(CODE) == ""
}
func SystemFind(m *ice.Message, bin string, dir ...string) string {
if text := kit.ReadFile(ice.ETC_PATH); len(text) > 0 {
dir = append(dir, strings.Split(text, ice.NL)...)
}
dir = append(dir, strings.Split(kit.Env(PATH), ice.DF)...)
return _system_find(m, bin, dir...)
}

View File

@ -46,7 +46,7 @@ func init() {
m.Display("/plugin/story/spide.js?prefix=spide", "root", kit.Select(ice.ICE, arg, 0), "split", ice.PT)
} else if index := kit.Keys(arg[1]); strings.HasSuffix(index, arg[2]) { // 命令列表
m.Cmdy(CONTEXT, index, COMMAND).Table(func(i int, value ice.Maps, head []string) {
m.Cmdy(CONTEXT, index, COMMAND).Tables(func(value ice.Maps) {
m.Push("file", arg[1])
})

View File

@ -11,7 +11,7 @@ func _event_listen(m *ice.Message, event string, cmd string) {
m.Cmdy(mdb.INSERT, EVENT, "", mdb.ZONE, event, ice.CMD, cmd)
}
func _event_action(m *ice.Message, event string, arg ...string) {
mdb.ZoneSelect(m, event).Table(func(index int, value ice.Maps, head []string) {
mdb.ZoneSelect(m, event).Tables(func(value ice.Maps) {
m.Cmd(kit.Split(value[ice.CMD]), event, arg).Cost(EVENT, event, ice.ARG, arg)
})
}

View File

@ -21,7 +21,7 @@ func _signal_listen(m *ice.Message, s int, arg ...string) {
}
}
func _signal_action(m *ice.Message, arg ...string) {
mdb.HashSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m.Spawn(), arg...).Tables(func(value ice.Maps) {
m.Cmdy(kit.Split(value[ice.CMD]))
})
}

View File

@ -192,49 +192,15 @@ func AutoConfig(args ...ice.Any) *ice.Action {
}}
}
func HashAction(args ...ice.Any) ice.Actions {
_key := func(m *ice.Message) string {
if m.Config(HASH) == UNIQ {
return HASH
}
if m.Config(SHORT) == UNIQ {
return HASH
}
return kit.Select(HASH, m.Config(SHORT))
}
return ice.Actions{ice.CTX_INIT: AutoConfig(args...),
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(INPUTS, m.PrefixKey(), "", HASH, arg)
}},
CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(INSERT, m.PrefixKey(), "", HASH, arg)
}},
REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.OptionFields(m.Config(FIELD))
m.Cmdy(DELETE, m.PrefixKey(), "", HASH, m.OptionSimple(_key(m)), arg)
m.Event(kit.Keys(m.CommandKey(), REMOVE), m.CommandKey(), m.Option(m.Config(SHORT)))
}},
MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
field := m.Config(FIELD)
for i := 0; i < len(arg); i += 2 {
if !strings.Contains(field, arg[i]) {
arg[i] = kit.Keys("extra", arg[i])
}
}
m.Cmdy(MODIFY, m.PrefixKey(), "", HASH, m.OptionSimple(_key(m)), arg)
}},
SELECT: &ice.Action{Name: "select hash auto", Help: "列表", Hand: func(m *ice.Message, arg ...string) {
HashSelect(m, arg...)
}},
PRUNES: &ice.Action{Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
HashPrunes(m, nil)
}},
EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
m.OptionFields(m.Config(FIELD))
m.Cmdy(EXPORT, m.PrefixKey(), "", HASH, arg)
}},
IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(IMPORT, m.PrefixKey(), "", HASH, arg)
}},
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { HashInputs(m, arg) }},
CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) { HashCreate(m, arg) }},
REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { HashRemove(m, arg) }},
MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { HashModify(m, arg) }},
SELECT: {Name: "select hash auto", Help: "列表", Hand: func(m *ice.Message, arg ...string) { HashSelect(m, arg...) }},
PRUNES: {Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) { HashPrunes(m, nil) }},
EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) { HashExport(m, arg) }},
IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) { HashImport(m, arg) }},
}
}
func HashActionStatus(args ...ice.Any) ice.Actions {
@ -248,16 +214,32 @@ func HashActionStatus(args ...ice.Any) ice.Actions {
}
func HashInputs(m *ice.Message, arg ...ice.Any) *ice.Message {
return m.Cmd(INPUTS, m.PrefixKey(), "", HASH, kit.Simple(arg...))
return m.Cmdy(INPUTS, m.PrefixKey(), "", HASH, kit.Simple(arg...))
}
func HashCreate(m *ice.Message, arg ...ice.Any) *ice.Message {
return m.Cmd(INSERT, m.PrefixKey(), "", HASH, kit.Simple(arg...))
field := m.Config(FIELD)
args := kit.Simple(arg...)
for i := 0; i < len(args); i += 2 {
if !strings.Contains(field, args[i]) {
args[i] = kit.Keys("extra", args[i])
}
}
return m.Cmd(INSERT, m.PrefixKey(), "", HASH, args)
}
func HashRemove(m *ice.Message, arg ...ice.Any) *ice.Message {
m.OptionFields(m.Config(FIELD))
defer m.Event(kit.Keys(m.CommandKey(), REMOVE), m.CommandKey(), m.Option(m.Config(SHORT)))
return m.Cmd(DELETE, m.PrefixKey(), "", HASH, kit.Simple(arg...))
}
func HashModify(m *ice.Message, arg ...ice.Any) *ice.Message {
return m.Cmd(MODIFY, m.PrefixKey(), "", HASH, kit.Simple(arg...))
field := m.Config(FIELD)
args := kit.Simple(arg...)
for i := 0; i < len(args); i += 2 {
if !strings.Contains(field, args[i]) {
args[i] = kit.Keys("extra", args[i])
}
}
return m.Cmd(MODIFY, m.PrefixKey(), "", HASH, args)
}
func HashSelect(m *ice.Message, arg ...string) *ice.Message {
m.Fields(len(arg), m.Config(FIELD))
@ -271,10 +253,13 @@ func HashPrunes(m *ice.Message, cb func(ice.Maps) bool) *ice.Message {
if m.Config(HASH) == UNIQ {
return HASH
}
if m.Config(SHORT) == UNIQ {
return HASH
}
return kit.Select(HASH, m.Config(SHORT))
}
expire := kit.Time(kit.Select(m.Time("-72h"), m.Option(EXPIRE)))
m.Cmd(m.CommandKey()).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(m.CommandKey()).Tables(func(value ice.Maps) {
if kit.Time(value[TIME]) > expire {
return
}
@ -287,6 +272,7 @@ func HashPrunes(m *ice.Message, cb func(ice.Maps) bool) *ice.Message {
return m
}
func HashExport(m *ice.Message, arg ...ice.Any) *ice.Message {
m.OptionFields(m.Config(FIELD))
return m.Cmd(EXPORT, m.PrefixKey(), "", HASH, kit.Simple(arg...))
}
func HashImport(m *ice.Message, arg ...ice.Any) *ice.Message {

View File

@ -72,14 +72,13 @@ const (
DETAIL = "detail"
RANDOM = "random"
INPUTS = "inputs"
CREATE = "create"
REMOVE = "remove"
INSERT = "insert"
DELETE = "delete"
MODIFY = "modify"
SELECT = "select"
INPUTS = "inputs"
PRUNES = "prunes"
EXPORT = "export"
IMPORT = "import"
@ -148,6 +147,21 @@ const MDB = "mdb"
var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {}},
INPUTS: {Name: "inputs key sub type field value", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
switch arg[3] {
case "index":
m.OptionFields(arg[3])
m.Cmdy("command", "search", "command", "", "")
}
switch arg[2] {
case ZONE: // inputs key sub type zone field value
_list_inputs(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), kit.Select(NAME, arg, 4), kit.Select("", arg, 5))
case HASH:
_hash_inputs(m, arg[0], _domain_chain(m, arg[1]), kit.Select(NAME, arg, 3), kit.Select("", arg, 4))
case LIST:
_list_inputs(m, arg[0], _domain_chain(m, arg[1]), kit.Select(NAME, arg, 3), kit.Select("", arg, 4))
}
}},
INSERT: {Name: "insert key sub type arg...", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
switch arg[2] {
case ZONE: // insert key sub type zone arg...
@ -190,21 +204,6 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
_list_select(m, arg[0], _domain_chain(m, arg[1]), kit.Select("", arg, 3), kit.Select("", arg, 4))
}
}},
INPUTS: {Name: "inputs key sub type field value", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
switch arg[3] {
case "index":
m.OptionFields(arg[3])
m.Cmdy("command", "search", "command")
}
switch arg[2] {
case ZONE: // inputs key sub type zone field value
_list_inputs(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), kit.Select(NAME, arg, 4), kit.Select("", arg, 5))
case HASH:
_hash_inputs(m, arg[0], _domain_chain(m, arg[1]), kit.Select(NAME, arg, 3), kit.Select("", arg, 4))
case LIST:
_list_inputs(m, arg[0], _domain_chain(m, arg[1]), kit.Select(NAME, arg, 3), kit.Select("", arg, 4))
}
}},
PRUNES: {Name: "prunes key sub type [field value]...", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
switch arg[2] {
case ZONE: // prunes key sub type zone field value

View File

@ -191,7 +191,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
}
func _dir_search(m *ice.Message, kind, name string) {
msg := _dir_list(m.Spawn(), PWD, "", 0, true, TYPE_BOTH, nil, kit.Split("time,type,name"))
msg.Table(func(index int, value ice.Maps, head []string) {
msg.Tables(func(value ice.Maps) {
if !strings.Contains(value[mdb.NAME], name) {
return
}

View File

@ -93,7 +93,7 @@ func init() {
_client_dial(m, arg...)
}},
}, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == OPEN))
})
}},

View File

@ -80,7 +80,7 @@ func init() {
}, Commands: ice.Commands{
HOST: {Name: "host name auto", Help: "主机", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(HOST).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(HOST).Tables(func(value ice.Maps) {
m.Cmd(HOST, aaa.WHITE, value[aaa.IP])
})
}},

View File

@ -101,7 +101,7 @@ func init() {
_server_listen(m, arg...)
}},
}, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == CLOSE))
})
}},

View File

@ -46,7 +46,7 @@ func _serve_udp(m *ice.Message, host, port string) {
}
if remote, err := net.ResolveUDPAddr("udp4", kit.Format("%s:%s", msg.Option(tcp.HOST), msg.Option(tcp.PORT))); err == nil {
m.Cmd(BROAD).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(BROAD).Tables(func(value ice.Maps) {
m.Debug("broad %v to %v", kit.Format(value), kit.Format(remote))
s.WriteToUDP([]byte(m.Spawn(value).FormatMeta()), remote)
})

View File

@ -41,7 +41,7 @@ func _cache_save(m *ice.Message, kind, name, text string, arg ...string) { // fi
m.Push(mdb.DATA, h)
}
func _cache_watch(m *ice.Message, key, file string) {
mdb.HashSelect(m.Spawn(), key).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m.Spawn(), key).Tables(func(value ice.Maps) {
if value[nfs.FILE] == "" {
m.Cmdy(nfs.SAVE, file, value[mdb.TEXT])
} else {

View File

@ -15,7 +15,7 @@ import (
)
func _dream_list(m *ice.Message) *ice.Message {
return m.Cmdy(nfs.DIR, m.Config(nfs.PATH), "time,size,name").Table(func(index int, value ice.Maps, head []string) {
return m.Cmdy(nfs.DIR, m.Config(nfs.PATH), "time,size,name").Tables(func(value ice.Maps) {
if m.Richs(SPACE, nil, value[mdb.NAME], func(key string, val ice.Map) {
m.Push(mdb.TYPE, val[mdb.TYPE])
m.Push(cli.STATUS, cli.START)
@ -146,7 +146,7 @@ func init() {
}, Hand: func(m *ice.Message, arg ...string) {
if start := 0; len(arg) == 0 {
_dream_list(m).SetAppend(mdb.TEXT)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
if value[cli.STATUS] != cli.START {
m.Push(mdb.TEXT, "")
return

View File

@ -19,7 +19,7 @@ func _route_travel(m *ice.Message, route string) {
return // 避免循环
}
m.Cmd(SPACE, val[mdb.NAME], ROUTE).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(SPACE, val[mdb.NAME], ROUTE).Tables(func(value ice.Maps) {
m.Push(mdb.TYPE, value[mdb.TYPE])
m.Push(ROUTE, kit.Keys(val[mdb.NAME], value[ROUTE]))
})
@ -32,7 +32,7 @@ func _route_travel(m *ice.Message, route string) {
})
}
func _route_list(m *ice.Message) {
m.Table(func(index int, value ice.Maps, field []string) {
m.Tables(func(value ice.Maps) {
m.PushAnchor(value[ROUTE], m.MergePod(value[ROUTE]))
switch value[mdb.TYPE] {
@ -47,7 +47,7 @@ func _route_list(m *ice.Message) {
// 网卡信息
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
m.Cmd(tcp.HOST).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(tcp.HOST).Tables(func(value ice.Maps) {
m.Push(mdb.TYPE, MYSELF)
m.Push(ROUTE, ice.Info.NodeName)
m.PushAnchor(value[aaa.IP], kit.Format("%s://%s:%s", u.Scheme, value[aaa.IP], u.Port()))
@ -106,13 +106,13 @@ func init() {
}
} else if len(arg) == 1 || arg[1] == "" { // 模块列表
m.Cmd(SPACE, arg[0], ctx.CONTEXT, ice.ICE).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(SPACE, arg[0], ctx.CONTEXT, ice.ICE).Tables(func(value ice.Maps) {
m.Push(ice.CTX, kit.Keys(value["ups"], value[mdb.NAME]))
m.Push("", value, kit.List(ice.CTX_STATUS, ice.CTX_STREAM, mdb.HELP))
})
} else if len(arg) == 2 || arg[2] == "" { // 命令列表
m.Cmd(SPACE, arg[0], ctx.CONTEXT, arg[1], ctx.COMMAND).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(SPACE, arg[0], ctx.CONTEXT, arg[1], ctx.COMMAND).Tables(func(value ice.Maps) {
m.Push(ice.CMD, value[mdb.KEY])
m.Push("", value, kit.List(mdb.NAME, mdb.HELP))
})

View File

@ -323,7 +323,7 @@ func init() {
})
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(SERVE).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(SERVE).Tables(func(value ice.Maps) {
m.Done(value[cli.STATUS] == tcp.START)
})
}},

View File

@ -220,8 +220,8 @@ func _space_search(m *ice.Message, kind, name, text string, arg ...string) {
if name != "" {
return
}
m.Cmd(SERVE, ice.OptionFields("")).Table(func(index int, val ice.Maps, head []string) {
m.Cmd(tcp.HOST, ice.OptionFields("")).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(SERVE, ice.OptionFields("")).Tables(func(val ice.Maps) {
m.Cmd(tcp.HOST, ice.OptionFields("")).Tables(func(value ice.Maps) {
m.PushSearch(kit.SimpleKV("", MYSELF, value[mdb.NAME], kit.Format("http://%s:%s", value[aaa.IP], val[tcp.PORT])))
})
})
@ -327,7 +327,7 @@ func init() {
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) < 2 { // 节点列表
if mdb.HashSelect(m, arg...); len(arg) == 0 {
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
switch value[mdb.TYPE] {
case MASTER:
m.PushAnchor(value[mdb.NAME], m.Cmd(SPIDE, value[mdb.NAME], ice.OptionFields("")).Append("client.url"))

View File

@ -26,7 +26,7 @@ func _action_key(m *ice.Message, arg ...string) string {
return kit.Keys(mdb.HASH, kit.Select(m.Option(RIVER), arg, 0), STORM, mdb.HASH, kit.Select(m.Option(STORM), arg, 1))
}
func _action_list(m *ice.Message, river, storm string) {
m.Cmdy(STORM, storm, ice.Option{ice.MSG_RIVER, river}).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(STORM, storm, ice.Option{ice.MSG_RIVER, river}).Tables(func(value ice.Maps) {
m.Cmdy(m.Space(kit.Select(m.Option(ice.POD), value[ice.POD])), ctx.COMMAND, kit.Keys(value[ice.CTX], value[ice.CMD]))
})
}

View File

@ -27,7 +27,7 @@ func init() {
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
link := web.SHARE_CACHE + value[mdb.DATA]
if m.PushDownload(mdb.LINK, value[mdb.NAME], link); len(arg) > 0 && kit.ExtIsImage(value[mdb.NAME]) {
m.PushImages("image", link)

View File

@ -42,7 +42,7 @@ func init() {
mdb.CREATE: {Name: "create name 照片 性别 年龄 身高 体重 籍贯 户口 学历 学校 职业 公司 年薪 资产 家境", Help: "添加"},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
msg := m.Spawn()
mdb.HashSelect(msg, arg...).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(msg, arg...).Tables(func(value ice.Maps) {
value["照片"] = ice.Render(m, ice.RENDER_IMAGES, value["照片"], kit.Select("100", "400", msg.FieldsIsDetail()))
m.Push(m.OptionFields(), value, kit.Split(msg.OptionFields()))
})

View File

@ -51,7 +51,7 @@ func init() {
if len(arg) == 0 {
m.OptionFields("time,type,name,share")
m.Cmdy(mdb.SELECT, RIVER, _river_key(m, NODE), mdb.HASH)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
m.PushAnchor(value[mdb.NAME], m.MergeURL2("/chat/pod/"+kit.Keys(m.Option(ice.POD), value[mdb.NAME])))
})
m.RenameAppend("name", "pod")

View File

@ -24,7 +24,7 @@ func init() {
}, Hand: func(m *ice.Message, arg ...string) {
m.Fields(len(arg), "time,username")
m.Cmdy(mdb.SELECT, RIVER, _river_key(m, OCEAN), mdb.HASH, aaa.USERNAME, arg)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
msg := m.Cmd(aaa.USER, value[aaa.USERNAME])
m.Push(aaa.USERNICK, msg.Append(aaa.USERNICK))
m.PushImages(aaa.AVATAR, msg.Append(aaa.AVATAR), kit.Select("60", "240", m.FieldsIsDetail()))

View File

@ -29,7 +29,7 @@ func init() {
}},
mdb.INSERT: {Name: "insert zone type=hi name=hello text=world", Help: "发送", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.ZONE, m.Option(mdb.ZONE), arg[2:])
m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, ice.Option{"fields", "time,space"}).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, ice.Option{"fields", "time,space"}).Tables(func(value ice.Maps) {
m.Cmdy(web.SPACE, value[web.SPACE], "toast", m.Option("text"), m.Option("name"))
})
}},

View File

@ -81,7 +81,7 @@ func init() {
if m.Copy(msg); len(arg) > 1 { // 命令插件
m.ProcessField(arg[0], arg[1], ice.RUN)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
m.Cmdy(m.Space(value[ice.POD]), ctx.CONTEXT, value[ice.CTX], ctx.COMMAND, value[ice.CMD])
})
} else {

View File

@ -148,7 +148,7 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin
return true
}
func _website_search(m *ice.Message, kind, name, text string, arg ...string) {
m.Cmd(m.PrefixKey(), ice.OptionFields("")).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(m.PrefixKey(), ice.OptionFields("")).Tables(func(value ice.Maps) {
m.PushSearch(value, mdb.TEXT, m.MergeWebsite(value[nfs.PATH]))
})
}

View File

@ -4,12 +4,14 @@ import (
"encoding/base64"
"os"
"os/exec"
"path"
"strings"
"sync"
"time"
pty "shylinux.com/x/creackpty"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
kit "shylinux.com/x/toolkits"
@ -20,7 +22,7 @@ const XTERM = "xterm"
func init() {
cache := sync.Map{}
add := func(m *ice.Message, key string) string {
cmd := exec.Command(kit.Select("/bin/sh", m.Option(mdb.TYPE)))
cmd := exec.Command(cli.SystemFind(m, kit.Select("sh", m.Option(mdb.TYPE))))
cmd.Env = append(os.Environ(), "TERM=xterm")
tty, err := pty.Start(cmd)
@ -30,18 +32,19 @@ func init() {
m.Go(func() {
defer m.Cmd(m.PrefixKey(), mdb.PRUNES)
defer cache.Delete(key)
buf := make([]byte, ice.MOD_BUFS)
for {
if n, e := tty.Read(buf); !m.Warn(e) {
m.Option(mdb.HASH, key)
m.Optionv(ice.MSG_OPTS, kit.Simple(mdb.HASH))
m.Option(mdb.TEXT, base64.StdEncoding.EncodeToString(buf[:n]))
m.Option(ice.MSG_DAEMON, m.Conf(m.PrefixKey(), kit.Keys(mdb.HASH, key, mdb.META, mdb.TEXT)))
m.PushNoticeGrow(kit.Format(kit.Dict(mdb.TYPE, "data", mdb.TEXT, base64.StdEncoding.EncodeToString(buf[:n]))))
m.PushNoticeGrow("data")
} else {
break
}
}
m.PushNoticeGrow(kit.Format(kit.Dict(mdb.TYPE, "exit")))
m.PushNoticeGrow("exit")
})
return key
}
@ -61,18 +64,21 @@ func init() {
}
Index.MergeCommands(ice.Commands{
XTERM: {Name: "xterm hash id auto", Help: "终端", Actions: ice.MergeAction(ice.Actions{
XTERM: {Name: "xterm hash refresh", Help: "终端", Actions: ice.MergeAction(ice.Actions{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
if mdb.HashInputs(m, arg); arg[0] == mdb.TYPE {
m.Push(mdb.TYPE, "/usr/bin/python")
m.Push(mdb.TYPE, "/usr/bin/node")
m.Push(mdb.TYPE, "/bin/bash")
m.Push(mdb.TYPE, "/bin/sh")
switch mdb.HashInputs(m, arg); arg[0] {
case mdb.TYPE:
m.Push(arg[0], "python")
m.Push(arg[0], "node")
m.Push(arg[0], "bash")
m.Push(arg[0], "sh")
case mdb.NAME:
m.Push(arg[0], path.Base(m.Option(mdb.TYPE)))
}
}},
mdb.CREATE: {Name: "create type name", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
if m.Option(mdb.TEXT, m.Option(ice.MSG_DAEMON)) != "" {
m.Echo(add(m, mdb.HashCreate(m, m.OptionSimple("type,name,text")).Result()))
m.Echo(add(m, mdb.HashCreate(m, arg, m.OptionSimple(mdb.TEXT)).Result()))
}
}},
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
@ -106,7 +112,9 @@ func init() {
}},
"input": {Name: "input", Help: "输入", Hand: func(m *ice.Message, arg ...string) {
mdb.HashModify(m, m.OptionSimple(mdb.HASH), mdb.TIME, m.Time())
get(m, m.Option(mdb.HASH)).Write([]byte(strings.Join(arg, "")))
if b, e := base64.StdEncoding.DecodeString(strings.Join(arg, "")); m.Assert(e) {
get(m, m.Option(mdb.HASH)).Write(b)
}
}},
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,extra"), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...)

View File

@ -82,7 +82,7 @@ func init() {
}},
CHECK: {Name: "check", Help: "核算", Hand: func(m *ice.Message, arg ...string) {
if m.Option(ACCOUNT) == "" {
m.Cmd(ASSET).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(ASSET).Tables(func(value ice.Maps) {
_asset_check(m, value[ACCOUNT])
})
m.ProcessRefresh30ms()
@ -98,7 +98,7 @@ func init() {
m.PushAction(CHECK)
m.SortIntR(AMOUNT)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
amount += kit.Int(value[AMOUNT])
count += kit.Int(value[COUNT])
})
@ -106,7 +106,7 @@ func init() {
} else {
m.PushAction(mdb.PLUGIN)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
amount += kit.Int(value[AMOUNT])
count++
})

View File

@ -24,7 +24,7 @@ func init() {
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...)
amount, income, tax := 0, 0, 0
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
amount += kit.Int(value[AMOUNT])
income += kit.Int(value[INCOME])
tax += kit.Int(value[TAX])

View File

@ -25,7 +25,7 @@ func init() {
msg.SortTime(BEGIN_TIME)
tz := int64(8)
msg.Table(func(index int, value ice.Maps, head []string) {
msg.Tables(func(value ice.Maps) {
if value[mdb.STATUS] == CANCEL {
return
}

View File

@ -96,7 +96,7 @@ func init() {
}, mdb.ZoneAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
if mdb.ZoneSelect(m, arg...); len(arg) > 0 {
status := map[string]int{}
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
m.PushButton(_task_action(m, value[STATUS]))
status[value[mdb.STATUS]]++
})

View File

@ -49,7 +49,7 @@ func init() {
if arg[0] == mdb.FOREACH && arg[1] == "" {
m.PushSearch(mdb.TYPE, "shy", mdb.NAME, "src/main.shy", mdb.TEXT, m.MergeCmd(""))
}
m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH).Tables(func(value ice.Maps) {
if arg[1] == "" {
if value[mdb.TYPE] == SPARK {
value[mdb.TEXT] = ice.Render(m, ice.RENDER_SCRIPT, value[mdb.TEXT])

12
meta.go
View File

@ -331,16 +331,16 @@ func (m *Message) Sort(key string, arg ...string) *Message {
// 排序因子
number := map[int]int64{}
table := []Maps{}
m.Table(func(index int, line Maps, head []string) {
switch table = append(table, line); cmp {
m.Table(func(index int, value Maps, head []string) {
switch table = append(table, value); cmp {
case "int":
number[index] = kit.Int64(line[key])
number[index] = kit.Int64(value[key])
case "int_r":
number[index] = -kit.Int64(line[key])
number[index] = -kit.Int64(value[key])
case "time":
number[index] = int64(kit.Time(line[key]))
number[index] = int64(kit.Time(value[key]))
case "time_r":
number[index] = -int64(kit.Time(line[key]))
number[index] = -int64(kit.Time(value[key]))
}
})
compare := func(i, j int, op string) bool {

20
misc.go
View File

@ -309,23 +309,27 @@ func SplitCmd(name string) (list []Any) {
BUTTON = "button"
)
const (
RUN = "run"
LIST = "list"
BACK = "back"
AUTO = "auto"
PAGE = "page"
ARGS = "args"
REFRESH = "refresh"
RUN = "run"
LIST = "list"
BACK = "back"
AUTO = "auto"
PAGE = "page"
ARGS = "args"
)
item, button := kit.Dict(), false
ls := kit.Split(name, SP, ":=@")
for i := 1; i < len(ls); i++ {
switch ls[i] {
case REFRESH:
list = append(list, kit.Dict(TYPE, BUTTON, NAME, ls[i], ACTION, AUTO))
button = true
case RUN:
list = append(list, kit.Dict(TYPE, BUTTON, NAME, RUN))
list = append(list, kit.Dict(TYPE, BUTTON, NAME, ls[i]))
button = true
case LIST:
list = append(list, kit.Dict(TYPE, BUTTON, NAME, LIST, ACTION, AUTO))
list = append(list, kit.Dict(TYPE, BUTTON, NAME, ls[i], ACTION, AUTO))
button = true
case AUTO:
list = append(list, kit.Dict(TYPE, BUTTON, NAME, LIST, ACTION, AUTO))

View File

@ -71,7 +71,7 @@ func (a alpha) List(m *ice.Message, arg ...string) {
// 搜索词汇
msg := m.Cmd(cli.SYSTEM, "grep", "-rih", arg[1], m.Config(mdb.STORE))
msg.CSV(msg.Result(), kit.Split(m.Config(mdb.FIELD))...).Table(func(index int, value ice.Maps, head []string) {
msg.CSV(msg.Result(), kit.Split(m.Config(mdb.FIELD))...).Tables(func(value ice.Maps) {
if m.FieldsIsDetail() {
m.Push(mdb.DETAIL, value, kit.Split(m.Config(mdb.FIELD)))
m.Push(mdb.TIME, m.Time())

View File

@ -10,7 +10,7 @@ import (
func init() {
Index.Merge(&ice.Context{Commands: ice.Commands{
"/configs": {Name: "/configs", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
m.Cmd("web.code.git.configs").Table(func(index int, value ice.Maps, head []string) {
m.Cmd("web.code.git.configs").Tables(func(value ice.Maps) {
if strings.HasPrefix(value[mdb.NAME], "url") {
m.Echo(`git config --global "%s" "%s"`, value[mdb.NAME], value[mdb.VALUE])
m.Echo(ice.NL)

View File

@ -18,7 +18,7 @@ func init() {
"/favor": {Name: "/favor", Help: "收藏", Actions: ice.Actions{
mdb.EXPORT: {Name: "export zone name", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
m.Echo("#!/bin/sh\n\n")
m.Cmdy(FAVOR, m.Option(mdb.ZONE)).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(FAVOR, m.Option(mdb.ZONE)).Tables(func(value ice.Maps) {
if m.Option(mdb.NAME) == "" || m.Option(mdb.NAME) == value[mdb.NAME] {
m.Echo("# %v\n%v\n\n", value[mdb.NAME], value[mdb.TEXT])
}

View File

@ -23,7 +23,7 @@ func init() {
if m.Cmdy(SESS, arg); len(arg) > 0 && m.Append("grant") == "" {
m.Process("_confirm", "授权设备")
}
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
if value["grant"] == "" {
m.PushButton("confirm", mdb.REMOVE)
} else {

View File

@ -15,7 +15,7 @@ func init() {
word := list[kit.Int(m.Option("index"))]
switch arg[0] {
case "shy":
m.Cmd("web.code.input.find", word).Table(func(index int, value ice.Maps, head []string) {
m.Cmd("web.code.input.find", word).Tables(func(value ice.Maps) {
m.Echo(value["text"]).Echo(" ")
})

View File

@ -29,7 +29,7 @@ func (c change) List(m *ice.Message, arg ...string) {
c.send(m, kit.Slice(arg, 0, 2))
return
}
c.send(m.Spawn(), kit.Slice(arg, 0, 2), m.CommandKey(), kit.Slice(arg, 2)).Table(func(index int, value ice.Maps, head []string) {
c.send(m.Spawn(), kit.Slice(arg, 0, 2), m.CommandKey(), kit.Slice(arg, 2)).Tables(func(value ice.Maps) {
m.Push(mdb.TEXT, kit.ReplaceAll(value[mdb.TEXT], "<", "&lt;", ">", "&gt;"))
})
if len(arg) > 3 {

View File

@ -36,7 +36,7 @@ func (f field) Command(m *ice.Message, arg ...string) {
})
}
func (f field) Run(m *ice.Message, arg ...string) {
f.Zone.List(m.Spawn(), m.Option(tcp.HOST), arg[0]).Table(func(index int, value ice.Maps, head []string) {
f.Zone.List(m.Spawn(), m.Option(tcp.HOST), arg[0]).Tables(func(value ice.Maps) {
m.Cmdy(value[mdb.INDEX], arg[1:])
})
}

View File

@ -20,8 +20,8 @@ func (o operate) send(m *ice.Message, arg ...ice.Any) *ice.Message {
func (o operate) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case mdb.ZONE:
o.send(m.Spawn()).Table(func(index int, value ice.Maps, head []string) {
o.send(m.Spawn(), value[WID]).Table(func(index int, value ice.Maps, head []string) {
o.send(m.Spawn()).Tables(func(value ice.Maps) {
o.send(m.Spawn(), value[WID]).Tables(func(value ice.Maps) {
m.Push(mdb.ZONE, kit.ParseURL(value[URL]).Host)
})
}).Sort(mdb.ZONE)
@ -32,7 +32,7 @@ func (o operate) Spide(m *ice.Message, arg ...string) {
o.send(m, arg)
return
}
o.send(m, arg[:2], "spide").Table(func(index int, value ice.Maps, head []string) {
o.send(m, arg[:2], "spide").Tables(func(value ice.Maps) {
switch value[mdb.TYPE] {
case wiki.VIDEO:
m.PushVideos(mdb.SHOW, value[mdb.LINK])

View File

@ -19,7 +19,7 @@ func (s style) Inputs(m *ice.Message, arg ...string) {
s.operate.Inputs(m, arg...)
}
func (s style) Command(m *ice.Message, arg ...string) {
s.Zone.List(m, m.Option(tcp.HOST)).Table(func(index int, value ice.Maps, head []string) {
s.Zone.List(m, m.Option(tcp.HOST)).Tables(func(value ice.Maps) {
s.send(m, "1", m.Option(TID), m.CommandKey(), value[SELECTOR], value[PROPERTY])
})
}

View File

@ -55,7 +55,7 @@ func init() {
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Conf(REPOS, mdb.HASH, "")
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
m.Cmd(nfs.DIR, ice.USR, "name,path").Table(func(index int, value ice.Maps, head []string) {
m.Cmd(nfs.DIR, ice.USR, "name,path").Tables(func(value ice.Maps) {
_repos_insert(m, value[mdb.NAME], value[nfs.PATH])
})
cli.IsAlpine(m, "git", "apk add git")

View File

@ -182,7 +182,7 @@ func init() {
m.Cmdy(cli.SYSTEM, GIT, INIT, "--bare", m.Option(mdb.NAME))
}},
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(REPOS, ice.OptionFields("time,name,path")).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(REPOS, ice.OptionFields("time,name,path")).Tables(func(value ice.Maps) {
remote := strings.Split(m.MergeURL2("/x/"+value[REPOS]), "?")[0]
m.Option(cli.CMD_DIR, value[nfs.PATH])
m.Cmd(cli.SYSTEM, GIT, PUSH, remote, MASTER)
@ -195,7 +195,7 @@ func init() {
}},
}, Hand: func(m *ice.Message, arg ...string) {
if m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_REPOS); len(arg) == 0 {
m.Cmdy(nfs.DIR, nfs.PWD).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(nfs.DIR, nfs.PWD).Tables(func(value ice.Maps) {
m.PushScript("git clone " + m.MergeLink("/x/"+strings.TrimSuffix(value[nfs.PATH], ice.PS)))
})
m.Cut("time,path,size,script,action")

View File

@ -117,7 +117,7 @@ func init() {
if len(arg) == 1 { // 目录列表
m.Option(nfs.DIR_DEEP, ice.TRUE)
color := []string{cli.YELLOW, cli.BLUE, cli.CYAN, cli.RED}
nfs.Dir(m, nfs.PATH).Table(func(index int, value ice.Maps, head []string) {
nfs.Dir(m, nfs.PATH).Tables(func(value ice.Maps) {
m.Push(cli.COLOR, color[strings.Count(value[nfs.PATH], ice.PS)%len(color)])
})
return

View File

@ -27,7 +27,7 @@ func _status_tag(m *ice.Message, tags string) string {
}
func _status_tags(m *ice.Message, repos string) {
vs := ice.Maps{}
m.Cmd(STATUS).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(STATUS).Tables(func(value ice.Maps) {
if value[mdb.TYPE] == "##" {
if value[REPOS] == ice.RELEASE {
value[REPOS] = ice.ICE
@ -92,7 +92,7 @@ func _status_each(m *ice.Message, title string, cmds ...string) {
toast(cli.BEGIN, count, total)
list := []string{}
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(REPOS, ice.OptionFields("name,path")).Tables(func(value ice.Maps) {
toast(value[REPOS], count, total)
if msg := m.Cmd(cmds, ice.Option{cli.CMD_DIR, value[nfs.PATH]}); !cli.IsSuccess(msg) {
@ -126,7 +126,7 @@ func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
return files, adds, dels
}
func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(REPOS, ice.OptionFields("name,path")).Tables(func(value ice.Maps) {
m.Option(cli.CMD_DIR, value[nfs.PATH])
diff := m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb")
tags := m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags")

View File

@ -29,7 +29,7 @@ func init() {
TOTAL: {Name: "total repos auto pie", Help: "统计量", Actions: ice.Actions{
PIE: {Name: "pie", Help: "饼图", Hand: func(m *ice.Message, arg ...string) {
defer m.Display("/plugin/story/pie.js")
m.Cmd(TOTAL).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(TOTAL).Tables(func(value ice.Maps) {
if value[REPOS] == "total" {
m.StatusTimeCount(REPOS, "total", "value", "1", "total", value["rest"])
return
@ -41,7 +41,7 @@ func init() {
}, Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 0 { // 提交详情
arg[0] = kit.Replace(arg[0], "src", "contexts")
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(REPOS, ice.OptionFields("name,path")).Tables(func(value ice.Maps) {
if value[REPOS] == arg[0] {
m.Cmdy("_sum", value[nfs.PATH], arg[1:])
}
@ -62,7 +62,7 @@ func init() {
mu.Lock()
defer mu.Unlock()
msg.Table(func(index int, value ice.Maps, head []string) {
msg.Tables(func(value ice.Maps) {
if kit.Int(value["days"]) > days {
days = kit.Int(value["days"])
}

View File

@ -38,7 +38,7 @@ func (w wubi) Input(m *ice.Message, arg ...string) {
}
m.Option(ice.CACHE_LIMIT, "10")
m.Cmd(w, "word", arg[0]).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(w, "word", arg[0]).Tables(func(value ice.Maps) {
m.Echo(value[mdb.TEXT] + ice.NL)
})
}

View File

@ -21,8 +21,8 @@ func init() {
text, link, list := kit.Select("", arg, 3), kit.MergeURL2(m.Conf(web.SHARE, kit.Keym("domain")), "/chat/lark/sso"), []string{}
if len(arg) == 0 {
m.Cmd("web.chat./river").Table(func(index int, val ice.Maps, head []string) {
m.Cmd("web.chat./river", val[mdb.HASH], chat.STORM).Table(func(index int, value ice.Maps, head []string) {
m.Cmd("web.chat./river").Tables(func(val ice.Maps) {
m.Cmd("web.chat./river", val[mdb.HASH], chat.STORM).Tables(func(value ice.Maps) {
list = append(list, kit.Keys(val[mdb.NAME], value[mdb.NAME]),
ice.CMD, kit.Format([]string{HOME, val[mdb.HASH], value[mdb.HASH], val[mdb.NAME] + "." + value[mdb.NAME]}))
})
@ -31,7 +31,7 @@ func init() {
m.Option(ice.MSG_RIVER, arg[0])
m.Option(ice.MSG_STORM, arg[1])
link = kit.MergeURL(link, chat.RIVER, arg[0], chat.STORM, arg[1])
m.Cmd("web.chat./river", arg[0], chat.STORM, arg[1]).Table(func(index int, value ice.Maps, head []string) {
m.Cmd("web.chat./river", arg[0], chat.STORM, arg[1]).Tables(func(value ice.Maps) {
list = append(list, value[ice.CMD], ice.CMD, kit.Keys(value[ice.CTX], value[ice.CMD]))
})
}

View File

@ -101,7 +101,7 @@ func init() {
m.Action(mdb.PRUNES)
mdb.HashSelect(m, arg...)
m.Set(ice.MSG_APPEND, ctx.ACTION)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
m.PushButton(kit.Select("", ctx.COMMAND, value[mdb.STATUS] == tcp.OPEN), mdb.REMOVE)
})
return

View File

@ -204,7 +204,7 @@ func init() {
})
}},
}, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
m.PushButton(kit.Select("", "command,session", value[mdb.STATUS] == tcp.OPEN), mdb.REMOVE)
})
if len(arg) == 0 {

View File

@ -34,7 +34,7 @@ func init() {
))
}},
mdb.EXPORT: {Name: "export key=.ssh/id_rsa pub=.ssh/id_rsa.pub", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(m.PrefixKey(), m.Option(mdb.HASH)).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(m.PrefixKey(), m.Option(mdb.HASH)).Tables(func(value ice.Maps) {
m.Cmdx(nfs.SAVE, kit.HomePath(m.Option("key")), value[PRIVATE])
m.Cmdx(nfs.SAVE, kit.HomePath(m.Option("pub")), value[PUBLIC])
})

View File

@ -31,7 +31,7 @@ func _ssh_config(m *ice.Message, h string) *ssh.ServerConfig {
m.Log_AUTH(tcp.HOSTPORT, conn.RemoteAddr(), aaa.USERNAME, conn.User())
err = nil // 本机用户
} else {
m.Cmd(mdb.SELECT, SERVICE, kit.Keys(mdb.HASH, h), mdb.LIST).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(mdb.SELECT, SERVICE, kit.Keys(mdb.HASH, h), mdb.LIST).Tables(func(value ice.Maps) {
if !strings.HasPrefix(value[mdb.NAME], conn.User()+"@") {
return
}
@ -135,7 +135,7 @@ func init() {
}},
mdb.EXPORT: {Name: "export authkey=.ssh/authorized_keys", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
list := []string{}
m.Cmd(mdb.SELECT, SERVICE, kit.Keys(mdb.HASH, kit.Hashs(m.Option(tcp.PORT))), mdb.LIST).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(mdb.SELECT, SERVICE, kit.Keys(mdb.HASH, kit.Hashs(m.Option(tcp.PORT))), mdb.LIST).Tables(func(value ice.Maps) {
list = append(list, fmt.Sprintf("%s %s %s", value[mdb.TYPE], value[mdb.TEXT], value[mdb.NAME]))
})

View File

@ -76,7 +76,7 @@ func init() {
}},
}, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
m.PushButton(kit.Select("", ctx.COMMAND, value[mdb.STATUS] == tcp.OPEN), mdb.REMOVE)
})
return
@ -85,7 +85,7 @@ func init() {
m.Action(ctx.COMMAND, mdb.PAGE)
m.OptionPage(kit.Slice(arg, 2)...)
m.Fields(len(kit.Slice(arg, 1, 2)), "time,id,type,text")
mdb.ZoneSelect(m, kit.Slice(arg, 0, 2)...).Table(func(index int, value ice.Maps, head []string) {
mdb.ZoneSelect(m, kit.Slice(arg, 0, 2)...).Tables(func(value ice.Maps) {
m.PushButton(kit.Select("", mdb.REPEAT, value[mdb.TYPE] == CMD))
})
}},

View File

@ -129,7 +129,7 @@ func init() {
}},
SCRIPT: {Name: "script name", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(SCRIPT, m.Option(mdb.NAME)).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(SCRIPT, m.Option(mdb.NAME)).Tables(func(value ice.Maps) {
switch value[mdb.TYPE] {
case "shell":
for _, line := range kit.Split(value[mdb.TEXT], ice.NL, ice.NL, ice.NL) {
@ -170,7 +170,7 @@ func init() {
// 会话列表
m.Split(m.Cmdx(cli.SYSTEM, TMUX, "list-session", "-F", m.Config(FORMAT)), m.Config(FIELDS), ice.FS, ice.NL)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
switch value["tag"] {
case "1":
m.PushButton("")

View File

@ -21,7 +21,7 @@ func init() {
}, Commands: ice.Commands{
"/favor": {Name: "/favor", Help: "收藏", Actions: ice.Actions{
mdb.SELECT: {Name: "select", Help: "主题", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(FAVOR).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(FAVOR).Tables(func(value ice.Maps) {
m.Echo(value[mdb.ZONE]).Echo(ice.NL)
})
}},
@ -29,7 +29,7 @@ func init() {
m.Cmd(FAVOR, mdb.INSERT)
}},
}, Hand: func(m *ice.Message, arg ...string) {
m.Cmd(FAVOR, m.Option(mdb.ZONE)).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(FAVOR, m.Option(mdb.ZONE)).Tables(func(value ice.Maps) {
m.Echo("%v\n", m.Option(mdb.ZONE)).Echo("%v:%v:%v:(%v): %v\n",
value[nfs.FILE], value[nfs.LINE], "1", value[mdb.NAME], value[mdb.TEXT])
})

View File

@ -19,7 +19,7 @@ func init() {
FAVOR: {Name: "favor text:text auto create", Help: "收藏", Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create type name text", Help: "添加"},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
m.PushQRCode(mdb.SCAN, kit.MergeURL(m.Config(mdb.LINK), aaa.USERNAME, value[mdb.TEXT]))
})
}},

View File

@ -19,13 +19,13 @@ func _wx_action(m *ice.Message) {
`, m.Option("ToUserName"), m.Option("FromUserName"), m.Option("CreateTime"), "news")
count := 0
m.Table(func(index int, value ice.Maps, head []string) { count++ })
m.Tables(func(value ice.Maps) { count++ })
m.Echo(`<ArticleCount>%d</ArticleCount>`, count)
share := m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN)
m.Echo(`<Articles>`)
m.Table(func(index int, value ice.Maps, head []string) {
m.Tables(func(value ice.Maps) {
m.Echo(`<item>
<Title><![CDATA[%s]]></Title>
<Description><![CDATA[%s]]></Description>

View File

@ -181,10 +181,15 @@ func (m *Message) Toast(text string, arg ...Any) { // [title [duration [progress
m.PushNoticeToast("", text, arg)
}
func (m *Message) PushNotice(arg ...Any) {
m.Optionv(MSG_OPTS, m.meta[MSG_OPTION])
if m.Option(MSG_USERPOD) == "" {
m.Cmd(SPACE, m.Option(MSG_DAEMON), arg)
} else {
m.Cmd("web.spide", OPS, m.MergeURL2("/share/toast/"), kit.Format(kit.Dict("hash", m.Option("hash"), POD, m.Option(MSG_DAEMON), "cmds", kit.Simple(arg...))))
opts := kit.Dict(POD, m.Option(MSG_DAEMON), "cmds", kit.Simple(arg...))
for _, k := range m.meta[MSG_OPTS] {
opts[k] = m.Option(k)
}
m.Cmd("web.spide", OPS, m.MergeURL2("/share/toast/"), kit.Format(opts))
}
}
func (m *Message) PushNoticeGrow(arg ...Any) {