From 34ffc9bf7358749711d1f9fde2c208efb65aa323 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sat, 9 Jul 2022 20:13:21 +0800 Subject: [PATCH] opt css --- base/aaa/role.go | 6 +++--- base/aaa/sess.go | 6 +++--- base/aaa/totp.go | 8 +++---- base/aaa/user.go | 6 +++--- base/cli/daemon.go | 10 ++++----- base/cli/forever.go | 4 ++-- base/cli/mirrors.go | 4 ++-- base/cli/qrcode.go | 4 ++-- base/cli/runtime.go | 8 +++---- base/cli/system.go | 6 +++--- base/ctx/command.go | 11 ++++++---- base/ctx/config.go | 6 +++--- base/ctx/context.go | 6 +++--- base/ctx/message.go | 2 +- base/gdb/event.go | 8 +++---- base/gdb/gdb.go | 2 +- base/gdb/routine.go | 6 +++--- base/gdb/signal.go | 8 +++---- base/gdb/timer.go | 6 +++--- base/lex/matrix.go | 6 +++--- base/lex/split.go | 4 ++-- base/log/log.go | 4 ++-- base/mdb/engine.go | 6 +++--- base/mdb/hash.go | 36 +++++++++++++++++++++---------- base/mdb/list.go | 4 ++-- base/mdb/mdb.go | 2 +- base/mdb/plugin.go | 6 +++--- base/mdb/render.go | 6 +++--- base/mdb/search.go | 6 +++--- base/mdb/zone.go | 12 +++++------ base/nfs/cat.go | 6 +++--- base/nfs/dir.go | 10 ++++----- base/nfs/find.go | 2 +- base/nfs/grep.go | 2 +- base/nfs/save.go | 2 +- base/nfs/tail.go | 8 +++---- base/nfs/tar.go | 4 ++-- base/nfs/trash.go | 8 +++---- base/ssh/scripts.go | 6 +++--- base/tcp/client.go | 8 +++---- base/tcp/host.go | 8 +++---- base/tcp/port.go | 8 +++---- base/tcp/server.go | 8 +++---- base/web/broad.go | 6 +++--- base/web/cache.go | 8 +++---- base/web/dream.go | 10 ++++----- base/web/route.go | 16 +++++++------- base/web/serve.go | 8 +++---- base/web/share.go | 6 +++--- base/web/space.go | 12 +++++------ base/web/spide.go | 19 +++++++++-------- base/web/story.go | 10 ++++----- base/yac/matrix.go | 6 +++--- base/yac/script.go | 10 ++++----- core/chat/action.go | 6 +++--- core/chat/cmd.go | 8 +++---- core/chat/div.go | 8 +++---- core/chat/files.go | 8 +++---- core/chat/footer.go | 6 +++--- core/chat/grant.go | 4 ++-- core/chat/header.go | 13 ++++++++---- core/chat/info.go | 4 ++-- core/chat/location.go | 8 +++---- core/chat/meet.go | 10 ++++----- core/chat/node.go | 6 +++--- core/chat/oauth/oauth.go | 20 +++++++++--------- core/chat/ocean.go | 6 +++--- core/chat/paste.go | 6 +++--- core/chat/pod.go | 6 +++--- core/chat/river.go | 4 ++-- core/chat/room.go | 10 ++++----- core/chat/scan.go | 6 +++--- core/chat/search.go | 4 ++-- core/chat/sso.go | 2 +- core/chat/storm.go | 6 +++--- core/chat/trans.go | 4 ++-- core/chat/website.go | 12 +++++------ core/code/autogen.go | 4 ++-- core/code/bench.go | 4 ++-- core/code/binpack.go | 12 +++++------ core/code/c.go | 8 +++---- core/code/case.go | 10 ++++----- core/code/compile.go | 6 +++--- core/code/favor.go | 4 ++-- core/code/go.go | 20 +++++++++--------- core/code/inner.go | 12 +++++------ core/code/install.go | 18 ++++++++-------- core/code/js.go | 8 +++---- core/code/oauth.go | 8 +++---- core/code/pprof.go | 10 ++++----- core/code/publish.go | 6 +++--- core/code/py.go | 6 +++--- core/code/sh.go | 6 +++--- core/code/shy.go | 6 +++--- core/code/template.go | 4 ++-- core/code/upgrade.go | 6 +++--- core/code/vimer.go | 4 ++-- core/code/webpack.go | 10 ++++----- core/code/zml.go | 6 +++--- core/mall/asset.go | 12 +++++------ core/mall/salary.go | 8 +++---- core/team/count.go | 6 +++--- core/team/plan.go | 4 ++-- core/team/task.go | 8 +++---- core/team/todo.go | 4 ++-- core/wiki/brief.go | 4 ++-- core/wiki/chart.go | 4 ++-- core/wiki/data.go | 6 +++--- core/wiki/draw.go | 6 +++--- core/wiki/feel.go | 6 +++--- core/wiki/field.go | 6 +++--- core/wiki/image.go | 6 +++--- core/wiki/local.go | 4 ++-- core/wiki/order.go | 4 ++-- core/wiki/parse.go | 2 +- core/wiki/refer.go | 4 ++-- core/wiki/shell.go | 4 ++-- core/wiki/spark.go | 6 +++--- core/wiki/table.go | 8 +++---- core/wiki/title.go | 4 ++-- core/wiki/video.go | 6 +++--- core/wiki/word.go | 10 ++++----- info.go | 8 +++---- meta.go | 42 ++++++++++++++++++++----------------- misc.go | 18 ++++++++-------- misc/alpha/alpha.go | 2 +- misc/bash/bash.go | 6 +++--- misc/bash/configs.go | 4 ++-- misc/bash/download.go | 2 +- misc/bash/favor.go | 10 ++++----- misc/bash/grant.go | 6 +++--- misc/bash/input.go | 4 ++-- misc/bash/run.go | 4 ++-- misc/bash/sess.go | 8 +++---- misc/bash/sync.go | 8 +++---- misc/bash/trash.go | 10 ++++----- misc/bash/zsh.go | 6 +++--- misc/chrome/change.go | 2 +- misc/chrome/field.go | 4 ++-- misc/chrome/operate.go | 6 +++--- misc/chrome/style.go | 2 +- misc/coder/server.go | 4 ++-- misc/git/configs.go | 8 +++---- misc/git/count.go | 4 ++-- misc/git/git.go | 6 +++--- misc/git/repos.go | 8 +++---- misc/git/server.go | 10 ++++----- misc/git/spide.go | 6 +++--- misc/git/status.go | 12 +++++------ misc/git/total.go | 12 +++++------ misc/git/trend.go | 4 ++-- misc/input/wubi.go | 2 +- misc/java/spring.go | 2 +- misc/lark/app.go | 6 +++--- misc/lark/company.go | 2 +- misc/lark/duty.go | 2 +- misc/lark/employee.go | 2 +- misc/lark/event.go | 4 ++-- misc/lark/form.go | 2 +- misc/lark/group.go | 2 +- misc/lark/home.go | 8 +++---- misc/lark/msg.go | 4 ++-- misc/lark/rand.go | 2 +- misc/lark/send.go | 2 +- misc/lark/sso.go | 2 +- misc/lark/talk.go | 4 ++-- misc/mp/login.go | 8 +++---- misc/ssh/channel.go | 10 ++++----- misc/ssh/connect.go | 8 +++---- misc/ssh/rsa.go | 8 +++---- misc/ssh/service.go | 14 ++++++------- misc/ssh/service_darwin.go | 2 +- misc/ssh/service_linux.go | 2 +- misc/ssh/service_windows.go | 4 ++-- misc/ssh/session.go | 10 ++++----- misc/tmux/buffer.go | 10 ++++----- misc/tmux/script.go | 6 +++--- misc/tmux/session.go | 10 ++++----- misc/tmux/tmux.go | 6 +++--- misc/vim/favor.go | 12 +++++------ misc/vim/input.go | 6 +++--- misc/vim/sess.go | 8 +++---- misc/vim/sync.go | 6 +++--- misc/vim/tags.go | 12 +++++------ misc/vim/vim.go | 6 +++--- misc/vim/vimrc.go | 6 +++--- misc/wework/bot.go | 6 +++--- misc/wx/access.go | 6 +++--- misc/wx/event.go | 6 +++--- misc/wx/favor.go | 8 +++---- misc/wx/login.go | 6 +++--- misc/wx/menu.go | 10 ++++----- misc/wx/text.go | 6 +++--- render.go | 20 +++++++++--------- type.go | 25 +++++++++++++--------- 195 files changed, 714 insertions(+), 682 deletions(-) diff --git a/base/aaa/role.go b/base/aaa/role.go index 7a102bb8..52abfc49 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -91,10 +91,10 @@ const ( const ROLE = "role" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ROLE: {Name: ROLE, Help: "角色", Value: kit.Data(mdb.SHORT, mdb.NAME)}, - }, Commands: map[string]*ice.Command{ - ROLE: {Name: "role role auto insert", Help: "角色", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + ROLE: {Name: "role role auto insert", Help: "角色", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Rich(ROLE, nil, kit.Dict(mdb.NAME, TECH, BLACK, kit.Dict(), WHITE, kit.Dict())) m.Rich(ROLE, nil, kit.Dict(mdb.NAME, VOID, WHITE, kit.Dict(), BLACK, kit.Dict())) diff --git a/base/aaa/sess.go b/base/aaa/sess.go index 3318063d..e5452dc4 100644 --- a/base/aaa/sess.go +++ b/base/aaa/sess.go @@ -70,12 +70,12 @@ const ( const SESS = "sess" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SESS: {Name: SESS, Help: "会话", Value: kit.Data( mdb.SHORT, "uniq", mdb.FIELD, "time,hash,userrole,username,usernick,ip,ua", mdb.EXPIRE, "720h", )}, - }, Commands: map[string]*ice.Command{ - SESS: {Name: "sess hash auto prunes", Help: "会话", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SESS: {Name: "sess hash auto prunes", Help: "会话", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create username", Help: "创建"}, }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) diff --git a/base/aaa/totp.go b/base/aaa/totp.go index fd98c453..e6c35018 100644 --- a/base/aaa/totp.go +++ b/base/aaa/totp.go @@ -53,12 +53,12 @@ const ( const TOTP = "totp" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TOTP: {Name: TOTP, Help: "令牌", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,secret,period,number", mdb.LINK, "otpauth://totp/%s?secret=%s", )}, - }, Commands: map[string]*ice.Command{ - TOTP: {Name: "totp name auto create", Help: "令牌", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + TOTP: {Name: "totp name auto create", Help: "令牌", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create name=hi secret period=30 number=6", Help: "添加", Hand: func(m *ice.Message, arg ...string) { if m.Option(SECRET) == "" { // 创建密钥 m.Option(SECRET, _totp_gen(kit.Int64(m.Option(PERIOD)))) @@ -67,7 +67,7 @@ func init() { m.Cmd(mdb.INSERT, TOTP, "", mdb.HASH, m.OptionSimple(mdb.NAME, SECRET, PERIOD, NUMBER)) }}, }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { - mdb.HashSelect(m.Spawn(), arg...).Tables(func(value map[string]string) { + mdb.HashSelect(m.Spawn(), arg...).Tables(func(value ice.Maps) { if len(arg) > 0 { m.OptionFields(mdb.DETAIL) } diff --git a/base/aaa/user.go b/base/aaa/user.go index 30e8fa29..98968d0d 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -114,12 +114,12 @@ const ( const USER = "user" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ USER: {Name: USER, Help: "用户", Value: kit.Data( mdb.SHORT, USERNAME, mdb.FIELD, "time,userrole,username,usernick,userzone", )}, - }, Commands: map[string]*ice.Command{ - USER: {Name: "user username auto create", Help: "用户", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + USER: {Name: "user username auto create", Help: "用户", Actions: ice.MergeAction(ice.Actions{ mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { if arg[0] == USER { _user_search(m, arg[1], kit.Select("", arg, 2)) diff --git a/base/cli/daemon.go b/base/cli/daemon.go index 96170b82..fccc20b1 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -101,12 +101,12 @@ const ( const DAEMON = "daemon" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ DAEMON: {Name: DAEMON, Help: "守护进程", Value: kit.Data( nfs.PATH, ice.USR_LOCAL_DAEMON, mdb.FIELD, "time,hash,status,pid,cmd,dir,env", )}, - }, Commands: map[string]*ice.Command{ - DAEMON: {Name: "daemon hash auto start prunes", Help: "守护进程", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + DAEMON: {Name: "daemon hash auto start prunes", Help: "守护进程", Actions: ice.MergeAction(ice.Actions{ ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.PRUNES, DAEMON, "", mdb.HASH, mdb.CACHE_CLEAR_ON_EXIT, ice.TRUE) }}, @@ -125,7 +125,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 map[string]string, head []string) { + m.Cmd(mdb.SELECT, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH)).Table(func(index int, value ice.Maps, head []string) { m.Cmd(mdb.MODIFY, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH), STATUS, STOP) m.Cmdy(SYSTEM, KILL, value[PID]) }) @@ -134,7 +134,7 @@ func init() { } }}, }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { - mdb.HashSelect(m, arg...).Set(ctx.ACTION).Table(func(index int, value map[string]string, head []string) { + mdb.HashSelect(m, arg...).Set(ctx.ACTION).Table(func(index int, value ice.Maps, head []string) { switch value[STATUS] { case START: m.PushButton(RESTART, STOP) diff --git a/base/cli/forever.go b/base/cli/forever.go index 492087b5..a4a92945 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -26,8 +26,8 @@ const FOREVER = "forever" func init() { const SERVE = "serve" const RESTART = "restart" - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - FOREVER: {Name: "forever auto", Help: "启动", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + FOREVER: {Name: "forever auto", Help: "启动", Actions: ice.Actions{ RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) { _forever_kill(m, "INT") }}, diff --git a/base/cli/mirrors.go b/base/cli/mirrors.go index 8e2188b3..af1f0ef8 100644 --- a/base/cli/mirrors.go +++ b/base/cli/mirrors.go @@ -28,8 +28,8 @@ const ( const MIRRORS = "mirrors" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - MIRRORS: {Name: "mirrors cli auto", Help: "软件镜像", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + MIRRORS: {Name: "mirrors cli auto", Help: "软件镜像", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Go(func() { m.Sleep("1s") diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index 2579d7b5..e1096654 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -129,8 +129,8 @@ const ( const QRCODE = "qrcode" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - QRCODE: {Name: "qrcode text@key fg@key bg@key size auto", Help: "二维码", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + QRCODE: {Name: "qrcode text@key fg@key bg@key size auto", Help: "二维码", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.AddRender(ice.RENDER_QRCODE, func(m *ice.Message, cmd string, args ...ice.Any) string { return m.Cmd(QRCODE, kit.Simple(args...)).Result() diff --git a/base/cli/runtime.go b/base/cli/runtime.go index c68b49d7..2289ecfc 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -74,7 +74,7 @@ func _runtime_hostinfo(m *ice.Message) { m.Push("uptime", kit.Split(m.Cmdx(SYSTEM, "uptime"), ice.FS)[0]) } func _runtime_diskinfo(m *ice.Message) { - m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", ice.SP, ice.NL).Table(func(index int, value map[string]string, head []string) { + m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", ice.SP, ice.NL).Table(func(index int, value ice.Maps, head []string) { if strings.HasPrefix(value["Filesystem"], "/dev") { m.Push("", value, head) } @@ -151,10 +151,10 @@ const ( const RUNTIME = "runtime" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ RUNTIME: {Name: RUNTIME, Help: "运行环境", Value: kit.Dict()}, - }, Commands: map[string]*ice.Command{ - RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,bootinfo,diskinfo,env,file,route auto", Help: "运行环境", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,bootinfo,diskinfo,env,file,route auto", Help: "运行环境", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(RUNTIME, MAXPROCS, "1") _runtime_init(m) diff --git a/base/cli/system.go b/base/cli/system.go index 94d9aa3d..2fd0a26b 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -147,10 +147,10 @@ const ( const SYSTEM = "system" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SYSTEM: {Name: SYSTEM, Help: "系统命令", Value: kit.Data(mdb.FIELD, "time,id,cmd")}, - }, Commands: map[string]*ice.Command{ - SYSTEM: {Name: "system cmd run", Help: "系统命令", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + SYSTEM: {Name: "system cmd run", Help: "系统命令", Actions: ice.Actions{ nfs.FIND: {Name: "find", Help: "查找", Hand: func(m *ice.Message, arg ...string) { m.Echo(_system_find(m, arg[0], arg[1:]...)) }}, diff --git a/base/ctx/command.go b/base/ctx/command.go index 911720ee..8d916e51 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -72,14 +72,17 @@ func _command_search(m *ice.Message, kind, name, text string) { }) } -func CmdAction(args ...ice.Any) map[string]*ice.Action { - return map[string]*ice.Action{ice.CTX_INIT: mdb.AutoConfig(args...), +func CmdAction(args ...ice.Any) ice.Actions { + return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...), COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { if !m.PodCmd(COMMAND, arg) { m.Cmdy(COMMAND, arg) } }}, ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { + if len(arg) > 3 && arg[1] == "action" && arg[2] == "config" && arg[3] == "reset" { + m.Cmd("config", "reset", arg[0]) + } if m.Right(arg) && !m.PodCmd(arg) { m.Cmdy(arg) } @@ -99,8 +102,8 @@ const ( const COMMAND = "command" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Prefix(COMMAND)) m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, COMMAND) diff --git a/base/ctx/config.go b/base/ctx/config.go index 24eaa177..bf3d7868 100644 --- a/base/ctx/config.go +++ b/base/ctx/config.go @@ -99,10 +99,10 @@ const ( const CONFIG = "config" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ CONFIG: {Name: CONFIG, Help: "配置", Value: kit.Data(nfs.PATH, ice.VAR_CONF)}, - }, Commands: map[string]*ice.Command{ - CONFIG: {Name: "config key auto reset", Help: "配置", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + CONFIG: {Name: "config key auto reset", Help: "配置", Actions: ice.Actions{ SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _config_save(m, arg[0], arg[1:]...) }}, diff --git a/base/ctx/context.go b/base/ctx/context.go index 7f7d5c35..10c5f27d 100644 --- a/base/ctx/context.go +++ b/base/ctx/context.go @@ -38,15 +38,15 @@ func Inputs(m *ice.Message, field string) bool { const CONTEXT = "context" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - CONTEXT: {Name: "context name=web action=context,command,config key auto spide", Help: "模块", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + CONTEXT: {Name: "context name=web action=context,command,config key auto spide", Help: "模块", Actions: ice.MergeAction(ice.Actions{ "spide": {Name: "spide", Help: "架构图", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[1] == CONTEXT { // 模块列表 m.Cmdy(CONTEXT, kit.Select(ice.ICE, arg, 0), CONTEXT) 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 map[string]string, head []string) { + m.Cmdy(CONTEXT, index, COMMAND).Table(func(i int, value ice.Maps, head []string) { m.Push("file", arg[1]) }) diff --git a/base/ctx/message.go b/base/ctx/message.go index f5028163..ef312d9b 100644 --- a/base/ctx/message.go +++ b/base/ctx/message.go @@ -12,7 +12,7 @@ import ( const MESSAGE = "message" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ MESSAGE: {Name: "message", Help: "消息", Hand: func(m *ice.Message, arg ...string) { t := reflect.TypeOf(m) for i := 0; i < t.NumMethod(); i++ { diff --git a/base/gdb/event.go b/base/gdb/event.go index 72628871..634abef1 100644 --- a/base/gdb/event.go +++ b/base/gdb/event.go @@ -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 map[string]string, head []string) { + mdb.ZoneSelect(m, event).Table(func(index int, value ice.Maps, head []string) { m.Cmd(kit.Split(value[ice.CMD]), event, arg).Cost(EVENT, event, ice.ARG, arg) }) } @@ -19,10 +19,10 @@ func _event_action(m *ice.Message, event string, arg ...string) { const EVENT = "event" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ EVENT: {Name: EVENT, Help: "事件流", Value: kit.Data(mdb.SHORT, EVENT, mdb.FIELD, "time,id,cmd")}, - }, Commands: map[string]*ice.Command{ - EVENT: {Name: "event event id auto listen", Help: "事件流", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + EVENT: {Name: "event event id auto listen", Help: "事件流", Actions: ice.MergeAction(ice.Actions{ LISTEN: {Name: "listen event cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) { _event_listen(m, m.Option(EVENT), m.Option(ice.CMD)) }}, diff --git a/base/gdb/gdb.go b/base/gdb/gdb.go index 5bafee78..899037d3 100644 --- a/base/gdb/gdb.go +++ b/base/gdb/gdb.go @@ -45,7 +45,7 @@ func (f *Frame) Close(m *ice.Message, arg ...string) bool { const GDB = "gdb" -var Index = &ice.Context{Name: GDB, Help: "事件模块", Commands: map[string]*ice.Command{ +var Index = &ice.Context{Name: GDB, Help: "事件模块", Commands: ice.Commands{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Load(TIMER) }}, diff --git a/base/gdb/routine.go b/base/gdb/routine.go index eaeef50f..af0acd44 100644 --- a/base/gdb/routine.go +++ b/base/gdb/routine.go @@ -12,10 +12,10 @@ import ( const ROUTINE = "routine" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ROUTINE: {Name: ROUTINE, Help: "协程池", Value: kit.Data(mdb.SHORT, "time,hash,status,fileline")}, - }, Commands: map[string]*ice.Command{ - ROUTINE: {Name: "routine hash auto prunes", Help: "协程池", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + ROUTINE: {Name: "routine hash auto prunes", Help: "协程池", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create fileline status", Help: "创建"}, mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) { m.OptionFields(m.Config(mdb.SHORT)) diff --git a/base/gdb/signal.go b/base/gdb/signal.go index b222c334..13aea35e 100644 --- a/base/gdb/signal.go +++ b/base/gdb/signal.go @@ -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 map[string]string, head []string) { + mdb.HashSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, head []string) { m.Cmdy(kit.Split(value[ice.CMD])) }) } @@ -45,12 +45,12 @@ const ( const SIGNAL = "signal" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SIGNAL: {Name: SIGNAL, Help: "信号器", Value: kit.Data( mdb.SHORT, SIGNAL, mdb.FIELD, "time,signal,name,cmd", nfs.PATH, path.Join(ice.VAR_RUN, "ice.pid"), )}, - }, Commands: map[string]*ice.Command{ - SIGNAL: {Name: "signal signal auto listen", Help: "信号器", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SIGNAL: {Name: "signal signal auto listen", Help: "信号器", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { if log.LogDisable { return // 禁用日志 diff --git a/base/gdb/timer.go b/base/gdb/timer.go index cebc3de8..493d8d80 100644 --- a/base/gdb/timer.go +++ b/base/gdb/timer.go @@ -41,12 +41,12 @@ const ( const TIMER = "timer" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TIMER: {Name: TIMER, Help: "定时器", Value: kit.Data( mdb.FIELD, "time,hash,delay,interval,order,next,cmd", TICK, "1s", )}, - }, Commands: map[string]*ice.Command{ - TIMER: {Name: "timer hash id auto create action prunes", Help: "定时器", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + TIMER: {Name: "timer hash id auto create action prunes", Help: "定时器", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create delay=10ms interval=10s order=3 cmd=runtime", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INSERT, TIMER, "", mdb.HASH, DELAY, "10ms", INTERVAL, "10m", ORDER, 1, NEXT, m.Time(m.Option(DELAY)), arg) }}, diff --git a/base/lex/matrix.go b/base/lex/matrix.go index 233d633d..7a66c443 100644 --- a/base/lex/matrix.go +++ b/base/lex/matrix.go @@ -385,10 +385,10 @@ const ( const MATRIX = "matrix" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data()}, - }, Commands: map[string]*ice.Command{ - MATRIX: {Name: "matrix hash npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + MATRIX: {Name: "matrix hash npage text auto", Help: "魔方矩阵", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { // _lex_load(m.Load()) }}, diff --git a/base/lex/split.go b/base/lex/split.go index d08abfae..a4f64c46 100644 --- a/base/lex/split.go +++ b/base/lex/split.go @@ -101,9 +101,9 @@ const ( const SPLIT = "split" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SPLIT: {Name: "split", Help: "解析", Value: kit.Data()}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ SPLIT: {Name: "split path key auto", Help: "解析", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) { m.Cmdy(nfs.DIR, arg) diff --git a/base/log/log.go b/base/log/log.go index a7c4c98d..d2f9cc68 100644 --- a/base/log/log.go +++ b/base/log/log.go @@ -94,7 +94,7 @@ const ( SHOW = "show" ) -var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: map[string]*ice.Config{ +var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: ice.Configs{ FILE: {Name: FILE, Help: "日志文件", Value: kit.Dict( BENCH, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "bench.log"), mdb.LIST, []string{}), WATCH, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "watch.log"), mdb.LIST, []string{ @@ -122,7 +122,7 @@ var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: map[string] }), )}, SHOW: {Name: SHOW, Help: "日志分流", Value: kit.Dict()}, -}, Commands: map[string]*ice.Command{ +}, Commands: ice.Commands{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { if log.LogDisable { return // 禁用日志 diff --git a/base/mdb/engine.go b/base/mdb/engine.go index 3b9c02aa..722cf75c 100644 --- a/base/mdb/engine.go +++ b/base/mdb/engine.go @@ -8,10 +8,10 @@ import ( const ENGINE = "engine" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ENGINE: {Name: ENGINE, Help: "引擎", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")}, - }, Commands: map[string]*ice.Command{ - ENGINE: {Name: "engine type name text auto", Help: "引擎", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + ENGINE: {Name: "engine type name text auto", Help: "引擎", Actions: ice.MergeAction(ice.Actions{ CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME))) m.Option(TYPE, kit.Ext(m.Option(TYPE))) diff --git a/base/mdb/hash.go b/base/mdb/hash.go index bf78d2be..7ef294d4 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -138,7 +138,7 @@ func _hash_prunes(m *ice.Message, prefix, chain string, arg ...string) { } m.Push(key, val, fields) }) - m.Table(func(index int, value map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { _hash_delete(m, prefix, chain, HASH, value[HASH]) }) } @@ -151,22 +151,36 @@ func AutoConfig(args ...ice.Any) *ice.Action { cs[m.CommandKey()] = &ice.Config{Value: kit.Data(args...)} m.Load(m.CommandKey()) } - if cs := m.Target().Commands; cs[m.CommandKey()] == nil || cs[m.CommandKey()].Meta[CREATE] != nil { - return - } inputs := []ice.Any{} kit.Fetch(kit.Split(m.Config(FIELD)), func(i int, k string) { switch k { - case TIME, HASH: + case TIME, HASH, ID: return } inputs = append(inputs, k) }) - m.Design(CREATE, "创建", inputs...) + + cs := m.Target().Commands + if cs[m.CommandKey()] == nil { + return + } + + m.Debug("what %v %v", m.CommandKey(), cs[m.CommandKey()].Actions[INSERT]) + if cs[m.CommandKey()].Actions[INSERT] != nil { + if cs[m.CommandKey()].Meta[INSERT] == nil { + m.Design(INSERT, "添加", append([]ice.Any{ZONE}, inputs...)...) + } + m.Debug("what %v %v", m.CommandKey(), cs[m.CommandKey()].Actions[INSERT]) + } else if cs[m.CommandKey()].Actions[CREATE] != nil { + if cs[m.CommandKey()].Meta[CREATE] == nil { + m.Design(CREATE, "创建", inputs...) + } + m.Debug("what %v %v", m.CommandKey(), cs[m.CommandKey()].Actions[INSERT]) + } }} } -func HashAction(args ...ice.Any) map[string]*ice.Action { +func HashAction(args ...ice.Any) ice.Actions { _key := func(m *ice.Message) string { if m.Config(HASH) == UNIQ { return HASH @@ -176,7 +190,7 @@ func HashAction(args ...ice.Any) map[string]*ice.Action { } return kit.Select(HASH, m.Config(SHORT)) } - return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...), + 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) }}, @@ -206,7 +220,7 @@ func HashAction(args ...ice.Any) map[string]*ice.Action { }}, } } -func HashActionStatus(args ...ice.Any) map[string]*ice.Action { +func HashActionStatus(args ...ice.Any) ice.Actions { list := HashAction(args...) list[PRUNES] = &ice.Action{Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) { m.OptionFields(m.Config(FIELD)) @@ -228,7 +242,7 @@ func HashSelect(m *ice.Message, arg ...string) *ice.Message { m.StatusTimeCount() return m } -func HashPrunes(m *ice.Message, cb func(map[string]string) bool) *ice.Message { +func HashPrunes(m *ice.Message, cb func(ice.Maps) bool) *ice.Message { _key := func(m *ice.Message) string { if m.Config(HASH) == UNIQ { return HASH @@ -236,7 +250,7 @@ func HashPrunes(m *ice.Message, cb func(map[string]string) bool) *ice.Message { 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 map[string]string, head []string) { + m.Cmd(m.CommandKey()).Table(func(index int, value ice.Maps, head []string) { if kit.Time(value[TIME]) > expire { return } diff --git a/base/mdb/list.go b/base/mdb/list.go index 3ac291a8..98a30e92 100644 --- a/base/mdb/list.go +++ b/base/mdb/list.go @@ -133,8 +133,8 @@ func _list_prunes(m *ice.Message, prefix, chain string, arg ...string) { const LIST = "list" -func ListAction(args ...ice.Any) map[string]*ice.Action { - return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...), +func ListAction(args ...ice.Any) ice.Actions { + return ice.Actions{ice.CTX_INIT: AutoConfig(args...), INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INPUTS, m.PrefixKey(), "", LIST, arg) }}, diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index c5134c82..bb2c6212 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -145,7 +145,7 @@ func NextPageLimit(m *ice.Message, total string, arg ...string) { const MDB = "mdb" -var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*ice.Command{ +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) {}}, INSERT: {Name: "insert key sub type arg...", Help: "添加", Hand: func(m *ice.Message, arg ...string) { diff --git a/base/mdb/plugin.go b/base/mdb/plugin.go index 33a5f52b..4edfc307 100644 --- a/base/mdb/plugin.go +++ b/base/mdb/plugin.go @@ -8,10 +8,10 @@ import ( const PLUGIN = "plugin" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ PLUGIN: {Name: PLUGIN, Help: "插件", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")}, - }, Commands: map[string]*ice.Command{ - PLUGIN: {Name: "plugin type name text auto", Help: "插件", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + PLUGIN: {Name: "plugin type name text auto", Help: "插件", Actions: ice.Actions{ CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME))) m.Option(TYPE, kit.Ext(m.Option(TYPE))) diff --git a/base/mdb/render.go b/base/mdb/render.go index 429fa4b7..87a2425e 100644 --- a/base/mdb/render.go +++ b/base/mdb/render.go @@ -8,10 +8,10 @@ import ( const RENDER = "render" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ RENDER: {Name: RENDER, Help: "渲染", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")}, - }, Commands: map[string]*ice.Command{ - RENDER: {Name: "render type name text auto", Help: "渲染", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + RENDER: {Name: "render type name text auto", Help: "渲染", Actions: ice.Actions{ CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME))) m.Option(TYPE, kit.Ext(m.Option(TYPE))) diff --git a/base/mdb/search.go b/base/mdb/search.go index 615da125..aba1ef2c 100644 --- a/base/mdb/search.go +++ b/base/mdb/search.go @@ -8,10 +8,10 @@ import ( const SEARCH = "search" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SEARCH: {Name: SEARCH, Help: "搜索", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")}, - }, Commands: map[string]*ice.Command{ - SEARCH: {Name: "search type name text auto", Help: "搜索", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + SEARCH: {Name: "search type name text auto", Help: "搜索", Actions: ice.Actions{ CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME))) m.Option(TYPE, kit.Ext(m.Option(TYPE))) diff --git a/base/mdb/zone.go b/base/mdb/zone.go index 0acfcbb3..0c38ef0f 100644 --- a/base/mdb/zone.go +++ b/base/mdb/zone.go @@ -41,8 +41,8 @@ func _zone_select(m *ice.Message, prefix, chain, zone string, id string) { cb(key, value) case func(ice.Map): cb(value) - case func(map[string]string): - res := map[string]string{} + case func(ice.Maps): + res := ice.Maps{} for k, v := range value { res[k] = kit.Format(v) } @@ -108,7 +108,7 @@ func _zone_import(m *ice.Message, prefix, chain, file string) { head, _ := r.Read() count := 0 - list := map[string]string{} + list := ice.Maps{} zkey := kit.Select(head[0], m.OptionFields()) for { @@ -145,10 +145,10 @@ func _zone_import(m *ice.Message, prefix, chain, file string) { const ZONE = "zone" -func ZoneAction(args ...ice.Any) map[string]*ice.Action { +func ZoneAction(args ...ice.Any) ice.Actions { _zone := func(m *ice.Message) string { return kit.Select(ZONE, m.Config(SHORT)) } - return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...), + return ice.Actions{ice.CTX_INIT: AutoConfig(args...), INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { arg[0] = strings.TrimPrefix(arg[0], "extra.") arg[0] = kit.Select(arg[0], m.Config(kit.Keys(ALIAS, arg[0]))) @@ -177,7 +177,7 @@ func ZoneAction(args ...ice.Any) map[string]*ice.Action { REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(DELETE, m.PrefixKey(), "", HASH, m.OptionSimple(_zone(m)), arg) }}, - INSERT: {Name: "insert zone type=go name=hi text=hello", Help: "添加", Hand: func(m *ice.Message, arg ...string) { + INSERT: {Name: "insert", Help: "添加", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { arg = m.OptionSimple(_zone(m), m.Config(FIELD)) } diff --git a/base/nfs/cat.go b/base/nfs/cat.go index e2938afd..bf58c891 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -167,7 +167,7 @@ const ( const CAT = "cat" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ CAT: {Name: CAT, Help: "文件", Value: kit.Data( SOURCE, kit.Dict( HTML, ice.TRUE, CSS, ice.TRUE, JS, ice.TRUE, GO, ice.TRUE, SH, ice.TRUE, CSV, ice.TRUE, JSON, ice.TRUE, @@ -176,8 +176,8 @@ func init() { "py", ice.TRUE, ), )}, - }, Commands: map[string]*ice.Command{ - CAT: {Name: "cat path auto", Help: "文件", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + CAT: {Name: "cat path auto", Help: "文件", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.RENDER, mdb.CREATE, m.CommandKey(), m.PrefixKey()) }}, diff --git a/base/nfs/dir.go b/base/nfs/dir.go index f54eefde..1fe4eed5 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -86,7 +86,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d continue case nil: default: - m.Error(true, ice.ErrNotImplement) + m.Error(true, "what: %v: %v", ice.ErrNotImplement, cb) } for _, field := range fields { @@ -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 map[string]string, head []string) { + msg.Table(func(index int, value ice.Maps, head []string) { if !strings.Contains(value[mdb.NAME], name) { return } @@ -235,10 +235,10 @@ const ( const DIR = "dir" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ DIR: {Name: DIR, Help: "目录", Value: kit.Data()}, - }, Commands: map[string]*ice.Command{ - DIR: {Name: "dir path field... auto upload", Help: "目录", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + DIR: {Name: "dir path field... auto upload", Help: "目录", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.RENDER, mdb.CREATE, m.CommandKey(), m.PrefixKey()) }}, diff --git a/base/nfs/find.go b/base/nfs/find.go index 6f65e342..b3ce0bab 100644 --- a/base/nfs/find.go +++ b/base/nfs/find.go @@ -9,7 +9,7 @@ import ( const FIND = "find" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ FIND: {Name: "find path word auto", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { for _, file := range strings.Split(m.Cmdx("cli.system", FIND, PWD, "-name", arg[1]), ice.NL) { m.Push(FILE, strings.TrimPrefix(file, PWD)) diff --git a/base/nfs/grep.go b/base/nfs/grep.go index 1954c79a..9b5d647e 100644 --- a/base/nfs/grep.go +++ b/base/nfs/grep.go @@ -5,7 +5,7 @@ import ice "shylinux.com/x/icebergs" const GREP = "grep" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ GREP: {Name: "grep path word auto", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { m.Option("cmd_dir", arg[0]) m.Split(m.Cmdx("cli.system", GREP, "--exclude=.[a-z]*", "--exclude-dir=.[a-z]*", "-rni", arg[1]), "file:line:text", ":") diff --git a/base/nfs/save.go b/base/nfs/save.go index 793c3f50..c97a1a88 100644 --- a/base/nfs/save.go +++ b/base/nfs/save.go @@ -92,7 +92,7 @@ const COPY = "copy" const LINK = "link" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ DEFS: {Name: "defs file text...", Help: "默认", Hand: func(m *ice.Message, arg ...string) { _defs_file(m, arg[0], arg[1:]...) }}, diff --git a/base/nfs/tail.go b/base/nfs/tail.go index c1e17de5..53dd1b29 100644 --- a/base/nfs/tail.go +++ b/base/nfs/tail.go @@ -36,12 +36,12 @@ func _tail_count(m *ice.Message, name string) string { const TAIL = "tail" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TAIL: {Name: TAIL, Help: "日志流", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,id,file,text", )}, - }, Commands: map[string]*ice.Command{ - TAIL: {Name: "tail name id auto page filter:text create", Help: "日志流", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + TAIL: {Name: "tail name id auto page filter:text create", Help: "日志流", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Richs(TAIL, "", mdb.FOREACH, func(key string, value ice.Map) { value, _ = kit.GetMeta(value), m.Option(mdb.HASH, key) @@ -66,7 +66,7 @@ func init() { m.Fields(len(kit.Slice(arg, 0, 2)), "time,name,count,file", m.Config(mdb.FIELD)) m.OptionPage(kit.Slice(arg, 2)...) - mdb.ZoneSelect(m.Spawn(), arg...).Table(func(index int, value map[string]string, head []string) { + mdb.ZoneSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, head []string) { if strings.Contains(value[mdb.TEXT], m.Option(ice.CACHE_FILTER)) { m.Push("", value, head) } diff --git a/base/nfs/tar.go b/base/nfs/tar.go index c39f3a16..ffd7f164 100644 --- a/base/nfs/tar.go +++ b/base/nfs/tar.go @@ -15,8 +15,8 @@ import ( const TAR = "tar" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TAR: {Name: "tar file path auto", Help: "打包", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + TAR: {Name: "tar file path auto", Help: "打包", Actions: ice.Actions{ mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 1 { arg = append(arg, arg[0]) diff --git a/base/nfs/trash.go b/base/nfs/trash.go index c3e31142..6eb10f24 100644 --- a/base/nfs/trash.go +++ b/base/nfs/trash.go @@ -32,12 +32,12 @@ const ( const TRASH = "trash" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TRASH: {Name: TRASH, Help: "回收站", Value: kit.Data( mdb.SHORT, FROM, mdb.FIELD, "time,hash,file,from", PATH, ice.VAR_TRASH, )}, - }, Commands: map[string]*ice.Command{ - TRASH: {Name: "trash hash auto prunes", Help: "回收站", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + TRASH: {Name: "trash hash auto prunes", Help: "回收站", Actions: ice.MergeAction(ice.Actions{ mdb.REVERT: {Name: "revert", Help: "恢复", Hand: func(m *ice.Message, arg ...string) { os.Rename(m.Option(FILE), m.Option(FROM)) m.Cmd(mdb.DELETE, TRASH, "", mdb.HASH, m.OptionSimple(mdb.HASH)) @@ -54,7 +54,7 @@ func init() { m.Cmd(mdb.DELETE, TRASH, "", mdb.HASH, m.OptionSimple(mdb.HASH)) }}, mdb.PRUNES: {Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) { - mdb.HashPrunes(m, func(value map[string]string) bool { + mdb.HashPrunes(m, func(value ice.Maps) bool { os.Remove(value[FILE]) return false }) diff --git a/base/ssh/scripts.go b/base/ssh/scripts.go index d8b84cfe..26b1fed5 100644 --- a/base/ssh/scripts.go +++ b/base/ssh/scripts.go @@ -259,15 +259,15 @@ const ( ) func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SOURCE: {Name: SOURCE, Help: "加载脚本", Value: kit.Data()}, PROMPT: {Name: PROMPT, Help: "命令提示", Value: kit.Data( PS1, []ice.Any{"\033[33;44m", mdb.COUNT, "[", mdb.TIME, "]", "\033[5m", TARGET, "\033[0m", "\033[44m", ">", "\033[0m ", "\033[?25h", "\033[32m"}, PS2, []ice.Any{mdb.COUNT, " ", TARGET, "> "}, )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {}}, - SOURCE: {Name: "source file", Help: "脚本解析", Action: ice.MergeAction(map[string]*ice.Action{ + SOURCE: {Name: "source file", Help: "脚本解析", Actions: ice.MergeAction(ice.Actions{ "repeat": {Name: "repeat", Help: "执行", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SCREEN, m.Option(mdb.TEXT)) m.ProcessInner() diff --git a/base/tcp/client.go b/base/tcp/client.go index 5ac213b2..e286a168 100644 --- a/base/tcp/client.go +++ b/base/tcp/client.go @@ -77,12 +77,12 @@ const ( const CLIENT = "client" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ CLIENT: {Name: CLIENT, Help: "客户端", Value: kit.Data( mdb.FIELD, "time,hash,status,type,name,host,port,error,nread,nwrite", )}, - }, Commands: map[string]*ice.Command{ - CLIENT: {Name: "client hash auto prunes", Help: "客户端", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + CLIENT: {Name: "client hash auto prunes", Help: "客户端", Actions: ice.MergeAction(ice.Actions{ ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Richs(CLIENT, "", mdb.FOREACH, func(key string, value ice.Map) { kit.Value(value, kit.Keym(STATUS), CLOSE) @@ -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 map[string]string, head []string) { + mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) { m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == OPEN)) }) }}, diff --git a/base/tcp/host.go b/base/tcp/host.go index 5e861658..8f7e9ce1 100644 --- a/base/tcp/host.go +++ b/base/tcp/host.go @@ -73,14 +73,14 @@ const ( const HOST = "host" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ HOST: {Name: HOST, Help: "主机", Value: kit.Data( aaa.BLACK, kit.Data(mdb.SHORT, mdb.TEXT), aaa.WHITE, kit.Data(mdb.SHORT, mdb.TEXT), )}, - }, Commands: map[string]*ice.Command{ - HOST: {Name: "host name auto", Help: "主机", Action: map[string]*ice.Action{ + }, 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 map[string]string, head []string) { + m.Cmd(HOST).Table(func(index int, value ice.Maps, head []string) { m.Cmd(HOST, aaa.WHITE, value[aaa.IP]) }) }}, diff --git a/base/tcp/port.go b/base/tcp/port.go index 559a9ee1..314ee475 100644 --- a/base/tcp/port.go +++ b/base/tcp/port.go @@ -46,10 +46,10 @@ const ( const PORT = "port" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ PORT: {Name: PORT, Help: "端口", Value: kit.Data(BEGIN, 10000, CURRENT, 10000, END, 20000)}, - }, Commands: map[string]*ice.Command{ - PORT: {Name: "port port path auto", Help: "端口", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + PORT: {Name: "port port path auto", Help: "端口", Actions: ice.Actions{ aaa.RIGHT: {Name: "right", Help: "分配", Hand: func(m *ice.Message, arg ...string) { m.Echo(_port_right(m, arg...)) }}, @@ -62,7 +62,7 @@ func init() { if len(arg) == 0 { current := kit.Int(m.Config(BEGIN)) m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_DAEMON) - m.Cmd(nfs.DIR, nfs.PWD, nfs.DIR_CLI_FIELDS).Tables(func(value map[string]string) { + m.Cmd(nfs.DIR, nfs.PWD, nfs.DIR_CLI_FIELDS).Tables(func(value ice.Maps) { bin := m.Cmd(nfs.DIR, path.Join(value[nfs.PATH], ice.BIN), nfs.DIR_CLI_FIELDS).Append(nfs.PATH) if bin == "" { bin = m.Cmd(nfs.DIR, path.Join(value[nfs.PATH], "sbin"), nfs.DIR_CLI_FIELDS).Append(nfs.PATH) diff --git a/base/tcp/server.go b/base/tcp/server.go index 3f2ab3bd..0b12af27 100644 --- a/base/tcp/server.go +++ b/base/tcp/server.go @@ -85,12 +85,12 @@ const ( const SERVER = "server" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data( mdb.FIELD, "time,hash,status,type,name,host,port,error,nconn", )}, - }, Commands: map[string]*ice.Command{ - SERVER: {Name: "server hash auto prunes", Help: "服务器", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SERVER: {Name: "server hash auto prunes", Help: "服务器", Actions: ice.MergeAction(ice.Actions{ ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Richs(SERVER, "", mdb.FOREACH, func(key string, value ice.Map) { kit.Value(value, kit.Keym(STATUS), CLOSE) @@ -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 map[string]string, head []string) { + mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) { m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == CLOSE)) }) }}, diff --git a/base/web/broad.go b/base/web/broad.go index e4c2d7be..4c3a36ee 100644 --- a/base/web/broad.go +++ b/base/web/broad.go @@ -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 map[string]string, head []string) { + m.Cmd(BROAD).Table(func(index int, value ice.Maps, head []string) { m.Debug("broad %v to %v", kit.Format(value), kit.Format(remote)) s.WriteToUDP([]byte(m.Spawn(value).FormatMeta()), remote) }) @@ -69,8 +69,8 @@ func _broad_search(m *ice.Message, kind, name, text string, arg ...string) { const BROAD = "broad" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - BROAD: {Name: "broad hash auto", Help: "广播", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + BROAD: {Name: "broad hash auto", Help: "广播", Actions: ice.MergeAction(ice.Actions{ SERVE: {Name: "broad port=9020", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { _serve_udp(m, m.Cmd(tcp.HOST).Append("ip"), m.Option(tcp.PORT)) }}, diff --git a/base/web/cache.go b/base/web/cache.go index e2ea6b44..2207ca0d 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -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 map[string]string, head []string) { + mdb.HashSelect(m.Spawn(), key).Table(func(index int, value ice.Maps, head []string) { if value[nfs.FILE] == "" { m.Cmdy(nfs.SAVE, file, value[mdb.TEXT]) } else { @@ -135,13 +135,13 @@ const ( const CACHE = "cache" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ CACHE: {Name: CACHE, Help: "缓存池", Value: kit.Data( mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,size,type,name,text", mdb.STORE, ice.VAR_DATA, nfs.PATH, ice.VAR_FILE, mdb.FSIZE, "200000", mdb.LIMIT, "50", mdb.LEAST, "30", )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ "/cache/": {Name: "/cache/", Help: "缓存池", Hand: func(m *ice.Message, arg ...string) { m.Richs(CACHE, nil, arg[0], func(key string, value ice.Map) { if kit.Format(value[nfs.FILE]) == "" { @@ -151,7 +151,7 @@ func init() { } }) }}, - CACHE: {Name: "cache hash auto", Help: "缓存池", Action: ice.MergeAction(map[string]*ice.Action{ + CACHE: {Name: "cache hash auto", Help: "缓存池", Actions: ice.MergeAction(ice.Actions{ WATCH: {Name: "watch key file", Help: "释放", Hand: func(m *ice.Message, arg ...string) { _cache_watch(m, arg[0], arg[1]) }}, diff --git a/base/web/dream.go b/base/web/dream.go index 2adbb8b4..bdaf1dbb 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -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 map[string]string, head []string) { + return m.Cmdy(nfs.DIR, m.Config(nfs.PATH), "time,size,name").Table(func(index int, value ice.Maps, head []string) { 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) @@ -102,8 +102,8 @@ const ( const DREAM = "dream" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - DREAM: {Name: "dream name path auto start", Help: "梦想家", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + DREAM: {Name: "dream name path auto start", Help: "梦想家", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config("miss", _dream_miss) }}, @@ -143,7 +143,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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { if value[cli.STATUS] != cli.START { m.Push(mdb.TEXT, "") return @@ -170,7 +170,7 @@ func init() { m.Option(nfs.DIR_ROOT, path.Join(m.Config(nfs.PATH), arg[0])) m.Cmdy(nfs.CAT, arg[1:]) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ DREAM: {Name: DREAM, Help: "梦想家", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_WORK, "miss", _dream_miss)}, }}) } diff --git a/base/web/route.go b/base/web/route.go index edb7897d..3f954c53 100644 --- a/base/web/route.go +++ b/base/web/route.go @@ -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 map[string]string, head []string) { + m.Cmd(SPACE, val[mdb.NAME], ROUTE).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, field []string) { + m.Table(func(index int, value ice.Maps, field []string) { 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 map[string]string, head []string) { + m.Cmd(tcp.HOST).Table(func(index int, value ice.Maps, head []string) { 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())) @@ -64,10 +64,10 @@ func _route_list(m *ice.Message) { const ROUTE = "route" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ROUTE: {Name: ROUTE, Help: "路由器", Value: kit.Data(mdb.SHORT, ROUTE)}, - }, Commands: map[string]*ice.Command{ - ROUTE: {Name: "route route ctx cmd auto invite spide", Help: "路由器", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + ROUTE: {Name: "route route ctx cmd auto invite spide", Help: "路由器", Actions: ice.Actions{ aaa.INVITE: {Name: "invite", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, m.Option(ROUTE), SPACE, aaa.INVITE, arg) m.ProcessInner() @@ -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 map[string]string, head []string) { + m.Cmd(SPACE, arg[0], ctx.CONTEXT, ice.ICE).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + m.Cmd(SPACE, arg[0], ctx.CONTEXT, arg[1], ctx.COMMAND).Table(func(index int, value ice.Maps, head []string) { m.Push(ice.CMD, value[mdb.KEY]) m.Push("", value, kit.List(mdb.NAME, mdb.HELP)) }) diff --git a/base/web/serve.go b/base/web/serve.go index bf08dcbb..c3a345f0 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -275,7 +275,7 @@ const ( const SERVE = "serve" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SERVE: {Name: SERVE, Help: "服务器", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,status,name,port,dev", tcp.LOCALHOST, ice.TRUE, aaa.BLACK, kit.Dict(), aaa.WHITE, kit.Dict( @@ -294,8 +294,8 @@ func init() { nfs.REPOS, "https://shylinux.com/x/intshell", nfs.BRANCH, nfs.MASTER, ), ice.REQUIRE, ".ish/pluged", )}, - }, Commands: map[string]*ice.Command{ - SERVE: {Name: "serve name auto start spide", Help: "服务器", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SERVE: {Name: "serve name auto start spide", Help: "服务器", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.NodeInfo(m, WORKER, ice.Info.PathName) AddRewrite(func(w http.ResponseWriter, r *http.Request) bool { @@ -321,7 +321,7 @@ func init() { }) }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { - m.Cmd(SERVE).Table(func(index int, value map[string]string, head []string) { + m.Cmd(SERVE).Table(func(index int, value ice.Maps, head []string) { m.Done(value[cli.STATUS] == tcp.START) }) }}, diff --git a/base/web/share.go b/base/web/share.go index 274dafd4..40493464 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -122,12 +122,12 @@ const ( const SHARE = "share" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SHARE: {Name: SHARE, Help: "共享链", Value: kit.Data( mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,userrole,username,river,storm,type,name,text", )}, - }, Commands: map[string]*ice.Command{ - SHARE: {Name: "share hash auto prunes", Help: "共享链", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SHARE: {Name: "share hash auto prunes", Help: "共享链", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.AddRender(ice.RENDER_DOWNLOAD, func(msg *ice.Message, cmd string, args ...ice.Any) string { list := []string{} diff --git a/base/web/space.go b/base/web/space.go index f11c5607..cb1d17e8 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -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 map[string]string, head []string) { - m.Cmd(tcp.HOST, ice.OptionFields("")).Table(func(index int, value map[string]string, head []string) { + 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.PushSearch(kit.SimpleKV("", MYSELF, value[mdb.NAME], kit.Format("http://%s:%s", value[aaa.IP], val[tcp.PORT]))) }) }) @@ -289,14 +289,14 @@ const ( const SPACE = "space" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SPACE: {Name: SPACE, Help: "空间站", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text", BUFFER, kit.Dict("r", ice.MOD_BUFS, "w", ice.MOD_BUFS), REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000), TIMEOUT, kit.Dict("c", "180s"), )}, - }, Commands: map[string]*ice.Command{ - SPACE: {Name: "space name cmd auto invite", Help: "空间站", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SPACE: {Name: "space name cmd auto invite", Help: "空间站", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf(SPACE, mdb.HASH, "") }}, @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { switch value[mdb.TYPE] { case MASTER: m.PushAnchor(value[mdb.NAME], m.Cmd(SPIDE, value[mdb.NAME], ice.OptionFields("")).Append("client.url")) diff --git a/base/web/spide.go b/base/web/spide.go index 59a23f0f..25b369de 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -127,8 +127,8 @@ func _spide_list(m *ice.Message, arg ...string) { _spide_save(m, cache, save, uri, res) }) } -func _spide_body(m *ice.Message, method string, arg ...string) (io.Reader, map[string]string, []string) { - head := map[string]string{} +func _spide_body(m *ice.Message, method string, arg ...string) (io.Reader, ice.Maps, []string) { + head := ice.Maps{} body, ok := m.Optionv(SPIDE_BODY).(io.Reader) if !ok && len(arg) > 0 && method != SPIDE_GET { if len(arg) == 1 { @@ -216,7 +216,7 @@ func _spide_part(m *ice.Message, arg ...string) (io.Reader, string) { } return buf, mp.FormDataContentType() } -func _spide_head(m *ice.Message, req *http.Request, head map[string]string, value ice.Map) { +func _spide_head(m *ice.Message, req *http.Request, head ice.Maps, value ice.Map) { m.Info("%s %s", req.Method, req.URL) kit.Fetch(value[SPIDE_HEADER], func(key string, value string) { req.Header.Set(key, value) @@ -331,6 +331,7 @@ const ( ContentFORM = "application/x-www-form-urlencoded" ContentJSON = "application/json" ContentHTML = "text/html" + ContentCSS = "text/css" ContentPNG = "image/png" ) const ( @@ -353,10 +354,10 @@ const ( const SPIDE = "spide" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SPIDE: {Name: SPIDE, Help: "蜘蛛侠", Value: kit.Data(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,client.name,client.url", LOGHEADERS, ice.FALSE)}, - }, Commands: map[string]*ice.Command{ - SPIDE: {Name: "spide client.name action=raw,msg,save,cache method=GET,PUT,POST,DELETE url format=form,part,json,data,file arg run create", Help: "蜘蛛侠", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SPIDE: {Name: "spide client.name action=raw,msg,save,cache method=GET,PUT,POST,DELETE url format=form,part,json,data,file arg run create", Help: "蜘蛛侠", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { conf := m.Confm(cli.RUNTIME, "conf") m.Cmd(SPIDE, mdb.CREATE, ice.OPS, kit.Select("http://127.0.0.1:9020", conf["ctx_ops"])) @@ -382,21 +383,21 @@ func init() { _spide_list(m, arg...) }}, - SPIDE_GET: {Name: "GET url key value run", Help: "蜘蛛侠", Action: map[string]*ice.Action{ + SPIDE_GET: {Name: "GET url key value run", Help: "蜘蛛侠", Actions: ice.Actions{ mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, m.OptionSimple(CLIENT_NAME)) }}, }, Hand: func(m *ice.Message, arg ...string) { m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(SPIDE, ice.DEV, SPIDE_RAW, SPIDE_GET, arg[0], arg[1:])))) }}, - SPIDE_POST: {Name: "POST url key value run", Help: "蜘蛛侠", Action: map[string]*ice.Action{ + SPIDE_POST: {Name: "POST url key value run", Help: "蜘蛛侠", Actions: ice.Actions{ mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, m.OptionSimple(CLIENT_NAME)) }}, }, Hand: func(m *ice.Message, arg ...string) { m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(SPIDE, ice.DEV, SPIDE_RAW, SPIDE_POST, arg[0], arg[1:])))) }}, - SPIDE_DELETE: {Name: "DELETE url key value run", Help: "蜘蛛侠", Action: map[string]*ice.Action{ + SPIDE_DELETE: {Name: "DELETE url key value run", Help: "蜘蛛侠", Actions: ice.Actions{ mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, m.OptionSimple(CLIENT_NAME)) }}, diff --git a/base/web/story.go b/base/web/story.go index 904f78e6..98c76ba7 100644 --- a/base/web/story.go +++ b/base/web/story.go @@ -162,13 +162,13 @@ const ( const STORY = "story" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ STORY: {Name: "story", Help: "故事会", Value: kit.Dict( mdb.META, kit.Dict(mdb.SHORT, DATA), HEAD, kit.Data(mdb.SHORT, STORY), )}, - }, Commands: map[string]*ice.Command{ - STORY: {Name: "story story auto", Help: "故事会", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + STORY: {Name: "story story auto", Help: "故事会", Actions: ice.Actions{ WRITE: {Name: "write type name text arg...", Help: "添加", Hand: func(m *ice.Message, arg ...string) { _story_write(m, arg[0], arg[1], arg[2], arg[3:]...) }}, @@ -260,7 +260,7 @@ func _story_pull(m *ice.Message, arg ...string) { pull := end var first ice.Map for begin != "" && begin != end { - if m.Cmd(SPIDE, arg[2], "msg", "/story/pull", "begin", begin, "end", end).Table(func(index int, value map[string]string, head []string) { + if m.Cmd(SPIDE, arg[2], "msg", "/story/pull", "begin", begin, "end", end).Table(func(index int, value ice.Maps, head []string) { if m.Richs(CACHE, nil, value["data"], nil) == nil { m.Log(ice.LOG_IMPORT, "%v: %v", value["data"], value["save"]) if node := kit.UnMarshal(value["save"]); kit.Format(kit.Value(node, "file")) != "" { @@ -404,7 +404,7 @@ func _story_commit(m *ice.Message, arg ...string) { arg[2] = m.Cmdx(STORY, "add", "submit", arg[2], "hostname,username") // 节点信息 - menu := map[string]string{} + menu := ice.Maps{} for i := 3; i < len(arg); i++ { menu[arg[i]] = m.Cmdx(STORY, INDEX, arg[i]) } diff --git a/base/yac/matrix.go b/base/yac/matrix.go index c2ad05cf..982dd9f3 100644 --- a/base/yac/matrix.go +++ b/base/yac/matrix.go @@ -344,10 +344,10 @@ const ( const MATRIX = "matrix" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data(mdb.SHORT, mdb.NAME)}, - }, Commands: map[string]*ice.Command{ - MATRIX: {Name: "matrix name npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + MATRIX: {Name: "matrix name npage text auto", Help: "魔方矩阵", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _yac_load(m) }}, mdb.CREATE: {Name: "create name=shy nlang=32 ncell=32", Help: "创建", Hand: func(m *ice.Message, arg ...string) { mat := NewMatrix(m, kit.Int(kit.Select("32", m.Option(NLANG))), kit.Int(kit.Select("32", m.Option(NCELL)))) diff --git a/base/yac/script.go b/base/yac/script.go index 8261b408..826018dd 100644 --- a/base/yac/script.go +++ b/base/yac/script.go @@ -16,7 +16,7 @@ type frame struct { pos int key string skip bool - data map[string]string + data ice.Maps } type stack struct { fs []*frame @@ -24,7 +24,7 @@ type stack struct { } func (s *stack) push(f *frame) *stack { - f.data = map[string]string{} + f.data = ice.Maps{} s.fs = append(s.fs, f) return s } @@ -95,8 +95,8 @@ func _exp_true(m *ice.Message, arg string) bool { const SCRIPT = "script" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - SCRIPT: {Name: "script name npage text auto create", Help: "脚本解析", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + SCRIPT: {Name: "script name npage text auto create", Help: "脚本解析", Actions: ice.Actions{ mdb.CREATE: {Name: "create name=shy text=etc/yac.txt", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Cmd(MATRIX, mdb.CREATE, m.Option(mdb.NAME)) if buf, err := ioutil.ReadFile(m.Option(mdb.TEXT)); err == nil { @@ -206,7 +206,7 @@ func init() { m.Option("stack", stack) m.Cmdy(MATRIX, PARSE, arg[0], arg[1], arg[2], func(nhash string, hash int, word []string, begin int, stream *lex.Stream) (int, []string) { m.Option("stream", stream) - if _, ok := m.Target().Commands[SCRIPT].Action[nhash]; ok && stack.can_run(nhash) { + if _, ok := m.Target().Commands[SCRIPT].Actions[nhash]; ok && stack.can_run(nhash) { msg := m.Cmd(SCRIPT, nhash, word, ice.Option{"begin", begin}) return hash, msg.Resultv() } diff --git a/core/chat/action.go b/core/chat/action.go index 20e3e433..ecf43ebf 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -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 map[string]string, head []string) { + m.Cmdy(STORM, storm, ice.Option{ice.MSG_RIVER, river}).Table(func(index int, value ice.Maps, head []string) { m.Cmdy(m.Space(kit.Select(m.Option(ice.POD), value[ice.POD])), ctx.COMMAND, kit.Keys(value[ice.CTX], value[ice.CMD])) }) } @@ -146,8 +146,8 @@ const ( const ACTION = "action" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for _, cmd := range []string{ "web.chat.meet.miss", diff --git a/core/chat/cmd.go b/core/chat/cmd.go index c9954629..d749dd80 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -51,10 +51,10 @@ func _cmd_file(m *ice.Message, arg ...string) bool { const CMD = "cmd" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ CMD: {Name: CMD, Help: "命令", Value: kit.Data(mdb.SHORT, "type", nfs.PATH, nfs.PWD)}, - }, Commands: map[string]*ice.Command{ - "/cmd/": {Name: "/cmd/", Help: "命令", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + "/cmd/": {Name: "/cmd/", Help: "命令", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, "shy", mdb.NAME, "web.wiki.word") m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, "svg", mdb.NAME, "web.wiki.draw") @@ -84,7 +84,7 @@ func init() { m.RenderDownload(path.Join(m.Config(nfs.PATH), path.Join(arg...))) // 文件 } }}, - CMD: {Name: "cmd path auto upload up home", Help: "命令", Action: ice.MergeAction(map[string]*ice.Action{ + CMD: {Name: "cmd path auto upload up home", Help: "命令", Actions: ice.MergeAction(ice.Actions{ web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { m.Upload(path.Join(m.Config(nfs.PATH), strings.TrimPrefix(path.Dir(m.R.URL.Path), "/cmd"))) }}, diff --git a/core/chat/div.go b/core/chat/div.go index b02f17f6..75c50398 100644 --- a/core/chat/div.go +++ b/core/chat/div.go @@ -25,13 +25,13 @@ func _div_parse(m *ice.Message, text string) string { const DIV = "div" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ DIV: {Name: "div", Help: "定制", Value: kit.Data( mdb.FIELD, "time,hash,type,name,text", nfs.PATH, ice.USR_PUBLISH, nfs.TEMPLATE, _div_template, )}, - }, Commands: map[string]*ice.Command{ - "/div/": {Name: "/div/", Help: "定制", Action: ice.MergeAction(ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, Commands: ice.Commands{ + "/div/": {Name: "/div/", Help: "定制", Actions: ice.MergeAction(ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { switch p := path.Join(arg...); kit.Ext(kit.Select("", p)) { case nfs.HTML: m.RenderDownload(p) @@ -45,7 +45,7 @@ func init() { m.RenderCmd(m.PrefixKey(), p) } }}, - DIV: {Name: "div hash auto import", Help: "定制", Action: ice.MergeAction(map[string]*ice.Action{ + DIV: {Name: "div hash auto import", Help: "定制", Actions: ice.MergeAction(ice.Actions{ lex.SPLIT: {Name: "split name=hi text", Help: "生成", Hand: func(m *ice.Message, arg ...string) { h := m.Cmdx(DIV, mdb.CREATE, m.OptionSimple(mdb.NAME), mdb.TEXT, _div_parse(m, m.Option(mdb.TEXT))) m.ProcessRewrite(mdb.HASH, h) diff --git a/core/chat/files.go b/core/chat/files.go index 3207dd08..6835da3f 100644 --- a/core/chat/files.go +++ b/core/chat/files.go @@ -11,12 +11,12 @@ import ( const FILES = "files" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ FILES: {Name: FILES, Help: "文件夹", Value: kit.Data( mdb.SHORT, mdb.DATA, mdb.FIELD, "time,hash,type,name,size,data", )}, - }, Commands: map[string]*ice.Command{ - FILES: {Name: "files hash auto upload", Help: "文件夹", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + FILES: {Name: "files hash auto upload", Help: "文件夹", Actions: ice.MergeAction(ice.Actions{ web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)) if len(up) < 2 { @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { 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) diff --git a/core/chat/footer.go b/core/chat/footer.go index e23f7916..3b049314 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -14,10 +14,10 @@ const ( const FOOTER = "footer" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ FOOTER: {Name: FOOTER, Help: "状态栏", Value: kit.Dict(LEGAL, kit.List(`shylinuxc@gmail.com`))}, - }, Commands: map[string]*ice.Command{ - web.P(FOOTER): {Name: "/footer", Help: "状态栏", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + web.P(FOOTER): {Name: "/footer", Help: "状态栏", Actions: ice.MergeAction(ice.Actions{ ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(arg); m.Result(1) == ice.ErrNotFound { m.Set(ice.MSG_RESULT).Cmdy(cli.SYSTEM, arg) diff --git a/core/chat/grant.go b/core/chat/grant.go index 5e741d7f..ba390a6d 100644 --- a/core/chat/grant.go +++ b/core/chat/grant.go @@ -10,8 +10,8 @@ import ( const GRANT = "grant" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - GRANT: {Name: "grant space id auto insert", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + GRANT: {Name: "grant space id auto insert", Help: "授权", Actions: ice.MergeAction(ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case web.SPACE: diff --git a/core/chat/header.go b/core/chat/header.go index d9891ed2..58c71ff1 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -20,6 +20,12 @@ func _header_agent(m *ice.Message, arg ...string) { } } func _header_check(m *ice.Message, arg ...string) bool { + if m.Option(web.SHARE) != "" { + m.Cmd(web.SHARE, m.Option(web.SHARE), ice.OptionFields("")).Tables(func(value ice.Maps) { + m.Option(ice.MSG_USERNAME, value["username"]) + m.Option(ice.MSG_USERROLE, value["userrole"]) + }) + } if m.Option(ice.MSG_USERNAME) != "" { return true } @@ -49,7 +55,6 @@ func _header_users(m *ice.Message, key string, arg ...string) { const ( TITLE = "title" - TOPIC = "topic" MENUS = "menus" TRANS = "trans" AGENT = "agent" @@ -59,9 +64,9 @@ const ( const HEADER = "header" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(aaa.LOGIN, kit.List("登录", "扫码"))}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case "/header": @@ -75,7 +80,7 @@ func init() { } m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) }}, - web.P(HEADER): {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{ + web.P(HEADER): {Name: "/header", Help: "标题栏", Actions: ice.Actions{ AGENT: {Name: "agent", Help: "宿主应用", Hand: func(m *ice.Message, arg ...string) { _header_agent(m, arg...) }}, diff --git a/core/chat/info.go b/core/chat/info.go index f5611c60..7dfc1675 100644 --- a/core/chat/info.go +++ b/core/chat/info.go @@ -8,8 +8,8 @@ import ( const INFO = "info" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - INFO: {Name: "info auto", Help: "信息", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + INFO: {Name: "info auto", Help: "信息", Actions: ice.Actions{ mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.MODIFY, RIVER, "", mdb.HASH, mdb.HASH, m.Option(ice.MSG_RIVER), arg) }}, diff --git a/core/chat/location.go b/core/chat/location.go index 463a987f..49db5ef4 100644 --- a/core/chat/location.go +++ b/core/chat/location.go @@ -15,7 +15,7 @@ func distance(lat1, long1, lat2, long2 float64) float64 { long2 = long2 * math.Pi / 180 return 2 * 6371 * math.Asin(math.Sqrt(math.Pow(math.Sin(math.Abs(lat1-lat2)/2), 2)+math.Cos(lat1)*math.Cos(lat2)*math.Pow(math.Sin(math.Abs(long1-long2)/2), 2))) } -func _trans(arg []string, tr map[string]string) { +func _trans(arg []string, tr ice.Maps) { for i := 0; i < len(arg)-1; i += 2 { arg[i] = kit.Select(arg[i], tr[arg[i]]) } @@ -32,12 +32,12 @@ const ( const LOCATION = "location" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ LOCATION: {Name: LOCATION, Help: "地理位置", Value: kit.Data( mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,type,name,text,longitude,latitude", )}, - }, Commands: map[string]*ice.Command{ - LOCATION: {Name: "location hash auto getLocation", Help: "地理位置", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + LOCATION: {Name: "location hash auto getLocation", Help: "地理位置", Actions: ice.MergeAction(ice.Actions{ OPENLOCATION: {Name: "location", Help: "地图"}, GETLOCATION: {Name: "location create", Help: "打卡"}, mdb.CREATE: {Name: "create type=text name text latitude longitude", Help: "添加"}, diff --git a/core/chat/meet.go b/core/chat/meet.go index f52133df..c3a96957 100644 --- a/core/chat/meet.go +++ b/core/chat/meet.go @@ -12,12 +12,12 @@ const ( const MISS = "miss" func init() { - Index.Register(&ice.Context{Name: MEET, Help: "遇见", Configs: map[string]*ice.Config{ + Index.Register(&ice.Context{Name: MEET, Help: "遇见", Configs: ice.Configs{ MISS: {Name: MISS, Help: "miss", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,照片,性别,年龄,身高,体重,籍贯,户口,学历,学校,职业,公司,年薪,资产,家境", )}, - }, Commands: map[string]*ice.Command{ - "monkey": {Name: "monkey total=888 count=9 run", Help: "猴子开箱子", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + "monkey": {Name: "monkey total=888 count=9 run", Help: "猴子开箱子", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create name 照片 性别 年龄 身高 体重 籍贯 户口 学历 学校 职业 公司 年薪 资产 家境", Help: "添加"}, }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { total := kit.Int(arg[0]) @@ -38,11 +38,11 @@ func init() { } m.StatusTimeCount() }}, - MISS: {Name: "miss name auto create", Help: "资料", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Action: ice.MergeAction(map[string]*ice.Action{ + MISS: {Name: "miss name auto create", Help: "资料", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Actions: ice.MergeAction(ice.Actions{ 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 map[string]string, head []string) { + mdb.HashSelect(msg, arg...).Table(func(index int, value ice.Maps, head []string) { value["照片"] = ice.Render(m, ice.RENDER_IMAGES, value["照片"], kit.Select("100", "400", msg.FieldsIsDetail())) m.Push(m.OptionFields(), value, kit.Split(msg.OptionFields())) }) diff --git a/core/chat/node.go b/core/chat/node.go index 676e0bd1..63623707 100644 --- a/core/chat/node.go +++ b/core/chat/node.go @@ -12,8 +12,8 @@ import ( const NODE = "node" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - NODE: {Name: "node pod ctx cmd auto insert invite", Help: "设备", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + NODE: {Name: "node pod ctx cmd auto insert invite", Help: "设备", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Watch(web.DREAM_START, m.PrefixKey()) m.Watch(web.SPACE_START, m.PrefixKey()) @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { m.PushAnchor(value[mdb.NAME], m.MergeURL2("/chat/pod/"+kit.Keys(m.Option(ice.POD), value[mdb.NAME]))) }) m.RenameAppend("name", "pod") diff --git a/core/chat/oauth/oauth.go b/core/chat/oauth/oauth.go index bf72fe01..a13dafe3 100644 --- a/core/chat/oauth/oauth.go +++ b/core/chat/oauth/oauth.go @@ -55,8 +55,8 @@ const ( ) const OAUTH = "oauth" -var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string]*ice.Command{ - OAUTH: {Name: "oauth hash auto prunes", Help: "权限", Action: ice.MergeAction(map[string]*ice.Action{ +var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: ice.Commands{ + OAUTH: {Name: "oauth hash auto prunes", Help: "权限", Actions: ice.MergeAction(ice.Actions{ CHECK: {Name: "check scope domain", Help: "检查", Hand: func(m *ice.Message, arg ...string) { m.Echo(_merge_url(m, kit.Select(ice.Info.Make.Domain, m.Option(web.DOMAIN)), APPLY, m.OptionSimple(SCOPE), REDIRECT_URI, _merge_url(m, "", REPLY))) }}, @@ -77,11 +77,11 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string }}, })}, - APPLY: {Name: "apply hash auto create prunes", Help: "申请", Action: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,username,scope,redirect_uri")}, - REPLY: {Name: "reply hash auto create prunes", Help: "授权", Action: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,offer")}, - OFFER: {Name: "offer hash auto create prunes", Help: "访问", Action: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")}, + APPLY: {Name: "apply hash auto create prunes", Help: "申请", Actions: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,username,scope,redirect_uri")}, + REPLY: {Name: "reply hash auto create prunes", Help: "授权", Actions: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,offer")}, + OFFER: {Name: "offer hash auto create prunes", Help: "访问", Actions: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")}, - web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Action: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { + web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { if m.Option(REDIRECT_URI) == "" { m.RenderStatusBadRequest() // 参数错误 @@ -89,7 +89,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string m.RenderCmd(m.Prefix(OAUTH), APPLY) } }}, - web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Action: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { + web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { if m.Option(OFFER) == "" { m.RenderStatusBadRequest() // 参数错误 @@ -109,9 +109,9 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string } }}, - AUTHORIZE: {Name: "authorize hash auto create prunes", Help: "认证", Action: mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,redirect_uri")}, - TOKEN: {Name: "token hash auto create prunes", Help: "授权", Action: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,used,state,scope,redirect_uri")}, - ACCESS: {Name: "access hash auto create prunes", Help: "访问", Action: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")}, + AUTHORIZE: {Name: "authorize hash auto create prunes", Help: "认证", Actions: mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,redirect_uri")}, + TOKEN: {Name: "token hash auto create prunes", Help: "授权", Actions: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,used,state,scope,redirect_uri")}, + ACCESS: {Name: "access hash auto create prunes", Help: "访问", Actions: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")}, web.P(AUTHORIZE): {Name: "/authorize state scope client_id redirect_uri", Help: "认证", Hand: func(m *ice.Message, arg ...string) { if m.Option(CLIENT_ID) == "" || m.Option(REDIRECT_URI) == "" { diff --git a/core/chat/ocean.go b/core/chat/ocean.go index 85b12413..66b7c42c 100644 --- a/core/chat/ocean.go +++ b/core/chat/ocean.go @@ -10,8 +10,8 @@ import ( const OCEAN = "ocean" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - OCEAN: {Name: "ocean username auto insert invite", Help: "用户", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + OCEAN: {Name: "ocean username auto insert invite", Help: "用户", Actions: ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(aaa.USER, ice.OptionFields(aaa.USERNAME, aaa.USERNICK, aaa.USERZONE)) }}, @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { 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())) diff --git a/core/chat/paste.go b/core/chat/paste.go index 91ddeed7..adaec60f 100644 --- a/core/chat/paste.go +++ b/core/chat/paste.go @@ -11,12 +11,12 @@ import ( const PASTE = "paste" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ PASTE: {Name: PASTE, Help: "粘贴", Value: kit.Data( mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,type,name,text", )}, - }, Commands: map[string]*ice.Command{ - PASTE: {Name: "paste hash auto getClipboardData", Help: "粘贴", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + PASTE: {Name: "paste hash auto getClipboardData", Help: "粘贴", Actions: ice.MergeAction(ice.Actions{ "getClipboardData": {Name: "getClipboardData", Help: "粘贴", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(PASTE, mdb.CREATE, arg) }}, diff --git a/core/chat/pod.go b/core/chat/pod.go index 36fb5b87..4e87d736 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -16,10 +16,10 @@ import ( const POD = "pod" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ POD: {Name: POD, Help: "节点", Value: kit.Data()}, - }, Commands: map[string]*ice.Command{ - "/pod/": {Name: "/pod/", Help: "节点", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + "/pod/": {Name: "/pod/", Help: "节点", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) { }}, }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { diff --git a/core/chat/river.go b/core/chat/river.go index 7412a185..ece8c46d 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -53,8 +53,8 @@ func _river_list(m *ice.Message) { const RIVER = "river" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - RIVER: {Name: "river hash auto create", Help: "群组", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + RIVER: {Name: "river hash auto create", Help: "群组", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(nfs.TEMPLATE, _river_template) }}, mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { switch m.Option(ctx.ACTION) { diff --git a/core/chat/room.go b/core/chat/room.go index 7148ee52..8456dc95 100644 --- a/core/chat/room.go +++ b/core/chat/room.go @@ -15,21 +15,21 @@ func init() { JOIN = "join" QUIT = "quit" ) - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ROOM: {Name: "room", Help: "room", Value: kit.Data( mdb.SHORT, "zone", mdb.FIELD, "time,id,type,name,text", )}, JOIN: {Name: "join", Help: "join", Value: kit.Data( mdb.SHORT, "space", mdb.FIELD, "time,hash,username,socket", )}, - }, Commands: map[string]*ice.Command{ - ROOM: {Name: "room zone id auto", Help: "room", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + ROOM: {Name: "room zone id auto", Help: "room", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create zone", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(mdb.ZONE)) }}, 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 map[string]string, head []string) { + 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(web.SPACE, value[web.SPACE], "toast", m.Option("text"), m.Option("name")) }) }}, @@ -51,7 +51,7 @@ func init() { m.Action(mdb.INSERT, JOIN) } }}, - JOIN: {Name: "join space zone auto", Help: "join", Action: ice.MergeAction(map[string]*ice.Action{ + JOIN: {Name: "join space zone auto", Help: "join", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { // m.Watch(web.SPACE_START, m.PrefixKey()) }}, diff --git a/core/chat/scan.go b/core/chat/scan.go index 1b4cd992..f67e1971 100644 --- a/core/chat/scan.go +++ b/core/chat/scan.go @@ -11,14 +11,14 @@ import ( const SCAN = "scan" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SCAN: {Name: SCAN, Help: "扫码", Value: kit.Data( mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,type,name,text", )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ SCAN: {Name: "scan hash auto scanQRCode scanQRCode0", Help: "扫码", Meta: kit.Dict( ice.Display("scan.js"), - ), Action: ice.MergeAction(map[string]*ice.Action{ + ), Actions: ice.MergeAction(ice.Actions{ "scanQRCode0": {Name: "scan create", Help: "本机扫码"}, "scanQRCode": {Name: "scan create", Help: "扫码"}, mdb.CREATE: {Name: "create type=text name=hi text:textarea=hi", Help: "添加"}, diff --git a/core/chat/search.go b/core/chat/search.go index e00f8596..a4361433 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -10,8 +10,8 @@ import ( const SEARCH = "search" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - web.P(SEARCH): {Name: "/search", Help: "搜索引擎", Action: ctx.CmdAction(mdb.SHORT, mdb.NAME), Hand: func(m *ice.Message, arg ...string) { + Index.Merge(&ice.Context{Commands: ice.Commands{ + web.P(SEARCH): {Name: "/search", Help: "搜索引擎", Actions: ctx.CmdAction(mdb.SHORT, mdb.NAME), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(m.Space(m.Option(ice.POD)), mdb.SEARCH, arg).StatusTimeCount() }}, }}) diff --git a/core/chat/sso.go b/core/chat/sso.go index 3067f234..906b28b0 100644 --- a/core/chat/sso.go +++ b/core/chat/sso.go @@ -12,7 +12,7 @@ import ( const SSO = "sso" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ "/sso": {Name: "/sso", Help: "登录", Hand: func(m *ice.Message, arg ...string) { if m.Option(ice.MSG_USERNAME) == "" { m.RenderIndex(web.SERVE, ice.VOLCANOS) diff --git a/core/chat/storm.go b/core/chat/storm.go index a87baea9..9cca0fa4 100644 --- a/core/chat/storm.go +++ b/core/chat/storm.go @@ -14,8 +14,8 @@ func _storm_key(m *ice.Message, key ...ice.Any) string { const STORM = "storm" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - STORM: {Name: "storm hash id auto insert create", Help: "应用", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + STORM: {Name: "storm hash id auto insert create", Help: "应用", Actions: ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { if ctx.Inputs(m, arg[0]) { return @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { m.Cmdy(m.Space(value[ice.POD]), ctx.CONTEXT, value[ice.CTX], ctx.COMMAND, value[ice.CMD]) }) } else { diff --git a/core/chat/trans.go b/core/chat/trans.go index c457c253..e4255eef 100644 --- a/core/chat/trans.go +++ b/core/chat/trans.go @@ -18,8 +18,8 @@ const ( ) func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TRANS: {Name: "trans from to auto", Help: "传输", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + TRANS: {Name: "trans from to auto", Help: "传输", Actions: ice.MergeAction(ice.Actions{ SEND: {Name: "send", Help: "发送", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, kit.Select(nfs.PWD, m.Option("to_path")), m.MergeURL2(path.Join(web.SHARE_LOCAL, m.Option("from_path")), ice.POD, m.Option(FROM), diff --git a/core/chat/website.go b/core/chat/website.go index b5ad49f6..2af8274b 100644 --- a/core/chat/website.go +++ b/core/chat/website.go @@ -156,7 +156,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 map[string]string, head []string) { + m.Cmd(m.PrefixKey(), ice.OptionFields("")).Table(func(index int, value ice.Maps, head []string) { m.PushSearch(value, mdb.TEXT, m.MergeWebsite(value[nfs.PATH])) }) } @@ -168,11 +168,11 @@ const ( const WEBSITE = "website" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ WEBSITE: {Name: "website", Help: "网站", Value: kit.Data(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path,type,name,text")}, - }, Commands: map[string]*ice.Command{ - "/website/": {Name: "/website/", Help: "网站", Action: ice.MergeAction(map[string]*ice.Action{}, ctx.CmdAction())}, - WEBSITE: {Name: "website path auto create import", Help: "网站", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + "/website/": {Name: "/website/", Help: "网站", Actions: ice.MergeAction(ice.Actions{}, ctx.CmdAction())}, + WEBSITE: {Name: "website path auto create import", Help: "网站", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.RENDER, mdb.CREATE, nfs.IML, m.PrefixKey()) m.Cmd(mdb.ENGINE, mdb.CREATE, nfs.IML, m.PrefixKey()) @@ -250,7 +250,7 @@ func init() { }) }}, }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { - mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) { + mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) { m.PushAnchor(m.MergeWebsite(value[nfs.PATH])) }) if len(arg) == 0 { diff --git a/core/code/autogen.go b/core/code/autogen.go index 16bf92eb..a42113b4 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -164,8 +164,8 @@ func init() { const AUTOGEN = "autogen" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - AUTOGEN: {Name: "autogen path auto create binpack script relay", Help: "生成", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + AUTOGEN: {Name: "autogen path auto create binpack script relay", Help: "生成", Actions: ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case cli.MAIN: diff --git a/core/code/bench.go b/core/code/bench.go index 918b8a86..5aaa0366 100644 --- a/core/code/bench.go +++ b/core/code/bench.go @@ -61,8 +61,8 @@ const ( const BENCH = "bench" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - BENCH: {Name: "bench zone id auto insert", Help: "性能压测", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + BENCH: {Name: "bench zone id auto insert", Help: "性能压测", Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert zone=some type=http,redis name=demo text='http://localhost:9020' nconn=3 nreqs=10", Help: "添加"}, ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { switch m.Option(mdb.TYPE) { diff --git a/core/code/binpack.go b/core/code/binpack.go index 72dc1433..9965194b 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -31,7 +31,7 @@ func _binpack_dir(m *ice.Message, f *os.File, dir string) { m.Option(nfs.DIR_DEEP, true) m.Option(nfs.DIR_TYPE, nfs.CAT) - m.Cmd(nfs.DIR, nfs.PWD).Sort(nfs.PATH).Tables(func(value map[string]string) { + m.Cmd(nfs.DIR, nfs.PWD).Sort(nfs.PATH).Tables(func(value ice.Maps) { switch path.Base(value[nfs.PATH]) { case "go.mod", "go.sum", "binpack.go", "version.go": return @@ -54,7 +54,7 @@ func _binpack_can(m *ice.Message, f *os.File, dir string) { fmt.Fprintln(f, _binpack_file(m, path.Join(dir, k), ice.PS+k)) } for _, k := range []string{LIB, PAGE, PANEL, PLUGIN, "publish/client/nodejs/"} { - m.Cmd(nfs.DIR, k).Sort(nfs.PATH).Tables(func(value map[string]string) { + m.Cmd(nfs.DIR, k).Sort(nfs.PATH).Tables(func(value ice.Maps) { fmt.Fprintln(f, _binpack_file(m, path.Join(dir, value[nfs.PATH]), ice.PS+value[nfs.PATH])) }) } @@ -67,8 +67,8 @@ func _binpack_ctx(m *ice.Message, f *os.File) { const BINPACK = "binpack" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { if kit.FileExists(path.Join(ice.USR_VOLCANOS, ice.PROTO_JS)) { m.Cmd(BINPACK, mdb.REMOVE) @@ -134,7 +134,7 @@ func init() { } `) - fmt.Fprintln(f, ` pack := map[string]string{`) + fmt.Fprintln(f, ` pack := ice.Maps{`) defer fmt.Fprintln(f, ` }`) if kit.FileExists(ice.USR_VOLCANOS) && kit.FileExists(ice.USR_INTSHELL) && m.Option(ice.MSG_USERPOD) == "" { @@ -153,7 +153,7 @@ func init() { fmt.Fprintln(f, _binpack_file(m, ice.README_MD)) fmt.Fprintln(f) - m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(nfs.PATH)).Tables(func(value map[string]string) { + m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(nfs.PATH)).Tables(func(value ice.Maps) { if s, e := os.Stat(value[nfs.PATH]); e == nil { if s.IsDir() { _binpack_dir(m, f, value[nfs.PATH]) diff --git a/core/code/c.go b/core/code/c.go index 938d17ad..a0bd76e8 100644 --- a/core/code/c.go +++ b/core/code/c.go @@ -48,8 +48,8 @@ const ( const C = "c" func init() { - Index.Register(&ice.Context{Name: C, Help: "系统", Commands: map[string]*ice.Command{ - C: {Name: C, Help: "系统", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Register(&ice.Context{Name: C, Help: "系统", Commands: ice.Commands{ + C: {Name: C, Help: "系统", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} { for _, k := range []string{H, C, CC} { @@ -79,7 +79,7 @@ func init() { // _go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2]) }}, }, PlugAction())}, - MAN: {Name: MAN, Help: "手册", Action: ice.MergeAction(map[string]*ice.Action{ + MAN: {Name: MAN, Help: "手册", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for _, cmd := range []string{mdb.SEARCH, mdb.RENDER, mdb.PLUGIN} { for _, k := range []string{MAN1, MAN2, MAN3, MAN8} { @@ -102,7 +102,7 @@ func init() { } }}, }, PlugAction())}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ C: {Name: C, Help: "系统", Value: kit.Data(PLUG, kit.Dict( SPLIT, kit.Dict("space", " ", "operator", "{[(.,:;!|<>)]}"), PREFIX, kit.Dict("//", COMMENT, "/* ", COMMENT, "* ", COMMENT), PREPARE, kit.Dict( diff --git a/core/code/case.go b/core/code/case.go index 1dec9104..efd5bdc4 100644 --- a/core/code/case.go +++ b/core/code/case.go @@ -15,8 +15,8 @@ import ( const CASE = "case" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - CASE: {Name: "case dev zone id auto", Help: "用例", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + CASE: {Name: "case dev zone id auto", Help: "用例", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create name address", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.SPIDE, mdb.CREATE, arg) }}, @@ -25,7 +25,7 @@ func init() { cli.CHECK: {Name: "check", Help: "检查", Hand: func(m *ice.Message, arg ...string) { if m.ProcessInner(); len(arg) > 0 { success := 0 - m.Cmd(m.PrefixKey(), arg[0]).Tables(func(value map[string]string) { + m.Cmd(m.PrefixKey(), arg[0]).Tables(func(value ice.Maps) { m.Push(mdb.TIME, m.Time()) m.Push(mdb.ID, value[mdb.ID]) if err := m.Cmdx(m.PrefixKey(), cli.CHECK, value); err == ice.OK { @@ -75,7 +75,7 @@ func init() { m.PushAction(ice.RUN, cli.CHECK) } }}, - "test": {Name: "test path func auto run case", Help: "测试用例", Action: map[string]*ice.Action{ + "test": {Name: "test path func auto run case", Help: "测试用例", Actions: ice.Actions{ "run": {Name: "run", Help: "运行", Hand: func(m *ice.Message, arg ...string) { // cli.Follow(m, "run", func() { m.Option(cli.CMD_DIR, kit.Select(path.Dir(arg[0]), arg[0], strings.HasSuffix(arg[0], "/"))) @@ -87,7 +87,7 @@ func init() { if strings.HasSuffix(arg[0], "/") { msg.Option(cli.CMD_DIR, arg[0]) msg.Split(msg.Cmdx(cli.SYSTEM, "grep", "-r", "func Test.*(", nfs.PWD), "file:line", ":", "\n") - msg.Tables(func(value map[string]string) { + msg.Tables(func(value ice.Maps) { if strings.HasPrefix(strings.TrimSpace(value["line"]), "//") { return } diff --git a/core/code/compile.go b/core/code/compile.go index af615420..904c04ad 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -41,12 +41,12 @@ const ( const COMPILE = "compile" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ COMPILE: {Name: COMPILE, Help: "编译", Value: kit.Data(nfs.PATH, ice.USR_PUBLISH, cli.ENV, kit.Dict("GOPROXY", "https://goproxy.cn,direct", "GOPRIVATE", "shylinux.com,github.com", "CGO_ENABLED", "0"), )}, - }, Commands: map[string]*ice.Command{ - COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack relay install", Help: "编译", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack relay install", Help: "编译", Actions: ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, `.*\.go$`)).Sort(nfs.PATH) }}, diff --git a/core/code/favor.go b/core/code/favor.go index a85aded6..a2c687a1 100644 --- a/core/code/favor.go +++ b/core/code/favor.go @@ -9,8 +9,8 @@ import ( const FAVOR = "favor" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert zone=数据结构 type=go name=hi text=hello path file line", Help: "添加"}, INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) { m.ProcessCommand(INNER, m.OptionSplit("path,file,line"), arg...) diff --git a/core/code/go.go b/core/code/go.go index 63421520..09ff1360 100644 --- a/core/code/go.go +++ b/core/code/go.go @@ -53,10 +53,10 @@ func _go_help(m *ice.Message, key string) { } } func _go_find(m *ice.Message, key string, dir string) { - m.Cmd(nfs.FIND, dir, key).Tables(func(value map[string]string) { m.PushSearch(nfs.LINE, 1, value) }) + m.Cmd(nfs.FIND, dir, key).Tables(func(value ice.Maps) { m.PushSearch(nfs.LINE, 1, value) }) } func _go_grep(m *ice.Message, key string, dir string) { - m.Cmd(nfs.GREP, dir, key).Tables(func(value map[string]string) { m.PushSearch(value) }) + m.Cmd(nfs.GREP, dir, key).Tables(func(value ice.Maps) { m.PushSearch(value) }) } var _cache_mods = map[string]*ice.Message{} @@ -177,8 +177,8 @@ func _mod_show(m *ice.Message, file string) { ) block := "" - require := map[string]string{} - replace := map[string]string{} + require := ice.Maps{} + replace := ice.Maps{} m.Cmd(nfs.CAT, file, func(ls []string, line string) { switch { case strings.HasPrefix(line, MODULE): @@ -223,7 +223,7 @@ const SUM = "sum" const GODOC = "godoc" func init() { - Index.Register(&ice.Context{Name: GO, Help: "后端", Commands: map[string]*ice.Command{ + Index.Register(&ice.Context{Name: GO, Help: "后端", Commands: ice.Commands{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.SEARCH, mdb.CREATE, GODOC, m.Prefix(GO)) m.Cmd(mdb.ENGINE, mdb.CREATE, GO, m.Prefix(GO)) @@ -234,20 +234,20 @@ func init() { m.Cmd(mdb.PLUGIN, mdb.CREATE, k, m.Prefix(k)) } }}, - GODOC: {Name: "godoc", Help: "文档", Action: ice.MergeAction(map[string]*ice.Action{ + GODOC: {Name: "godoc", Help: "文档", Actions: ice.MergeAction(ice.Actions{ mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(cli.SYSTEM, GO, "doc", strings.TrimSuffix(arg[1], ice.PT+arg[0]), kit.Dict(cli.CMD_DIR, arg[2])).SetAppend() }}, }, PlugAction())}, - SUM: {Name: "sum", Help: "版本", Action: ice.MergeAction(map[string]*ice.Action{ + SUM: {Name: "sum", Help: "版本", Actions: ice.MergeAction(ice.Actions{ mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }}, }, PlugAction())}, - MOD: {Name: "mod", Help: "模块", Action: ice.MergeAction(map[string]*ice.Action{ + MOD: {Name: "mod", Help: "模块", Actions: ice.MergeAction(ice.Actions{ mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }}, }, PlugAction())}, - GO: {Name: "go", Help: "后端", Action: ice.MergeAction(map[string]*ice.Action{ + GO: {Name: "go", Help: "后端", Actions: ice.MergeAction(ice.Actions{ mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if arg[0] == GO { _go_tags(m, kit.Select(cli.MAIN, arg, 1)) @@ -259,7 +259,7 @@ func init() { mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_exec(m, arg...) }}, mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _go_show(m, arg...) }}, }, PlugAction())}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ MOD: {Name: MOD, Help: "模块", Value: kit.Data(PLUG, kit.Dict( PREFIX, kit.Dict("//", COMMENT), PREPARE, kit.Dict( KEYWORD, kit.Simple("go", "module", "require", "replace", "=>"), diff --git a/core/code/inner.go b/core/code/inner.go index b9c61a45..f51f36cc 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -68,8 +68,8 @@ func LoadPlug(m *ice.Message, language ...string) { }) } } -func PlugAction() map[string]*ice.Action { - return map[string]*ice.Action{ +func PlugAction() ice.Actions { + return ice.Actions{ mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Config(PLUG)) }}, mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }}, @@ -98,8 +98,8 @@ const ( const INNER = "inner" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - INNER: {Name: "inner path=src/@key file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict(ice.DisplayLocal("")), Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + INNER: {Name: "inner path=src/@key file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict(ice.DisplayLocal("")), Actions: ice.MergeAction(ice.Actions{ mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" { m.Echo(kit.Select("{}", m.Config(kit.Keys(PLUG, arg[0])))) @@ -117,7 +117,7 @@ func init() { m.Option(nfs.DIR_ROOT, arg[2]) m.Option(cli.CMD_DIR, kit.Path(arg[2])) m.Cmdy(mdb.SEARCH, arg[0], arg[1], arg[2]) - m.Cmd(FAVOR, arg[1], ice.OptionFields("")).Tables(func(value map[string]string) { + m.Cmd(FAVOR, arg[1], ice.OptionFields("")).Tables(func(value ice.Maps) { if p := path.Join(value[nfs.PATH], value[nfs.FILE]); strings.HasPrefix(p, m.Option(nfs.PATH)) { m.Push(nfs.FILE, strings.TrimPrefix(p, m.Option(nfs.PATH))) m.Push(nfs.LINE, value[nfs.LINE]) @@ -197,7 +197,7 @@ func init() { } m.Set(ice.MSG_STATUS) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ INNER: {Name: "inner", Help: "源代码", Value: kit.Data( EXEC, kit.Dict("py", []string{"python"}), PLUG, kit.Dict( diff --git a/core/code/install.go b/core/code/install.go index 8e795526..15b67875 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -105,7 +105,7 @@ func _install_spawn(m *ice.Message, arg ...string) { if m.Option(INSTALL) == "" && kit.FileExists(kit.Path(source, "_install")) { m.Option(INSTALL, "_install") } - m.Cmd(nfs.DIR, path.Join(source, m.Option(INSTALL))).Tables(func(value map[string]string) { + m.Cmd(nfs.DIR, path.Join(source, m.Option(INSTALL))).Tables(func(value ice.Maps) { m.Cmd(cli.SYSTEM, "cp", "-r", strings.TrimSuffix(value[nfs.PATH], ice.PS), target+ice.PS) }) } @@ -127,7 +127,7 @@ func _install_start(m *ice.Message, arg ...string) { } } func _install_stop(m *ice.Message, arg ...string) { - m.Cmd(cli.DAEMON).Tables(func(value map[string]string) { + m.Cmd(cli.DAEMON).Tables(func(value ice.Maps) { if value[cli.PID] == m.Option(cli.PID) { m.Cmd(cli.DAEMON, cli.STOP, kit.Dict(mdb.HASH, value[mdb.HASH])) } @@ -137,12 +137,12 @@ func _install_stop(m *ice.Message, arg ...string) { func _install_service(m *ice.Message, arg ...string) { arg = kit.Split(path.Base(arg[0]), "-.")[:1] m.Fields(len(arg[1:]), "time,port,status,pid,cmd,dir") - m.Cmd(mdb.SELECT, cli.DAEMON, "", mdb.HASH).Tables(func(value map[string]string) { + m.Cmd(mdb.SELECT, cli.DAEMON, "", mdb.HASH).Tables(func(value ice.Maps) { if strings.Contains(value[ice.CMD], path.Join(ice.BIN, arg[0])) { m.Push("", value, kit.Split(m.OptionFields())) } }) - m.Set(tcp.PORT).Tables(func(value map[string]string) { m.Push(tcp.PORT, path.Base(value[nfs.DIR])) }) + m.Set(tcp.PORT).Tables(func(value ice.Maps) { m.Push(tcp.PORT, path.Base(value[nfs.DIR])) }) m.StatusTimeCount() } @@ -152,12 +152,12 @@ const ( const INSTALL = "install" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,path,link", nfs.PATH, ice.USR_INSTALL, )}, - }, Commands: map[string]*ice.Command{ - INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Actions: ice.MergeAction(ice.Actions{ web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) { _install_download(m) }}, @@ -204,8 +204,8 @@ func init() { }}) } -func InstallAction(args ...ice.Any) map[string]*ice.Action { - return map[string]*ice.Action{ice.CTX_INIT: mdb.AutoConfig(args...), +func InstallAction(args ...ice.Any) ice.Actions { + return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...), web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INSTALL, web.DOWNLOAD, m.Config(nfs.SOURCE)) }}, diff --git a/core/code/js.go b/core/code/js.go index 8abd47ae..63712f0a 100644 --- a/core/code/js.go +++ b/core/code/js.go @@ -51,8 +51,8 @@ const JSON = "json" const NODE = "node" func init() { - Index.Register(&ice.Context{Name: JS, Help: "前端", Commands: map[string]*ice.Command{ - JS: {Name: "js", Help: "前端", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Register(&ice.Context{Name: JS, Help: "前端", Commands: ice.Commands{ + JS: {Name: "js", Help: "前端", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} { m.Cmd(cmd, mdb.CREATE, JSON, m.PrefixKey()) @@ -83,12 +83,12 @@ func init() { _go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2]) }}, }, PlugAction())}, - NODE: {Name: "node auto download", Help: "前端", Action: map[string]*ice.Action{ + NODE: {Name: "node auto download", Help: "前端", Actions: ice.Actions{ web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INSTALL, m.Config(nfs.SOURCE)) }}, }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ NODE: {Name: NODE, Help: "前端", Value: kit.Data( nfs.SOURCE, "https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz", )}, diff --git a/core/code/oauth.go b/core/code/oauth.go index 6b5526e0..b3d1fc5e 100644 --- a/core/code/oauth.go +++ b/core/code/oauth.go @@ -22,10 +22,10 @@ func init() { LOGIN_OAUTH = "https://github.com/login/oauth/" API_GITHUB = "https://api.github.com/" ) - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ OAUTH: {Name: OAUTH, Help: "授权", Value: kit.Data(mdb.FIELD, "time,hash,code,access_token,scope,token_type")}, - }, Commands: map[string]*ice.Command{ - OAUTH: {Name: "oauth hash auto", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + OAUTH: {Name: "oauth hash auto", Help: "授权", Actions: ice.MergeAction(ice.Actions{ ctx.CONFIG: {Name: "config client_id client_secret redirect_uri", Help: "配置", Hand: func(m *ice.Message, arg ...string) { m.ConfigOption(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI) }}, @@ -77,7 +77,7 @@ func init() { m.Debug("what %v", m.FormatMeta()) } }}, - "/oauth": {Name: "/oauth", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + "/oauth": {Name: "/oauth", Help: "授权", Actions: ice.MergeAction(ice.Actions{}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if m.Option(CODE) != "" { m.RenderCmd(m.PrefixKey(), m.Cmdx(m.PrefixKey(), mdb.CREATE, m.OptionSimple(CODE))) } diff --git a/core/code/pprof.go b/core/code/pprof.go index 0c0880c5..b24465ab 100644 --- a/core/code/pprof.go +++ b/core/code/pprof.go @@ -24,12 +24,12 @@ const ( const PPROF = "pprof" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ PPROF: {Name: PPROF, Help: "性能分析", Value: kit.Data( mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,text,file", PPROF, kit.List(GO, "tool", PPROF), )}, - }, Commands: map[string]*ice.Command{ - PPROF: {Name: "pprof zone id auto", Help: "性能分析", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + PPROF: {Name: "pprof zone id auto", Help: "性能分析", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool { if p := r.URL.Path; strings.HasPrefix(p, "/debug") { @@ -44,7 +44,7 @@ func init() { case BINNARY: m.Cmdy(nfs.DIR, ice.BIN, nfs.DIR_CLI_FIELDS).RenameAppend(nfs.PATH, BINNARY) case SERVICE: - m.Cmd(web.SPIDE).Tables(func(value map[string]string) { + m.Cmd(web.SPIDE).Tables(func(value ice.Maps) { m.Push(SERVICE, kit.MergeURL2(value["client.url"], "/debug/pprof/profile")) }) } @@ -73,7 +73,7 @@ func init() { return } - m.Tables(func(value map[string]string) { + m.Tables(func(value ice.Maps) { m.PushDownload(mdb.LINK, "pprof.pd.gz", value[nfs.FILE]) m.PushButton(web.SERVE) }) diff --git a/core/code/publish.go b/core/code/publish.go index 528d4776..16612942 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -60,10 +60,10 @@ const ( const PUBLISH = "publish" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data(nfs.PATH, ice.USR_PUBLISH, ice.CONTEXTS, _contexts)}, - }, Commands: map[string]*ice.Command{ - PUBLISH: {Name: "publish path auto create volcanos icebergs intshell export", Help: "发布", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + PUBLISH: {Name: "publish path auto create volcanos icebergs intshell export", Help: "发布", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Config(nfs.PATH)) m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey()) diff --git a/core/code/py.go b/core/code/py.go index 3d9eddef..724d4462 100644 --- a/core/code/py.go +++ b/core/code/py.go @@ -26,8 +26,8 @@ func _py_main_script(m *ice.Message, arg ...string) { const PY = nfs.PY func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - PY: {Name: "py path auto", Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + PY: {Name: "py path auto", Help: "脚本", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.ENGINE, mdb.CREATE, PY, m.PrefixKey()) m.Cmd(mdb.RENDER, mdb.CREATE, PY, m.PrefixKey()) @@ -48,7 +48,7 @@ func init() { m.Option(nfs.DIR_REG, ".*.(py)$") m.Cmdy(nfs.DIR, arg) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ PY: {Name: PY, Help: "脚本", Value: kit.Data(PLUG, kit.Dict( SPLIT, kit.Dict(SPACE, " ", OPERATE, "{[(.,;!|<>)]}"), PREFIX, kit.Dict("#!", COMMENT, "# ", COMMENT), SUFFIX, kit.Dict(" {", COMMENT), diff --git a/core/code/sh.go b/core/code/sh.go index 5b722770..e56910bd 100644 --- a/core/code/sh.go +++ b/core/code/sh.go @@ -58,8 +58,8 @@ func _sh_exec(m *ice.Message, arg ...string) { const SH = nfs.SH func init() { - Index.Register(&ice.Context{Name: SH, Help: "命令", Commands: map[string]*ice.Command{ - SH: {Name: "sh path auto", Help: "命令", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Register(&ice.Context{Name: SH, Help: "命令", Commands: ice.Commands{ + SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) { for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} { m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) @@ -92,7 +92,7 @@ func init() { m.Option(nfs.DIR_REG, ".*.(sh)$") m.Cmdy(nfs.DIR, arg) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ SH: {Name: SH, Help: "命令", Value: kit.Data(PLUG, kit.Dict( SPLIT, kit.Dict(SPACE, " ", OPERATE, "{[(.,;!|<>)]}"), PREFIX, kit.Dict("#!", COMMENT, "# ", COMMENT), SUFFIX, kit.Dict(" {", COMMENT), diff --git a/core/code/shy.go b/core/code/shy.go index e0204046..3b51b0cd 100644 --- a/core/code/shy.go +++ b/core/code/shy.go @@ -34,8 +34,8 @@ func _shy_exec(m *ice.Message, arg ...string) { const SHY = "shy" func init() { - Index.Register(&ice.Context{Name: SHY, Help: "脚本", Commands: map[string]*ice.Command{ - SHY: {Name: "shy path auto", Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Register(&ice.Context{Name: SHY, Help: "脚本", Commands: ice.Commands{ + SHY: {Name: "shy path auto", Help: "脚本", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} { m.Cmd(cmd, mdb.CREATE, SHY, m.PrefixKey()) @@ -61,7 +61,7 @@ func init() { } m.Cmdy("web.wiki.word", arg) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ SHY: {Name: SHY, Help: "脚本", Value: kit.Data(PLUG, kit.Dict( mdb.RENDER, kit.Dict(), PREFIX, kit.Dict("# ", COMMENT), PREPARE, kit.Dict( diff --git a/core/code/template.go b/core/code/template.go index 2fd4ac09..e5b389b3 100644 --- a/core/code/template.go +++ b/core/code/template.go @@ -13,8 +13,8 @@ import ( const TEMPLATE = "template" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TEMPLATE: {Name: "template name auto", Help: "模板", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + TEMPLATE: {Name: "template name auto", Help: "模板", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for _, _template := range _template_list { m.Cmd(TEMPLATE, mdb.CREATE, kit.SimpleKV(kit.Format(_template[0]), _template[1:]...)) diff --git a/core/code/upgrade.go b/core/code/upgrade.go index cb5be301..79cf8989 100644 --- a/core/code/upgrade.go +++ b/core/code/upgrade.go @@ -16,14 +16,14 @@ import ( const UPGRADE = "upgrade" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ UPGRADE: {Name: UPGRADE, Help: "升级", Value: kit.Dict(mdb.HASH, kit.Dict( nfs.TARGET, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, "bin", nfs.FILE, "ice.bin")), nfs.SOURCE, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, "tar", nfs.FILE, "contexts.src.tar.gz")), nfs.BINARY, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, "tar", nfs.FILE, "contexts.bin.tar.gz")), ))}, - }, Commands: map[string]*ice.Command{ - UPGRADE: {Name: "upgrade item=target,source,binary run restart", Help: "升级", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + UPGRADE: {Name: "upgrade item=target,source,binary run restart", Help: "升级", Actions: ice.Actions{ cli.RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) { m.Sleep("1s").Go(func() { m.Cmd(ice.EXIT, 1) }) }}, diff --git a/core/code/vimer.go b/core/code/vimer.go index 55aadfbe..07c01edb 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -145,8 +145,8 @@ func _vimer_go_complete(m *ice.Message, name string, arg ...string) *ice.Message const VIMER = "vimer" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Meta: kit.Dict(ice.DisplayLocal("", INNER)), Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Meta: kit.Dict(ice.DisplayLocal("", INNER)), Actions: ice.Actions{ nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) { m.Option(nfs.CONTENT, kit.Select(_vimer_defs(m, kit.Ext(m.Option(nfs.FILE))), m.Option(nfs.CONTENT))) m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))) diff --git a/core/code/webpack.go b/core/code/webpack.go index 075ddcdc..9ff715ec 100644 --- a/core/code/webpack.go +++ b/core/code/webpack.go @@ -48,7 +48,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) { m.Option(nfs.DIR_PACK, true) m.Option(nfs.DIR_TYPE, nfs.CAT) - // m.Cmd(nfs.DIR, ice.SRC).Tables(func(value map[string]string) { + // m.Cmd(nfs.DIR, ice.SRC).Tables(func(value ice.Maps) { // if kit.Ext(value[nfs.PATH]) == JS { // fmt.Fprintln(js, `_can_name = "`+path.Join("/require", ice.Info.Make.Module, value[nfs.PATH])+`"`) // fmt.Fprintln(js, m.Cmdx(nfs.CAT, value[nfs.PATH])) @@ -57,7 +57,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) { m.Option(nfs.DIR_ROOT, dir) for _, k := range []string{LIB, PANEL, PLUGIN} { - m.Cmd(nfs.DIR, k).Tables(func(value map[string]string) { + m.Cmd(nfs.DIR, k).Tables(func(value ice.Maps) { if kit.Ext(value[nfs.PATH]) == CSS { fmt.Fprintln(css, m.Cmdx(nfs.CAT, value[nfs.PATH])) fmt.Fprintln(js, `Volcanos.meta.cache["`+path.Join(ice.PS, value[nfs.PATH])+`"] = []`) @@ -66,7 +66,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) { } fmt.Fprintln(js) for _, k := range []string{LIB, PANEL, PLUGIN} { - m.Cmd(nfs.DIR, k).Tables(func(value map[string]string) { + m.Cmd(nfs.DIR, k).Tables(func(value ice.Maps) { if kit.Ext(value[nfs.PATH]) == JS { fmt.Fprintln(js, `_can_name = "`+path.Join(ice.PS, value[nfs.PATH])+`"`) fmt.Fprintln(js, m.Cmdx(nfs.CAT, value[nfs.PATH])) @@ -134,8 +134,8 @@ const DEVPACK = "devpack" const WEBPACK = "webpack" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - WEBPACK: {Name: "webpack path auto create remove", Help: "打包", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + WEBPACK: {Name: "webpack path auto create remove", Help: "打包", Actions: ice.Actions{ mdb.CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) { _webpack_cache(m.Spawn(), _volcanos(m), true) }}, diff --git a/core/code/zml.go b/core/code/zml.go index 88eafc96..8945d4d9 100644 --- a/core/code/zml.go +++ b/core/code/zml.go @@ -27,8 +27,8 @@ func _website_url(m *ice.Message, file string) string { const ZML = nfs.ZML func init() { - Index.Register(&ice.Context{Name: ZML, Help: "网页", Commands: map[string]*ice.Command{ - ZML: {Name: "zml", Help: "网页", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Register(&ice.Context{Name: ZML, Help: "网页", Commands: ice.Commands{ + ZML: {Name: "zml", Help: "网页", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.PLUGIN, mdb.CREATE, nfs.ZML, m.PrefixKey()) m.Cmd(mdb.RENDER, mdb.CREATE, nfs.ZML, m.PrefixKey()) @@ -38,7 +38,7 @@ func init() { m.EchoIFrame(_website_url(m, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE))) }}, }, PlugAction())}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ ZML: {Name: ZML, Help: "网页", Value: kit.Data(PLUG, kit.Dict(PREFIX, kit.Dict("# ", COMMENT), PREPARE, kit.Dict( KEYWORD, kit.Simple( "head", "left", "main", "foot", diff --git a/core/mall/asset.go b/core/mall/asset.go index 785f8216..a60f087e 100644 --- a/core/mall/asset.go +++ b/core/mall/asset.go @@ -59,15 +59,15 @@ const ( const ASSET = "asset" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ASSET: {Name: ASSET, Help: "资产", Value: kit.Data( mdb.SHORT, ACCOUNT, mdb.FIELD, "time,id,type,amount,name,text", mdb.ALIAS, kit.Dict(FROM, ACCOUNT, TO, ACCOUNT), )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ ASSET: {Name: "asset account id auto spend trans bonus", Help: "资产", Meta: kit.Dict( "_trans", kit.Dict(ACCOUNT, "账户", AMOUNT, "金额", FROM, "转出", TO, "转入", "time", "时间", "name", "商家", "text", "备注"), - ), Action: ice.MergeAction(map[string]*ice.Action{ + ), Actions: ice.MergeAction(ice.Actions{ SPEND: {Name: "spend account name amount time@date text", Help: "支出", Hand: func(m *ice.Message, arg ...string) { _sub_amount(m, arg) _asset_insert(m, arg[1], kit.Simple(mdb.TYPE, "支出", arg[2:])...) @@ -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 map[string]string, head []string) { + m.Cmd(ASSET).Table(func(index int, value ice.Maps, head []string) { _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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { amount += kit.Int(value[AMOUNT]) count++ }) diff --git a/core/mall/salary.go b/core/mall/salary.go index 55efa21a..814231b9 100644 --- a/core/mall/salary.go +++ b/core/mall/salary.go @@ -14,17 +14,17 @@ const ( const SALARY = "salary" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SALARY: {Name: SALARY, Help: "工资", Value: kit.Data( mdb.SHORT, MONTH, mdb.FIELD, "month,company,amount,income,tax", )}, - }, Commands: map[string]*ice.Command{ - SALARY: {Name: "salary month auto create", Help: "工资", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SALARY: {Name: "salary month auto create", Help: "工资", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create month company amount income tax 公积金 养老保险 医疗保险 生育保险 工伤保险 失业保险 企业公积金 企业养老保险 企业医疗保险 企业生育保险 企业工伤保险 企业失业保险", Help: "添加"}, }, 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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { amount += kit.Int(value[AMOUNT]) income += kit.Int(value[INCOME]) tax += kit.Int(value[TAX]) diff --git a/core/team/count.go b/core/team/count.go index c3b84bb4..92761e45 100644 --- a/core/team/count.go +++ b/core/team/count.go @@ -12,10 +12,10 @@ import ( const COUNT = "count" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ COUNT: {Name: "count begin_time@date end_time@date auto insert", Help: "倒计时", Meta: kit.Dict( ice.Display(""), - ), Action: ice.MergeAction(map[string]*ice.Action{ + ), Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.INSERT, arg) }}, @@ -25,7 +25,7 @@ func init() { msg.SortTime(BEGIN_TIME) tz := int64(8) - msg.Table(func(index int, value map[string]string, head []string) { + msg.Table(func(index int, value ice.Maps, head []string) { if value[mdb.STATUS] == CANCEL { return } diff --git a/core/team/plan.go b/core/team/plan.go index 13c52018..6b03144a 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -65,10 +65,10 @@ const ( const PLAN = "plan" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Meta: kit.Dict( ice.Display("/plugin/local/team/plan.js"), - ), Action: ice.MergeAction(map[string]*ice.Action{ + ), Actions: ice.MergeAction(ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) m.Cmdy(TASK, mdb.INPUTS, arg) diff --git a/core/team/task.go b/core/team/task.go index 380f9c46..3bbbce3c 100644 --- a/core/team/task.go +++ b/core/team/task.go @@ -56,12 +56,12 @@ const ( const TASK = "task" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TASK: {Name: TASK, Help: "任务", Value: kit.Data( mdb.SHORT, mdb.ZONE, mdb.FIELD, "begin_time,id,status,level,score,type,name,text", )}, - }, Commands: map[string]*ice.Command{ - TASK: {Name: "task zone id auto insert export import", Help: "任务", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + TASK: {Name: "task zone id auto insert export import", Help: "任务", Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.HASH, m.OptionSimple(mdb.ZONE)) m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.ZONE, m.Option(mdb.ZONE), @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { m.PushButton(_task_action(m, value[STATUS])) status[value[mdb.STATUS]]++ }) diff --git a/core/team/todo.go b/core/team/todo.go index 35e76a20..92c968ff 100644 --- a/core/team/todo.go +++ b/core/team/todo.go @@ -9,8 +9,8 @@ import ( const TODO = "todo" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TODO: {Name: "todo hash list create export import", Help: "待办", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + TODO: {Name: "todo hash list create export import", Help: "待办", Actions: ice.MergeAction(ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INPUTS, m.PrefixKey(), "", mdb.HASH, arg) m.Cmdy(TASK, mdb.INPUTS, arg) diff --git a/core/wiki/brief.go b/core/wiki/brief.go index d2b12057..c7595a73 100644 --- a/core/wiki/brief.go +++ b/core/wiki/brief.go @@ -9,11 +9,11 @@ import ( const BRIEF = "brief" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ BRIEF: {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, arg ...string) { _wiki_template(m, m.CommandKey(), "", arg[0], arg[1:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(nfs.TEMPLATE, `

{{.Option "text"}}

`)}, }}) } diff --git a/core/wiki/chart.go b/core/wiki/chart.go index 8cfac2a8..f1ede840 100644 --- a/core/wiki/chart.go +++ b/core/wiki/chart.go @@ -182,13 +182,13 @@ const ( const CHART = "chart" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ CHART: {Name: "chart type=label,chain,sequence auto text", Help: "图表", Hand: func(m *ice.Message, arg ...string) { if len(arg) > 1 { _chart_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...) } }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ CHART: {Name: CHART, Help: "图表", Value: kit.Data( nfs.TEMPLATE, ` {{.Option "name"}} diff --git a/core/wiki/image.go b/core/wiki/image.go index 05d823d8..41018e2e 100644 --- a/core/wiki/image.go +++ b/core/wiki/image.go @@ -22,8 +22,8 @@ const ( const IMAGE = "image" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - IMAGE: {Name: "image url height auto", Help: "图片", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + IMAGE: {Name: "image url height auto", Help: "图片", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.RENDER, mdb.CREATE, PNG, m.PrefixKey()) }}, @@ -37,7 +37,7 @@ func init() { m.Option("height", kit.Select("", arg, 1)) _image_show(m, arg[0]) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ IMAGE: {Name: IMAGE, Help: "图片", Value: kit.Data( nfs.TEMPLATE, ``, nfs.PATH, ice.USR_LOCAL_IMAGE, diff --git a/core/wiki/local.go b/core/wiki/local.go index 64fc65f0..6ab78e54 100644 --- a/core/wiki/local.go +++ b/core/wiki/local.go @@ -14,12 +14,12 @@ func _local_show(m *ice.Message, name, text string, arg ...string) { const LOCAL = "local" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ LOCAL: {Name: "local [name] file", Help: "文件", Hand: func(m *ice.Message, arg ...string) { arg = _name(m, arg) _local_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ LOCAL: {Name: LOCAL, Help: "文件", Value: kit.Data( nfs.TEMPLATE, `{{range $index, $value := .Optionv "input"}}{{$value}}{{end}}`, )}, diff --git a/core/wiki/order.go b/core/wiki/order.go index 2ab0d10a..4310e604 100644 --- a/core/wiki/order.go +++ b/core/wiki/order.go @@ -17,11 +17,11 @@ func _order_show(m *ice.Message, text string, arg ...string) { const ORDER = "order" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ ORDER: {Name: "order `[item\n]...`", Help: "列表", Hand: func(m *ice.Message, arg ...string) { _order_show(m, arg[0], arg[1:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ ORDER: {Name: ORDER, Help: "列表", Value: kit.Data( nfs.TEMPLATE, ``, )}, diff --git a/core/wiki/parse.go b/core/wiki/parse.go index 39713df2..45ef32c6 100644 --- a/core/wiki/parse.go +++ b/core/wiki/parse.go @@ -19,7 +19,7 @@ import ( const PARSE = "parse" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ PARSE: {Name: "parse type=auto,base64,json,http,form,time,list auto text", Help: "解析", Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 { return diff --git a/core/wiki/refer.go b/core/wiki/refer.go index e44458fc..28f4ae4e 100644 --- a/core/wiki/refer.go +++ b/core/wiki/refer.go @@ -26,11 +26,11 @@ func _refer_show(m *ice.Message, text string, arg ...string) { const REFER = "refer" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ REFER: {Name: "refer `[[name] url\n]...`", Help: "参考", Hand: func(m *ice.Message, arg ...string) { _refer_show(m, arg[0], arg[1:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ REFER: {Name: REFER, Help: "参考", Value: kit.Data( nfs.TEMPLATE, ``, )}, diff --git a/core/wiki/shell.go b/core/wiki/shell.go index 68d7a09a..8637d0b7 100644 --- a/core/wiki/shell.go +++ b/core/wiki/shell.go @@ -19,12 +19,12 @@ const ( const SHELL = "shell" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, arg ...string) { arg = _name(m, arg) _shell_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ SHELL: {Name: SHELL, Help: "命令", Value: kit.Data( nfs.TEMPLATE, `$ {{.Option "input"}} # {{.Option "name"}} {{.Option "output"}}`, diff --git a/core/wiki/spark.go b/core/wiki/spark.go index 34f68483..727dab9a 100644 --- a/core/wiki/spark.go +++ b/core/wiki/spark.go @@ -43,8 +43,8 @@ const ( const SPARK = "spark" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - SPARK: {Name: "spark [name] text auto field:text value:text", Help: "段落", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + SPARK: {Name: "spark [name] text auto field:text value:text", Help: "段落", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...ice.Any) string { arg := kit.Simple(args...) @@ -126,7 +126,7 @@ func init() { arg = _name(m, arg) _spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ SPARK: {Name: SPARK, Help: "段落", Value: kit.Data( nfs.TEMPLATE, `

{{.Option "text"}}

`, ssh.PROMPT, kit.Dict(SHELL, "$ "), diff --git a/core/wiki/table.go b/core/wiki/table.go index f51934f2..af350f0c 100644 --- a/core/wiki/table.go +++ b/core/wiki/table.go @@ -12,7 +12,7 @@ func _table_run(m *ice.Message, arg ...string) { msg := m.Cmd(arg) list := [][]string{} - msg.Table(func(index int, value map[string]string, head []string) { + msg.Table(func(index int, value ice.Maps, head []string) { if index == 0 { m.Optionv("head", head) } @@ -61,15 +61,15 @@ func _table_show(m *ice.Message, text string, arg ...string) { const TABLE = "table" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TABLE: {Name: "table `[item item\n]...`", Help: "表格", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + TABLE: {Name: "table `[item item\n]...`", Help: "表格", Actions: ice.Actions{ ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { _table_run(m, arg...) }}, }, Hand: func(m *ice.Message, arg ...string) { _table_show(m, arg[0], arg[1:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ TABLE: {Name: TABLE, Help: "表格", Value: kit.Data( nfs.TEMPLATE, `{{range $i, $v := .Optionv "head"}}{{end}} diff --git a/core/wiki/title.go b/core/wiki/title.go index 4316461b..7a15abaa 100644 --- a/core/wiki/title.go +++ b/core/wiki/title.go @@ -77,7 +77,7 @@ const ( const TITLE = "title" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ TITLE: {Name: "title [navmenu|premenu|chapter|section|endmenu] text", Help: "标题", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { arg = append(arg, kit.Slice(kit.Split(ice.Info.NodeName, "-"), -1)[0]) @@ -93,7 +93,7 @@ func init() { _title_show(m, "", arg[0], arg[1:]...) } }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ TITLE: {Name: TITLE, Help: "标题", Value: kit.Data( nfs.TEMPLATE, `<{{.Option "level"}} {{.OptionTemplate}}>{{.Option "prefix"}} {{.Option "text"}}`, PREMENU, ``, diff --git a/core/wiki/video.go b/core/wiki/video.go index 0787dfcb..9299d2d4 100644 --- a/core/wiki/video.go +++ b/core/wiki/video.go @@ -22,15 +22,15 @@ const ( const VIDEO = "video" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - VIDEO: {Name: "video url", Help: "视频", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + VIDEO: {Name: "video url", Help: "视频", Actions: ice.Actions{ mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { _video_show(m, path.Join(arg[2], arg[1])) }}, }, Hand: func(m *ice.Message, arg ...string) { _video_show(m, arg[0], arg[1:]...) }}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ VIDEO: {Name: "video", Help: "视频", Value: kit.Data( nfs.PATH, ice.USR_LOCAL_IMAGE, nfs.TEMPLATE, ``, diff --git a/core/wiki/word.go b/core/wiki/word.go index e37a7927..c2be7a24 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -25,7 +25,7 @@ func _word_show(m *ice.Message, name string, arg ...string) { const WORD = "word" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ WORD: {Name: WORD, Help: "语言文字", Value: kit.Data( nfs.PATH, "", lex.REGEXP, ".*\\.shy", mdb.ALIAS, kit.Dict( NAVMENU, kit.List(TITLE, NAVMENU), @@ -40,8 +40,8 @@ func init() { mdb.SHORT, "type,name,text", mdb.FIELD, "time,hash,type,name,text", )}, - }, Commands: map[string]*ice.Command{ - WORD: {Name: "word path=src/main.shy@key list play", Help: "语言文字", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + WORD: {Name: "word path=src/main.shy@key list play", Help: "语言文字", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey("src/main.shy")) }}, @@ -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 map[string]string, head []string) { + m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH).Table(func(index int, value ice.Maps, head []string) { if arg[1] == "" { if value[mdb.TYPE] == SPARK { value[mdb.TEXT] = ice.Render(m, ice.RENDER_SCRIPT, value[mdb.TEXT]) @@ -63,7 +63,7 @@ func init() { }}, "recent": {Name: "recent", Help: "最近", Hand: func(m *ice.Message, arg ...string) { m.OptionFields(m.Config(mdb.FIELD)) - m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH).Table(func(index int, value map[string]string, head []string) { + m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH).Table(func(index int, value ice.Maps, head []string) { if value[mdb.TYPE] == "spark" { value[mdb.TEXT] = ice.Render(m, ice.RENDER_SCRIPT, value[mdb.TEXT]) } diff --git a/info.go b/info.go index 0172271a..0bcae156 100644 --- a/info.go +++ b/info.go @@ -39,8 +39,8 @@ var Info = struct { Help string cans string - Route map[string]string // 路由命令 - File map[string]string // 文件命令 + Route Maps // 路由命令 + File Maps // 文件命令 Pack map[string][]byte // 打包文件 names Map @@ -67,8 +67,8 @@ source: https://shylinux.com/x/icebergs `, - Route: map[string]string{}, - File: map[string]string{}, + Route: Maps{}, + File: Maps{}, Pack: map[string][]byte{}, names: Map{}, diff --git a/meta.go b/meta.go index fd44b8be..1a18ddf3 100644 --- a/meta.go +++ b/meta.go @@ -103,12 +103,19 @@ func (m *Message) Cut(fields ...string) *Message { return m } func (m *Message) Push(key string, value Any, arg ...Any) *Message { + head := kit.Simple() + if len(head) == 0 && len(arg) > 0 { + head = kit.Simple(arg[0]) + } + if len(head) == 0 { + head = kit.Simple(m.meta[MSG_APPEND]) + } + if len(head) == 0 && !m.FieldsIsDetail() { + head = kit.Split(m.OptionFields()) + } + switch value := value.(type) { case Map: - head := kit.Simple() - if len(arg) > 0 { - head = kit.Simple(arg[0]) - } if len(head) == 0 { // 键值排序 head = kit.SortedKey(kit.KeyValue(Map{}, "", value)) } @@ -148,11 +155,8 @@ func (m *Message) Push(key string, value Any, arg ...Any) *Message { } } - case map[string]string: - head := kit.Simple() - if len(arg) > 0 { - head = kit.Simple(arg[0]) - } else { // 键值排序 + case Maps: + if len(head) == 0 { // 键值排序 head = kit.SortedKey(value) } @@ -214,20 +218,20 @@ func (m *Message) Length() (max int) { } return max } -func (m *Message) Tables(cbs ...func(value map[string]string)) *Message { - return m.Table(func(index int, value map[string]string, head []string) { +func (m *Message) Tables(cbs ...func(value Maps)) *Message { + return m.Table(func(index int, value Maps, head []string) { for _, cb := range cbs { cb(value) } }) } -func (m *Message) Table(cbs ...func(index int, value map[string]string, head []string)) *Message { +func (m *Message) Table(cbs ...func(index int, value Maps, head []string)) *Message { if len(cbs) > 0 && cbs[0] != nil { if m.FieldsIsDetail() { if m.Length() == 0 { return m } - line := map[string]string{} + line := Maps{} for i, k := range m.meta[KEY] { line[k] = kit.Select("", m.meta[VALUE], i) } @@ -237,7 +241,7 @@ func (m *Message) Table(cbs ...func(index int, value map[string]string, head []s n := m.Length() for i := 0; i < n; i++ { - line := map[string]string{} + line := Maps{} for _, k := range m.meta[MSG_APPEND] { line[k] = kit.Select("", m.meta[k], i) } @@ -265,7 +269,7 @@ func (m *Message) Table(cbs ...func(index int, value map[string]string, head []s rows := kit.Select(NL, m.Option("table.row_sep")) cols := kit.Select(SP, m.Option("table.col_sep")) compact := m.Option("table.compact") == TRUE - cb := func(value map[string]string, field []string, index int) bool { + cb := func(value Maps, field []string, index int) bool { for i, v := range field { if k := m.meta[MSG_APPEND][i]; compact { v = value[k] @@ -280,7 +284,7 @@ func (m *Message) Table(cbs ...func(index int, value map[string]string, head []s } // 输出表头 - row, wor := map[string]string{}, []string{} + row, wor := Maps{}, []string{} for _, k := range m.meta[MSG_APPEND] { row[k], wor = k, append(wor, k+strings.Repeat(space, width[k]-kit.Width(k, len(space)))) } @@ -290,7 +294,7 @@ func (m *Message) Table(cbs ...func(index int, value map[string]string, head []s // 输出数据 for i := 0; i < depth; i++ { - row, wor := map[string]string{}, []string{} + row, wor := Maps{}, []string{} for _, k := range m.meta[MSG_APPEND] { data := "" if i < len(m.meta[k]) { @@ -326,8 +330,8 @@ func (m *Message) Sort(key string, arg ...string) *Message { // 排序因子 number := map[int]int64{} - table := []map[string]string{} - m.Table(func(index int, line map[string]string, head []string) { + table := []Maps{} + m.Table(func(index int, line Maps, head []string) { switch table = append(table, line); cmp { case "int": number[index] = kit.Int64(line[key]) diff --git a/misc.go b/misc.go index f22b47ba..49a57666 100644 --- a/misc.go +++ b/misc.go @@ -163,7 +163,7 @@ func (m *Message) Design(action Any, help string, input ...Any) { } } k := kit.Format(action) - if a, ok := m._cmd.Action[k]; ok { + if a, ok := m._cmd.Actions[k]; ok { m._cmd.Meta[k], a.List = list, list kit.Value(m._cmd.Meta, kit.Keys("_trans", k), help) } @@ -183,14 +183,14 @@ func (m *Message) _command(arg ...Any) *Message { for k, v := range val { opts[k] = v } - case map[string]string: + case Maps: for k, v := range val { opts[k] = v } case string: args = append(args, v) - case func(int, map[string]string, []string): + case func(int, Maps, []string): defer func() { m.Table(val) }() default: if reflect.TypeOf(val).Kind() == reflect.Func { @@ -244,14 +244,14 @@ func (c *Context) _command(m *Message, cmd *Command, key string, arg ...string) if m._key, m._cmd = key, cmd; cmd == nil { return m } - if m.Hand, m.meta[MSG_DETAIL] = true, kit.Simple(key, arg); cmd.Action != nil { + if m.Hand, m.meta[MSG_DETAIL] = true, kit.Simple(key, arg); cmd.Actions != nil { if len(arg) > 1 && arg[0] == ACTION { - if h, ok := cmd.Action[arg[1]]; ok { + if h, ok := cmd.Actions[arg[1]]; ok { return c._action(m, cmd, key, arg[1], h, arg[2:]...) } } if len(arg) > 0 && arg[0] != COMMAND { - if h, ok := cmd.Action[arg[0]]; ok { + if h, ok := cmd.Actions[arg[0]]; ok { return c._action(m, cmd, key, arg[0], h, arg[1:]...) } } @@ -262,8 +262,8 @@ func (c *Context) _command(m *Message, cmd *Command, key string, arg ...string) if cmd.Hand != nil { cmd.Hand(m, arg...) - } else if cmd.Action != nil && cmd.Action["select"] != nil { - cmd.Action["select"].Hand(m, arg...) + } else if cmd.Actions != nil && cmd.Actions["select"] != nil { + cmd.Actions["select"].Hand(m, arg...) } return m } @@ -399,7 +399,7 @@ func MergeAction(list ...Any) map[string]*Action { case string: base[CTX_INIT] = &Action{Hand: func(m *Message, arg ...string) { m.Search(from, func(p *Context, s *Context, key string, cmd *Command) { - MergeAction(base, cmd.Action) + MergeAction(base, cmd.Actions) m.target.Merge(m.target) }) }} diff --git a/misc/alpha/alpha.go b/misc/alpha/alpha.go index b1377677..86fb1b80 100644 --- a/misc/alpha/alpha.go +++ b/misc/alpha/alpha.go @@ -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 map[string]string, head []string) { + msg.CSV(msg.Result(), kit.Split(m.Config(mdb.FIELD))...).Table(func(index int, value ice.Maps, head []string) { if m.FieldsIsDetail() { m.Push(mdb.DETAIL, value, kit.Split(m.Config(mdb.FIELD))) m.Push(mdb.TIME, m.Time()) diff --git a/misc/bash/bash.go b/misc/bash/bash.go index e23de53a..2b55d35f 100644 --- a/misc/bash/bash.go +++ b/misc/bash/bash.go @@ -11,12 +11,12 @@ import ( const BASH = "bash" -var Index = &ice.Context{Name: BASH, Help: "命令行", Configs: map[string]*ice.Config{ +var Index = &ice.Context{Name: BASH, Help: "命令行", Configs: ice.Configs{ BASH: {Name: BASH, Help: "命令行", Value: kit.Data( nfs.SOURCE, "http://mirrors.tencent.com/macports/distfiles/bash/5.1_1/bash-5.1.tar.gz", )}, -}, Commands: map[string]*ice.Command{ - BASH: {Name: "bash path auto order build download", Help: "命令行", Action: ice.MergeAction(map[string]*ice.Action{ +}, Commands: ice.Commands{ + BASH: {Name: "bash path auto order build download", Help: "命令行", Actions: ice.MergeAction(ice.Actions{ cli.ORDER: {Name: "order", Help: "加载", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, cli.ORDER, m.Config(nfs.SOURCE), "_install/bin") }}, diff --git a/misc/bash/configs.go b/misc/bash/configs.go index be8c146f..79199f21 100644 --- a/misc/bash/configs.go +++ b/misc/bash/configs.go @@ -8,9 +8,9 @@ import ( ) func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + 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 map[string]string, head []string) { + m.Cmd("web.code.git.configs").Table(func(index int, value ice.Maps, head []string) { if strings.HasPrefix(value[mdb.NAME], "url") { m.Echo(`git config --global "%s" "%s"`, value[mdb.NAME], value[mdb.VALUE]) m.Echo(ice.NL) diff --git a/misc/bash/download.go b/misc/bash/download.go index caeb371b..8458d7d8 100644 --- a/misc/bash/download.go +++ b/misc/bash/download.go @@ -10,7 +10,7 @@ import ( ) func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ "/download": {Name: "/download", Help: "下载", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[0] == "" { m.Cmdy(chat.FILES).Table() diff --git a/misc/bash/favor.go b/misc/bash/favor.go index f75230dc..25941182 100644 --- a/misc/bash/favor.go +++ b/misc/bash/favor.go @@ -10,15 +10,15 @@ import ( const FAVOR = "favor" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data( mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,pwd,username,hostname", )}, - }, Commands: map[string]*ice.Command{ - "/favor": {Name: "/favor", Help: "收藏", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + "/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 map[string]string, head []string) { + m.Cmdy(FAVOR, m.Option(mdb.ZONE)).Table(func(index int, value ice.Maps, head []string) { 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]) } @@ -27,7 +27,7 @@ func init() { }, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(FAVOR).Table() }}, - FAVOR: {Name: "favor zone id auto", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{ + FAVOR: {Name: "favor zone id auto", Help: "收藏夹", Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert zone=系统命令 type=shell name=1 text=pwd pwd=/home", Help: "添加"}, cli.SYSTEM: {Name: "system", Help: "命令", Hand: func(m *ice.Message, arg ...string) { m.Option(cli.CMD_DIR, m.Option(cli.PWD)) diff --git a/misc/bash/grant.go b/misc/bash/grant.go index 74b02fdd..7977ee96 100644 --- a/misc/bash/grant.go +++ b/misc/bash/grant.go @@ -8,8 +8,8 @@ import ( const GRANT = "grant" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - "grant": {Name: "grant hash auto", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + "grant": {Name: "grant hash auto", Help: "授权", Actions: ice.MergeAction(ice.Actions{ "confirm": {Name: "confirm", Help: "同意", Hand: func(m *ice.Message, arg ...string) { m.Cmd(SESS, mdb.MODIFY, GRANT, m.Option(ice.MSG_USERNAME), ice.Option{mdb.HASH, m.Option("hash")}) }}, @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { if value["grant"] == "" { m.PushButton("confirm", mdb.REMOVE) } else { diff --git a/misc/bash/input.go b/misc/bash/input.go index 2b2137ce..d377325b 100644 --- a/misc/bash/input.go +++ b/misc/bash/input.go @@ -9,13 +9,13 @@ import ( ) func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ "/input": {Name: "/input", Help: "补全", Hand: func(m *ice.Message, arg ...string) { list := kit.Split(m.Option("line"), m.Option("break")) word := list[kit.Int(m.Option("index"))] switch arg[0] { case "shy": - m.Cmd("web.code.input.find", word).Table(func(index int, value map[string]string, head []string) { + m.Cmd("web.code.input.find", word).Table(func(index int, value ice.Maps, head []string) { m.Echo(value["text"]).Echo(" ") }) diff --git a/misc/bash/run.go b/misc/bash/run.go index 1110acff..04c0d793 100644 --- a/misc/bash/run.go +++ b/misc/bash/run.go @@ -70,8 +70,8 @@ ish_sys_dev_run_action() { const RUN = "run" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - "/run/": {Name: "/run/", Help: "执行", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + "/run/": {Name: "/run/", Help: "执行", Actions: ice.MergeAction(ice.Actions{ ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { m.Search(arg[0], func(_ *ice.Context, s *ice.Context, key string, cmd *ice.Command) { if p := strings.ReplaceAll(kit.Select("/app/cat.sh", cmd.Meta["display"]), ".js", ".sh"); strings.HasPrefix(p, ice.PS+ice.REQUIRE) { diff --git a/misc/bash/sess.go b/misc/bash/sess.go index d91c2a35..820b1708 100644 --- a/misc/bash/sess.go +++ b/misc/bash/sess.go @@ -21,11 +21,11 @@ const ( const SESS = "sess" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SESS: {Name: SESS, Help: "会话流", Value: kit.Data( mdb.FIELD, "time,hash,status,username,hostname,pid,pwd,grant", )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) { if f, _, e := m.R.FormFile(SUB); e == nil { defer f.Close() @@ -55,7 +55,7 @@ func init() { "/qrcode": {Name: "/qrcode", Help: "二维码", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(cli.QRCODE, m.Option(mdb.TEXT), m.Option(cli.FG), m.Option(cli.BG)) }}, - "/sess": {Name: "/sess", Help: "会话", Action: map[string]*ice.Action{ + "/sess": {Name: "/sess", Help: "会话", Actions: ice.Actions{ aaa.LOGOUT: {Name: "logout", Help: "退出", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SESS, mdb.MODIFY, mdb.STATUS, aaa.LOGOUT, ice.Option{mdb.HASH, m.Option(SID)}) }}, @@ -67,7 +67,7 @@ func init() { } m.Echo(m.Option(SID)) }}, - SESS: {Name: "sess hash auto prunes", Help: "会话流", Action: ice.MergeAction(map[string]*ice.Action{ + SESS: {Name: "sess hash auto prunes", Help: "会话流", Actions: ice.MergeAction(ice.Actions{ mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) { m.OptionFields(m.Config(mdb.FIELD)) m.Cmdy(mdb.PRUNES, m.PrefixKey(), "", mdb.HASH, mdb.STATUS, aaa.LOGOUT) diff --git a/misc/bash/sync.go b/misc/bash/sync.go index fac4c810..91bacd81 100644 --- a/misc/bash/sync.go +++ b/misc/bash/sync.go @@ -14,12 +14,12 @@ import ( const SYNC = "sync" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SYNC: {Name: SYNC, Help: "同步流", Value: kit.Data( mdb.FIELD, "time,id,type,name,text,pwd,username,hostname", )}, - }, Commands: map[string]*ice.Command{ - "/sync": {Name: "/sync", Help: "同步", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + "/sync": {Name: "/sync", Help: "同步", Actions: ice.Actions{ "history": {Name: "history", Help: "历史", Hand: func(m *ice.Message, arg ...string) { ls := strings.SplitN(strings.TrimSpace(m.Option(ARG)), ice.SP, 4) if text := strings.TrimSpace(strings.Join(ls[3:], ice.SP)); text != "" { @@ -29,7 +29,7 @@ func init() { } }}, }}, - SYNC: {Name: "sync id auto page export import", Help: "同步流", Action: ice.MergeAction(map[string]*ice.Action{ + SYNC: {Name: "sync id auto page export import", Help: "同步流", Actions: ice.MergeAction(ice.Actions{ cli.SYSTEM: {Name: "system", Help: "命令", Hand: func(m *ice.Message, arg ...string) { m.Option(cli.CMD_DIR, m.Option(cli.PWD)) m.ProcessCommand(cli.SYSTEM, kit.Split(m.Option(mdb.TEXT)), arg...) diff --git a/misc/bash/trash.go b/misc/bash/trash.go index e065969e..5ffcf81f 100644 --- a/misc/bash/trash.go +++ b/misc/bash/trash.go @@ -19,17 +19,17 @@ const ( const TRASH = "trash" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TRASH: {Name: TRASH, Help: "回收站", Value: kit.Data( mdb.FIELD, "time,hash,username,hostname,size,from,to", )}, - }, Commands: map[string]*ice.Command{ - "/trash": {Name: "/trash", Help: "回收", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + "/trash": {Name: "/trash", Help: "回收", Actions: ice.Actions{ mdb.INSERT: {Name: "insert from to", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TRASH, mdb.INSERT, arg) }}, }}, - TRASH: {Name: "TRASH hash path auto prunes", Help: "回收站", Action: ice.MergeAction(map[string]*ice.Action{ + TRASH: {Name: "TRASH hash path auto prunes", Help: "回收站", Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert from to", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(aaa.USERNAME, tcp.HOSTNAME, nfs.SIZE, FROM, TO)) }}, @@ -42,7 +42,7 @@ func init() { m.Cmdy(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(mdb.HASH)) }}, mdb.PRUNES: {Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) { - mdb.HashPrunes(m, func(value map[string]string) bool { + mdb.HashPrunes(m, func(value ice.Maps) bool { os.RemoveAll(value[TO]) return false }) diff --git a/misc/bash/zsh.go b/misc/bash/zsh.go index 7183f959..f42967b1 100644 --- a/misc/bash/zsh.go +++ b/misc/bash/zsh.go @@ -11,12 +11,12 @@ import ( const ZSH = "zsh" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ZSH: {Name: ZSH, Help: "命令行", Value: kit.Data( nfs.SOURCE, "https://nchc.dl.sourceforge.net/project/zsh/zsh/5.8/zsh-5.8.tar.xz", )}, - }, Commands: map[string]*ice.Command{ - ZSH: {Name: "zsh path auto order build download", Help: "命令行", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + ZSH: {Name: "zsh path auto order build download", Help: "命令行", Actions: ice.MergeAction(ice.Actions{ cli.ORDER: {Name: "order", Help: "加载", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, cli.ORDER, m.Config(nfs.SOURCE), "_install/bin") }}, diff --git a/misc/chrome/change.go b/misc/chrome/change.go index 6f4947f6..797f08ff 100644 --- a/misc/chrome/change.go +++ b/misc/chrome/change.go @@ -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 map[string]string, head []string) { + c.send(m.Spawn(), kit.Slice(arg, 0, 2), m.CommandKey(), kit.Slice(arg, 2)).Table(func(index int, value ice.Maps, head []string) { m.Push(mdb.TEXT, kit.ReplaceAll(value[mdb.TEXT], "<", "<", ">", ">")) }) if len(arg) > 3 { diff --git a/misc/chrome/field.go b/misc/chrome/field.go index 88d153c0..eaf838fa 100644 --- a/misc/chrome/field.go +++ b/misc/chrome/field.go @@ -23,7 +23,7 @@ func (f field) Inputs(m *ice.Message, arg ...string) { } func (f field) Command(m *ice.Message, arg ...string) { m.OptionFields("") - f.Zone.List(m.Spawn(), kit.Simple(m.Option(tcp.HOST), arg)...).Table(func(index int, value map[string]string, head []string) { + f.Zone.List(m.Spawn(), kit.Simple(m.Option(tcp.HOST), arg)...).Table(func(index int, value ice.Maps, head []string) { if len(arg) == 0 { // 命令列表 m.Option(ice.MSG_OPTS, head) for k, v := range value { @@ -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 map[string]string, head []string) { + f.Zone.List(m.Spawn(), m.Option(tcp.HOST), arg[0]).Table(func(index int, value ice.Maps, head []string) { m.Cmdy(value[mdb.INDEX], arg[1:]) }) } diff --git a/misc/chrome/operate.go b/misc/chrome/operate.go index 5eb401fe..5bfcb8ba 100644 --- a/misc/chrome/operate.go +++ b/misc/chrome/operate.go @@ -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 map[string]string, head []string) { - o.send(m.Spawn(), value[WID]).Table(func(index int, value map[string]string, head []string) { + 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) { 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 map[string]string, head []string) { + o.send(m, arg[:2], "spide").Table(func(index int, value ice.Maps, head []string) { switch value[mdb.TYPE] { case wiki.VIDEO: m.PushVideos(mdb.SHOW, value[mdb.LINK]) diff --git a/misc/chrome/style.go b/misc/chrome/style.go index b5ecdb2e..64d1f6ca 100644 --- a/misc/chrome/style.go +++ b/misc/chrome/style.go @@ -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 map[string]string, head []string) { + s.Zone.List(m, m.Option(tcp.HOST)).Table(func(index int, value ice.Maps, head []string) { s.send(m, "1", m.Option(TID), m.CommandKey(), value[SELECTOR], value[PROPERTY]) }) } diff --git a/misc/coder/server.go b/misc/coder/server.go index 4d265bc7..1924f81a 100644 --- a/misc/coder/server.go +++ b/misc/coder/server.go @@ -25,7 +25,7 @@ type server struct { func (s server) Search(m *ice.Message, arg ...string) { if arg[0] == mdb.FOREACH && arg[1] == "" { - s.List(m.Spawn(kit.Dict(ice.MSG_FIELDS, "time,port,status,pid,cmd,dir"))).Tables(func(value map[string]string) { + s.List(m.Spawn(kit.Dict(ice.MSG_FIELDS, "time,port,status,pid,cmd,dir"))).Tables(func(value ice.Maps) { m.PushSearch(mdb.TYPE, value[cli.STATUS], mdb.NAME, value[nfs.PATH], mdb.TEXT, value[mdb.LINK]) }) } @@ -42,7 +42,7 @@ password: %s } func (s server) List(m *ice.Message, arg ...string) *ice.Message { if s.Code.List(m, "", arg...); len(arg) == 0 { - m.Tables(func(value map[string]string) { + m.Tables(func(value ice.Maps) { switch value[cli.STATUS] { case cli.START: m.PushButton(s.Open, s.Stop) diff --git a/misc/git/configs.go b/misc/git/configs.go index 8a2633e8..98e3a649 100644 --- a/misc/git/configs.go +++ b/misc/git/configs.go @@ -25,7 +25,7 @@ func _configs_list(m *ice.Message) { } m.Sort(mdb.NAME) - mdb.HashSelect(m.Spawn(ice.OptionFields("name,value"))).Table(func(index int, value map[string]string, head []string) { + mdb.HashSelect(m.Spawn(ice.OptionFields("name,value"))).Table(func(index int, value ice.Maps, head []string) { m.Push("", value, head).PushButton(mdb.CREATE) }) } @@ -33,7 +33,7 @@ func _configs_list(m *ice.Message) { const CONFIGS = "configs" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ CONFIGS: {Name: CONFIGS, Help: "配置键", Value: kit.Data( mdb.SHORT, mdb.NAME, ice.INIT, kit.Dict( "alias", kit.Dict("s", "status", "b", "branch", "l", "log --oneline --decorate"), @@ -42,8 +42,8 @@ func init() { "push", kit.Dict("default", "simple"), "color", kit.Dict("ui", "always"), ))}, - }, Commands: map[string]*ice.Command{ - CONFIGS: {Name: "configs name auto create import", Help: "配置键", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + CONFIGS: {Name: "configs name auto create import", Help: "配置键", Actions: ice.Actions{ mdb.IMPORT: {Name: "import", Help: "初始化", Hand: func(m *ice.Message, arg ...string) { kit.Fetch(m.Configv(ice.INIT), func(conf string, value ice.Any) { kit.Fetch(value, func(key string, value string) { _configs_set(m, kit.Keys(conf, key), value) }) diff --git a/misc/git/count.go b/misc/git/count.go index e02d8317..2b1b0a6b 100644 --- a/misc/git/count.go +++ b/misc/git/count.go @@ -13,8 +13,8 @@ import ( const COUNT = "count" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - COUNT: {Name: "count path auto count", Help: "代码行", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + COUNT: {Name: "count path auto count", Help: "代码行", Actions: ice.Actions{ COUNT: {Name: "count", Help: "计数", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[0] == "usr/" { m.Echo("to many file, please choice sub dir") diff --git a/misc/git/git.go b/misc/git/git.go index ca460d4f..713ca891 100644 --- a/misc/git/git.go +++ b/misc/git/git.go @@ -11,12 +11,12 @@ import ( const GIT = "git" -var Index = &ice.Context{Name: GIT, Help: "代码库", Configs: map[string]*ice.Config{ +var Index = &ice.Context{Name: GIT, Help: "代码库", Configs: ice.Configs{ GIT: {Name: GIT, Help: "代码库", Value: kit.Data( nfs.SOURCE, "http://mirrors.tencent.com/macports/distfiles/git-cinnabar/git-2.31.1.tar.gz", )}, -}, Commands: map[string]*ice.Command{ - GIT: {Name: "git path auto install order build download", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{ +}, Commands: ice.Commands{ + GIT: {Name: "git path auto install order build download", Help: "代码库", Actions: ice.MergeAction(ice.Actions{ code.INSTALL: {Name: "install", Help: "安装", Hand: func(m *ice.Message, arg ...string) { cli.PushStream(m) defer m.ProcessInner() diff --git a/misc/git/repos.go b/misc/git/repos.go index 0f535964..b51efd62 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -45,17 +45,17 @@ const ( const REPOS = "repos" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ REPOS: {Name: REPOS, Help: "代码库", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,branch,commit,remote", REPOS, "https://shylinux.com/x", nfs.PATH, ice.USR_LOCAL, )}, - }, Commands: map[string]*ice.Command{ - REPOS: {Name: "repos repos path auto create", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + REPOS: {Name: "repos repos path auto create", Help: "代码库", Actions: ice.MergeAction(ice.Actions{ 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 map[string]string, head []string) { + m.Cmd(nfs.DIR, ice.USR, "name,path").Table(func(index int, value ice.Maps, head []string) { _repos_insert(m, value[mdb.NAME], value[nfs.PATH]) }) cli.IsAlpine(m, "git", "apk add git") diff --git a/misc/git/server.go b/misc/git/server.go index 2de60e24..df0f0260 100644 --- a/misc/git/server.go +++ b/misc/git/server.go @@ -113,11 +113,11 @@ func _server_repos(m *ice.Message, arg ...string) error { const SERVER = "server" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) { m.Render(ice.RENDER_VOID) }}, - "/repos/": {Name: "/repos/", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{ + "/repos/": {Name: "/repos/", Help: "代码库", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { web.AddRewrite(func(p string, w http.ResponseWriter, r *http.Request) bool { if strings.HasPrefix(p, "/chat/pod/") { @@ -176,13 +176,13 @@ func init() { web.RenderStatus(m, 500, err.Error()) } }}, - SERVER: {Name: "server path auto create import", Help: "服务器", Action: map[string]*ice.Action{ + SERVER: {Name: "server path auto create import", Help: "服务器", Actions: ice.Actions{ mdb.CREATE: {Name: "create name", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Option(cli.CMD_DIR, path.Join(ice.USR_LOCAL, REPOS)) 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 map[string]string, head []string) { + m.Cmdy(REPOS, ice.OptionFields("time,name,path")).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + m.Cmdy(nfs.DIR, nfs.PWD).Table(func(index int, value ice.Maps, head []string) { m.PushScript("git clone " + m.MergeLink("/x/"+strings.TrimSuffix(value[nfs.PATH], ice.PS))) }) m.Cut("time,path,size,script,action") diff --git a/misc/git/spide.go b/misc/git/spide.go index e449ea6d..af6575a6 100644 --- a/misc/git/spide.go +++ b/misc/git/spide.go @@ -60,8 +60,8 @@ func _spide_c(m *ice.Message, file string) { const SPIDE = "spide" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - SPIDE: {Name: "spide repos auto", Help: "构架图", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + SPIDE: {Name: "spide repos auto", Help: "构架图", Actions: ice.MergeAction(ice.Actions{ code.INNER: {Name: "web.code.inner"}, "depend": {Name: "depend path=icebergs/base", Help: "依赖", Hand: func(m *ice.Message, arg ...string) { keys := map[string]bool{} @@ -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 map[string]string, head []string) { + nfs.Dir(m, nfs.PATH).Table(func(index int, value ice.Maps, head []string) { m.Push(cli.COLOR, color[strings.Count(value[nfs.PATH], ice.PS)%len(color)]) }) return diff --git a/misc/git/status.go b/misc/git/status.go index 1642871d..07702202 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -26,8 +26,8 @@ func _status_tag(m *ice.Message, tags string) string { return "v0.0.1" } func _status_tags(m *ice.Message, repos string) { - vs := map[string]string{} - m.Cmd(STATUS).Table(func(index int, value map[string]string, head []string) { + vs := ice.Maps{} + m.Cmd(STATUS).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value ice.Maps, head []string) { m.Option(cli.CMD_DIR, value[nfs.PATH]) diff := m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb") tags := m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags") @@ -199,8 +199,8 @@ const ( const STATUS = "status" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - STATUS: {Name: "status repos auto", Help: "状态机", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + STATUS: {Name: "status repos auto", Help: "状态机", Actions: ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case mdb.NAME, REPOS: diff --git a/misc/git/total.go b/misc/git/total.go index 3487226a..f3641997 100644 --- a/misc/git/total.go +++ b/misc/git/total.go @@ -17,7 +17,7 @@ import ( const TOTAL = "total" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TOTAL: {Name: TOTAL, Help: "统计量", Value: kit.Data( "skip", kit.Dict( "wubi-dict", ice.TRUE, "word-dict", ice.TRUE, @@ -25,11 +25,11 @@ func init() { "echarts", ice.TRUE, "go-qrcode", ice.TRUE, ), )}, - }, Commands: map[string]*ice.Command{ - TOTAL: {Name: "total repos auto pie", Help: "统计量", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + 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 map[string]string, head []string) { + m.Cmd(TOTAL).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + msg.Table(func(index int, value ice.Maps, head []string) { if kit.Int(value["days"]) > days { days = kit.Int(value["days"]) } diff --git a/misc/git/trend.go b/misc/git/trend.go index d7c7e574..fbb09fd0 100644 --- a/misc/git/trend.go +++ b/misc/git/trend.go @@ -11,10 +11,10 @@ import ( const TREND = "trend" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Meta: kit.Dict( ice.DisplayStory("trend.js"), - ), Action: ice.MergeAction(map[string]*ice.Action{ + ), Actions: ice.MergeAction(ice.Actions{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("name,time")) }}, code.INNER: {Name: "web.code.inner"}, diff --git a/misc/input/wubi.go b/misc/input/wubi.go index 6123bbb2..338fccca 100644 --- a/misc/input/wubi.go +++ b/misc/input/wubi.go @@ -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 map[string]string, head []string) { + m.Cmd(w, "word", arg[0]).Table(func(index int, value ice.Maps, head []string) { m.Echo(value[mdb.TEXT] + ice.NL) }) } diff --git a/misc/java/spring.go b/misc/java/spring.go index 6f0c7996..0346a48f 100644 --- a/misc/java/spring.go +++ b/misc/java/spring.go @@ -45,7 +45,7 @@ func (s spring) List(m *ice.Message, arg ...string) { s.Hash.List(m, arg...).PushAction(s.Start, s.Build) } else { // 服务列表 - m.Cmd(cli.DAEMON).Table(func(index int, value map[string]string, head []string) { + m.Cmd(cli.DAEMON).Table(func(index int, value ice.Maps, head []string) { if strings.Contains(value[ice.CMD], "target/"+arg[0]+"-0.0.1-SNAPSHOT.jar") { m.PushRecord(value, head...) } diff --git a/misc/lark/app.go b/misc/lark/app.go index 5e667efb..69d65f57 100644 --- a/misc/lark/app.go +++ b/misc/lark/app.go @@ -20,13 +20,13 @@ const ( const APP = "app" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ APP: {Name: APP, Help: "应用", Value: kit.Data( mdb.SHORT, APPID, mdb.FIELD, "time,appid,duty,token,expire", tcp.SERVER, "https://open.feishu.cn/", )}, - }, Commands: map[string]*ice.Command{ - APP: {Name: "app appid auto token login", Help: "应用", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + APP: {Name: "app appid auto token login", Help: "应用", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(web.SPIDE, mdb.CREATE, LARK, m.Config(tcp.SERVER)) }}, diff --git a/misc/lark/company.go b/misc/lark/company.go index 3c5e182a..889b4eb6 100644 --- a/misc/lark/company.go +++ b/misc/lark/company.go @@ -39,7 +39,7 @@ func _company_members(m *ice.Message, appid string, ship_id string) { const COMPANY = "company" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ COMPANY: {Name: "company appid ship_id open_id text auto", Help: "组织", Hand: func(m *ice.Message, arg ...string) { switch len(arg) { case 0: // 应用列表 diff --git a/misc/lark/duty.go b/misc/lark/duty.go index 70e75edf..8d470bd1 100644 --- a/misc/lark/duty.go +++ b/misc/lark/duty.go @@ -7,7 +7,7 @@ import ( const DUTY = "duty" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ DUTY: {Name: "duty [title] text run", Help: "通告", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(APP, m.Option(APP_ID)) m.Cmdy(SEND, msg.Append(APPID), msg.Append(DUTY), arg) diff --git a/misc/lark/employee.go b/misc/lark/employee.go index e9c08083..c37cdd75 100644 --- a/misc/lark/employee.go +++ b/misc/lark/employee.go @@ -31,7 +31,7 @@ func _employee_openid(m *ice.Message, appid string, arg ...string) { const EMPLOYEE = "employee" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ EMPLOYEE: {Name: "employee appid open_id|mobile|email auto", Help: "员工", Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 { return diff --git a/misc/lark/event.go b/misc/lark/event.go index 4008298d..a1eed238 100644 --- a/misc/lark/event.go +++ b/misc/lark/event.go @@ -17,8 +17,8 @@ const ( const EVENT = "event" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - EVENT: {Name: "event", Help: "事件", Action: map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + EVENT: {Name: "event", Help: "事件", Actions: ice.Actions{ P2P_CHAT_CREATE: {Name: "", Help: "", Hand: func(m *ice.Message, arg ...string) { if m.Option(OPEN_CHAT_ID) != "" { m.Cmdy(SEND, m.Option(APP_ID), m.Option(OPEN_CHAT_ID), m.Conf(APP, kit.Keym(nfs.TEMPLATE, m.Option(mdb.TYPE)))) diff --git a/misc/lark/form.go b/misc/lark/form.go index f9dbcdfb..de3fed70 100644 --- a/misc/lark/form.go +++ b/misc/lark/form.go @@ -10,7 +10,7 @@ import ( const FORM = "form" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ FORM: {Name: "form [chat_id|open_id|user_id|email] target title text [confirm|value|url arg...]...", Help: "消息", Hand: func(m *ice.Message, arg ...string) { var form = kit.Dict() switch arg[0] { diff --git a/misc/lark/group.go b/misc/lark/group.go index 487be888..c3f232d1 100644 --- a/misc/lark/group.go +++ b/misc/lark/group.go @@ -34,7 +34,7 @@ func _group_members(m *ice.Message, appid string, chat_id string) { const GROUP = "group" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ GROUP: {Name: "group appid chat_id open_id text auto", Help: "群组", Hand: func(m *ice.Message, arg ...string) { switch len(arg) { case 0: // 应用列表 diff --git a/misc/lark/home.go b/misc/lark/home.go index 8b200a2d..b9aca14e 100644 --- a/misc/lark/home.go +++ b/misc/lark/home.go @@ -11,7 +11,7 @@ import ( const HOME = "home" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ HOME: {Name: "home river storm title content", Help: "首页", Hand: func(m *ice.Message, arg ...string) { name := kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK)) if len(name) > 10 { @@ -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 map[string]string, head []string) { - m.Cmd("web.chat./river", val[mdb.HASH], chat.STORM).Table(func(index int, value map[string]string, head []string) { + 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) { 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 map[string]string, head []string) { + m.Cmd("web.chat./river", arg[0], chat.STORM, arg[1]).Table(func(index int, value ice.Maps, head []string) { list = append(list, value[ice.CMD], ice.CMD, kit.Keys(value[ice.CTX], value[ice.CMD])) }) } diff --git a/misc/lark/msg.go b/misc/lark/msg.go index be44203e..0ec92e34 100644 --- a/misc/lark/msg.go +++ b/misc/lark/msg.go @@ -59,7 +59,7 @@ const ( const MSG = "msg" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) { m.Option(ice.MSG_USERZONE, LARK) }}, @@ -81,7 +81,7 @@ func init() { m.Cmd(DUTY, m.Option("msg.type"), kit.Formats(data)) } }}, - MSG: {Name: "msg", Help: "聊天消息", Action: map[string]*ice.Action{ + MSG: {Name: "msg", Help: "聊天消息", Actions: ice.Actions{ "location": {Name: "", Help: "", Hand: func(m *ice.Message, arg ...string) { }}, "image": {Name: "", Help: "", Hand: func(m *ice.Message, arg ...string) { diff --git a/misc/lark/rand.go b/misc/lark/rand.go index 43fa5878..bd87f0da 100644 --- a/misc/lark/rand.go +++ b/misc/lark/rand.go @@ -11,7 +11,7 @@ import ( const RAND = "rand" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ RAND: {Name: "rand", Help: "随机", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(GROUP, m.Option(APP_ID), EMPLOYEE, m.Option(OPEN_CHAT_ID)) list := msg.Appendv(mdb.NAME) diff --git a/misc/lark/send.go b/misc/lark/send.go index cfe436f8..e8401e44 100644 --- a/misc/lark/send.go +++ b/misc/lark/send.go @@ -48,7 +48,7 @@ const ( const SEND = "send" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ SEND: {Name: "send appid [chat_id|open_id|user_id|email] target [title] text", Help: "消息", Hand: func(m *ice.Message, arg ...string) { form := kit.Dict(CONTENT, kit.Dict()) appid, arg := arg[0], arg[1:] diff --git a/misc/lark/sso.go b/misc/lark/sso.go index aa0f8461..17730f44 100644 --- a/misc/lark/sso.go +++ b/misc/lark/sso.go @@ -12,7 +12,7 @@ import ( const SSO = "sso" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ "/sso": {Name: "/sso", Help: "网页", Hand: func(m *ice.Message, arg ...string) { if m.Option(ice.MSG_USERNAME) != "" { // 默认主页 m.RenderIndex(web.SERVE, ice.VOLCANOS) diff --git a/misc/lark/talk.go b/misc/lark/talk.go index d34aae40..e07177b6 100644 --- a/misc/lark/talk.go +++ b/misc/lark/talk.go @@ -13,7 +13,7 @@ import ( const TALK = "talk" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + Index.Merge(&ice.Context{Commands: ice.Commands{ TALK: {Name: "talk text", Help: "聊天", Hand: func(m *ice.Message, arg ...string) { cmds := kit.Split(strings.Join(arg, " ")) if aaa.UserLogin(m, m.Option(OPEN_ID), ""); !m.Right(cmds) { @@ -37,7 +37,7 @@ func init() { } val := []string{} - m.Table(func(index int, value map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { for _, key := range head { val = append(val, kit.Format("%s:\t%s", key, value[key])) } diff --git a/misc/mp/login.go b/misc/mp/login.go index 274383a0..c82d83ab 100644 --- a/misc/mp/login.go +++ b/misc/mp/login.go @@ -30,12 +30,12 @@ const ( const LOGIN = "login" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ LOGIN: {Name: LOGIN, Help: "认证", Value: kit.Data( tcp.SERVER, "https://api.weixin.qq.com", )}, - }, Commands: map[string]*ice.Command{ - "/login/": {Name: "/login/", Help: "认证", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + "/login/": {Name: "/login/", Help: "认证", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(web.SPIDE, mdb.CREATE, MP, m.Config(tcp.SERVER)) }}, @@ -63,7 +63,7 @@ func init() { m.Cmdy(chat.SCAN, arg) }}, }}, - LOGIN: {Name: "login appid auto qrcode tokens create", Help: "认证", Action: map[string]*ice.Action{ + LOGIN: {Name: "login appid auto qrcode tokens create", Help: "认证", Actions: ice.Actions{ mdb.CREATE: {Name: "create appid appmm", Help: "登录", Hand: func(m *ice.Message, arg ...string) { m.Config(APPID, m.Option(APPID)) m.Config(APPMM, m.Option(APPMM)) diff --git a/misc/ssh/channel.go b/misc/ssh/channel.go index 39b0ac2c..8b7cd978 100644 --- a/misc/ssh/channel.go +++ b/misc/ssh/channel.go @@ -36,7 +36,7 @@ func _ssh_close(m *ice.Message, c net.Conn, channel ssh.Channel) { defer channel.Close() channel.Write([]byte(m.Conf(SERVICE, kit.Keym(GOODBYE)))) } -func _ssh_watch(m *ice.Message, meta map[string]string, h string, input io.Reader, output io.Writer) { +func _ssh_watch(m *ice.Message, meta ice.Maps, h string, input io.Reader, output io.Writer) { r, w := io.Pipe() bio := io.TeeReader(input, w) m.Go(func() { io.Copy(output, r) }) @@ -67,12 +67,12 @@ func _ssh_watch(m *ice.Message, meta map[string]string, h string, input io.Reade const CHANNEL = "channel" func init() { - psh.Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + psh.Index.Merge(&ice.Context{Configs: ice.Configs{ CHANNEL: {Name: "channel", Help: "通道", Value: kit.Data( mdb.FIELD, "time,hash,status,username,hostport,tty,count", )}, - }, Commands: map[string]*ice.Command{ - CHANNEL: {Name: "channel hash id auto", Help: "通道", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + CHANNEL: {Name: "channel hash id auto", Help: "通道", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Richs(CHANNEL, "", mdb.FOREACH, func(key string, value ice.Map) { kit.Value(value, kit.Keym(mdb.STATUS), tcp.CLOSE) @@ -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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { m.PushButton(kit.Select("", ctx.COMMAND, value[mdb.STATUS] == tcp.OPEN), mdb.REMOVE) }) return diff --git a/misc/ssh/connect.go b/misc/ssh/connect.go index 295168f1..ac6a518e 100644 --- a/misc/ssh/connect.go +++ b/misc/ssh/connect.go @@ -155,10 +155,10 @@ const SSH = "ssh" const CONNECT = "connect" func init() { - psh.Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + psh.Index.Merge(&ice.Context{Configs: ice.Configs{ CONNECT: {Name: CONNECT, Help: "连接", Value: kit.Data(mdb.SHORT, "name", mdb.FIELD, "time,name,status,username,host,port")}, - }, Commands: map[string]*ice.Command{ - CONNECT: {Name: "connect name auto", Help: "连接", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + CONNECT: {Name: "connect name auto", Help: "连接", Actions: ice.MergeAction(ice.Actions{ tcp.OPEN: {Name: "open authfile username=shy password verfiy host=shylinux.com port=22 private=.ssh/id_rsa", Help: "终端", Hand: func(m *ice.Message, arg ...string) { aaa.UserRoot(m) _ssh_open(m.OptionLoad(m.Option("authfile")), arg...) @@ -204,7 +204,7 @@ func init() { }) }}, }, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) { - mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) { + mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) { m.PushButton(kit.Select("", "command,session", value[mdb.STATUS] == tcp.OPEN), mdb.REMOVE) }) if len(arg) == 0 { diff --git a/misc/ssh/rsa.go b/misc/ssh/rsa.go index 5edb87f6..7c2c21c4 100644 --- a/misc/ssh/rsa.go +++ b/misc/ssh/rsa.go @@ -22,10 +22,10 @@ const ( const RSA = "rsa" func init() { - aaa.Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + aaa.Index.Merge(&ice.Context{Configs: ice.Configs{ RSA: {Name: RSA, Help: "角色", Value: kit.Data(mdb.SHORT, mdb.HASH, mdb.FIELD, "time,hash,title,public,private")}, - }, Commands: map[string]*ice.Command{ - RSA: {Name: "rsa hash auto", Help: "公钥", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + RSA: {Name: "rsa hash auto", Help: "公钥", Actions: ice.MergeAction(ice.Actions{ mdb.IMPORT: {Name: "import key=.ssh/id_rsa pub=.ssh/id_rsa.pub", Help: "导入", Hand: func(m *ice.Message, arg ...string) { m.Conf(m.PrefixKey(), kit.Keys(mdb.HASH, path.Base(m.Option("key"))), kit.Data(mdb.TIME, m.Time(), "title", kit.Format("%s@%s", ice.Info.UserName, ice.Info.HostName), @@ -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 map[string]string, head []string) { + m.Cmd(m.PrefixKey(), m.Option(mdb.HASH)).Table(func(index int, value ice.Maps, head []string) { m.Cmdx(nfs.SAVE, kit.HomePath(m.Option("key")), value[PRIVATE]) m.Cmdx(nfs.SAVE, kit.HomePath(m.Option("pub")), value[PUBLIC]) }) diff --git a/misc/ssh/service.go b/misc/ssh/service.go index f7ba537e..190fc3b4 100644 --- a/misc/ssh/service.go +++ b/misc/ssh/service.go @@ -20,8 +20,8 @@ import ( kit "shylinux.com/x/toolkits" ) -func _ssh_meta(conn ssh.ConnMetadata) map[string]string { - return map[string]string{aaa.USERNAME: conn.User(), tcp.HOSTPORT: conn.RemoteAddr().String()} +func _ssh_meta(conn ssh.ConnMetadata) ice.Maps { + return ice.Maps{aaa.USERNAME: conn.User(), tcp.HOSTPORT: conn.RemoteAddr().String()} } func _ssh_config(m *ice.Message, h string) *ssh.ServerConfig { config := &ssh.ServerConfig{ @@ -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 map[string]string, head []string) { + m.Cmd(mdb.SELECT, SERVICE, kit.Keys(mdb.HASH, h), mdb.LIST).Table(func(index int, value ice.Maps, head []string) { if !strings.HasPrefix(value[mdb.NAME], conn.User()+"@") { return } @@ -98,13 +98,13 @@ const ( const SERVICE = "service" func init() { - psh.Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + psh.Index.Merge(&ice.Context{Configs: ice.Configs{ SERVICE: {Name: SERVICE, Help: "服务", Value: kit.Data( WELCOME, "\r\nwelcome to context world\r\n", GOODBYE, "\r\ngoodbye of context world\r\n", mdb.SHORT, tcp.PORT, mdb.FIELD, "time,port,status,private,authkey,count", )}, - }, Commands: map[string]*ice.Command{ - SERVICE: {Name: "service port id auto listen prunes", Help: "服务", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SERVICE: {Name: "service port id auto listen prunes", Help: "服务", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Richs(SERVICE, "", mdb.FOREACH, func(key string, value ice.Map) { if value = kit.GetMeta(value); kit.Value(value, mdb.STATUS) == tcp.OPEN { @@ -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 map[string]string, head []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) { list = append(list, fmt.Sprintf("%s %s %s", value[mdb.TYPE], value[mdb.TEXT], value[mdb.NAME])) }) diff --git a/misc/ssh/service_darwin.go b/misc/ssh/service_darwin.go index 0924f23a..0b3a6df1 100644 --- a/misc/ssh/service_darwin.go +++ b/misc/ssh/service_darwin.go @@ -29,7 +29,7 @@ func _ssh_sizes(fd uintptr, w, h int) { ws := &Winsize{Width: uint16(w), Height: uint16(h)} syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws))) } -func _ssh_handle(m *ice.Message, meta map[string]string, c net.Conn, channel ssh.Channel, requests <-chan *ssh.Request) { +func _ssh_handle(m *ice.Message, meta ice.Maps, c net.Conn, channel ssh.Channel, requests <-chan *ssh.Request) { m.Logs(CHANNEL, tcp.HOSTPORT, c.RemoteAddr(), "->", c.LocalAddr()) defer m.Logs("dischan", tcp.HOSTPORT, c.RemoteAddr(), "->", c.LocalAddr()) diff --git a/misc/ssh/service_linux.go b/misc/ssh/service_linux.go index 0924f23a..0b3a6df1 100644 --- a/misc/ssh/service_linux.go +++ b/misc/ssh/service_linux.go @@ -29,7 +29,7 @@ func _ssh_sizes(fd uintptr, w, h int) { ws := &Winsize{Width: uint16(w), Height: uint16(h)} syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws))) } -func _ssh_handle(m *ice.Message, meta map[string]string, c net.Conn, channel ssh.Channel, requests <-chan *ssh.Request) { +func _ssh_handle(m *ice.Message, meta ice.Maps, c net.Conn, channel ssh.Channel, requests <-chan *ssh.Request) { m.Logs(CHANNEL, tcp.HOSTPORT, c.RemoteAddr(), "->", c.LocalAddr()) defer m.Logs("dischan", tcp.HOSTPORT, c.RemoteAddr(), "->", c.LocalAddr()) diff --git a/misc/ssh/service_windows.go b/misc/ssh/service_windows.go index cac90bc4..296c3b63 100644 --- a/misc/ssh/service_windows.go +++ b/misc/ssh/service_windows.go @@ -3,8 +3,8 @@ package ssh import ( "net" - ice "shylinux.com/x/icebergs" "golang.org/x/crypto/ssh" + ice "shylinux.com/x/icebergs" ) type Winsize struct{ Height, Width, x, y uint16 } @@ -13,5 +13,5 @@ func _ssh_size(fd uintptr, b []byte) { } func _ssh_sizes(fd uintptr, w, h int) { } -func _ssh_handle(m *ice.Message, meta map[string]string, c net.Conn, channel ssh.Channel, requests <-chan *ssh.Request) { +func _ssh_handle(m *ice.Message, meta ice.Maps, c net.Conn, channel ssh.Channel, requests <-chan *ssh.Request) { } diff --git a/misc/ssh/session.go b/misc/ssh/session.go index 6b24081a..745bf753 100644 --- a/misc/ssh/session.go +++ b/misc/ssh/session.go @@ -58,10 +58,10 @@ const ( const SESSION = "session" func init() { - psh.Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + psh.Index.Merge(&ice.Context{Configs: ice.Configs{ SESSION: {Name: SESSION, Help: "会话", Value: kit.Data(mdb.SHORT, "name", mdb.FIELD, "time,name,status,count,connect")}, - }, Commands: map[string]*ice.Command{ - SESSION: {Name: "session name id auto", Help: "会话", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SESSION: {Name: "session name id auto", Help: "会话", Actions: ice.MergeAction(ice.Actions{ mdb.REPEAT: {Name: "repeat", Help: "执行", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SESSION, ctx.ACTION, ctx.COMMAND, CMD, m.Option(mdb.TEXT)) }}, @@ -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 map[string]string, head []string) { + mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + mdb.ZoneSelect(m, kit.Slice(arg, 0, 2)...).Table(func(index int, value ice.Maps, head []string) { m.PushButton(kit.Select("", mdb.REPEAT, value[mdb.TYPE] == CMD)) }) }}, diff --git a/misc/tmux/buffer.go b/misc/tmux/buffer.go index f2a6e1c2..74e35cfb 100644 --- a/misc/tmux/buffer.go +++ b/misc/tmux/buffer.go @@ -16,10 +16,10 @@ const ( ) func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ BUFFER: {Name: BUFFER, Help: "缓存", Value: kit.Data()}, - }, Commands: map[string]*ice.Command{ - BUFFER: {Name: "buffer name value auto export import", Help: "缓存", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + BUFFER: {Name: "buffer name value auto export import", Help: "缓存", Actions: ice.Actions{ mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case mdb.TEXT: @@ -30,7 +30,7 @@ func init() { m.Config(mdb.LIST, "") m.Config(mdb.COUNT, "0") - m.Cmd(BUFFER).Table(func(index int, value map[string]string, head []string) { + m.Cmd(BUFFER).Table(func(index int, value ice.Maps, head []string) { m.Grow(m.PrefixKey(), "", kit.Dict( mdb.NAME, value[head[0]], mdb.TEXT, m.Cmdx(cli.SYSTEM, TMUX, "show-buffer", "-b", value[head[0]]), )) @@ -68,7 +68,7 @@ func init() { } } }}, - TEXT: {Name: "text auto save text:textarea", Help: "文本", Action: map[string]*ice.Action{ + TEXT: {Name: "text auto save text:textarea", Help: "文本", Actions: ice.Actions{ nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] != "" { m.Cmd(cli.SYSTEM, TMUX, "set-buffer", arg[0]) diff --git a/misc/tmux/script.go b/misc/tmux/script.go index 452a048e..af4e955b 100644 --- a/misc/tmux/script.go +++ b/misc/tmux/script.go @@ -9,12 +9,12 @@ import ( const SCRIPT = "script" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SCRIPT: {Name: SCRIPT, Help: "脚本", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text", )}, - }, Commands: map[string]*ice.Command{ - SCRIPT: {Name: "script name auto create export import", Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + SCRIPT: {Name: "script name auto create export import", Help: "脚本", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create type=shell,tmux,vim name=hi text:textarea=pwd", Help: "添加"}, }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) diff --git a/misc/tmux/session.go b/misc/tmux/session.go index ace20833..adc311b6 100644 --- a/misc/tmux/session.go +++ b/misc/tmux/session.go @@ -37,7 +37,7 @@ const ( ) func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SESSION: {Name: SESSION, Help: "会话", Value: kit.Data( FORMAT, "#{session_id},#{session_attached},#{session_name},#{session_windows},#{session_height},#{session_width}", FIELDS, "id,tag,session,windows,height,width", @@ -50,8 +50,8 @@ func init() { FORMAT, "#{pane_id},#{pane_active},#{pane_index},#{pane_tty},#{pane_height},#{pane_width},#{pane_current_command}", FIELDS, "id,tag,pane,tty,height,width,cmd", )}, - }, Commands: map[string]*ice.Command{ - SESSION: {Name: "session session window pane cmd auto", Help: "会话管理", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + SESSION: {Name: "session session window pane cmd auto", Help: "会话管理", Actions: ice.Actions{ web.DREAM_CREATE: {Name: "dream.create type name", Help: "梦想", Hand: func(m *ice.Message, arg ...string) { if m.Cmd(m.PrefixKey(), m.Option(mdb.NAME)).Length() == 0 { m.Cmd(m.PrefixKey(), mdb.CREATE) @@ -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 map[string]string, head []string) { + m.Cmd(SCRIPT, m.Option(mdb.NAME)).Table(func(index int, value ice.Maps, head []string) { 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 map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { switch value["tag"] { case "1": m.PushButton("") diff --git a/misc/tmux/tmux.go b/misc/tmux/tmux.go index 25f5f1f4..16aa2737 100644 --- a/misc/tmux/tmux.go +++ b/misc/tmux/tmux.go @@ -11,12 +11,12 @@ import ( const TMUX = "tmux" -var Index = &ice.Context{Name: TMUX, Help: "工作台", Configs: map[string]*ice.Config{ +var Index = &ice.Context{Name: TMUX, Help: "工作台", Configs: ice.Configs{ TMUX: {Name: TMUX, Help: "工作台", Value: kit.Data( nfs.SOURCE, "http://mirrors.tencent.com/macports/distfiles/tmux/tmux-3.2.tar.gz", )}, -}, Commands: map[string]*ice.Command{ - TMUX: {Name: "tmux path auto start order build download", Help: "服务", Action: ice.MergeAction(map[string]*ice.Action{ +}, Commands: ice.Commands{ + TMUX: {Name: "tmux path auto start order build download", Help: "服务", Actions: ice.MergeAction(ice.Actions{ cli.START: {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) { m.Optionv(code.PREPARE, func(p string) []string { return []string{"-S", kit.Path(m.Option(cli.CMD_DIR, p), "tmux.socket"), "new-session", "-dn", "miss"} diff --git a/misc/vim/favor.go b/misc/vim/favor.go index 37d0e4eb..a91e55f4 100644 --- a/misc/vim/favor.go +++ b/misc/vim/favor.go @@ -14,14 +14,14 @@ import ( const FAVOR = "favor" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data( mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,file,line,pwd", )}, - }, Commands: map[string]*ice.Command{ - "/favor": {Name: "/favor", Help: "收藏", Action: map[string]*ice.Action{ + }, 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 map[string]string, head []string) { + m.Cmd(FAVOR).Table(func(index int, value ice.Maps, head []string) { m.Echo(value[mdb.ZONE]).Echo(ice.NL) }) }}, @@ -29,12 +29,12 @@ 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 map[string]string, head []string) { + m.Cmd(FAVOR, m.Option(mdb.ZONE)).Table(func(index int, value ice.Maps, head []string) { 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]) }) }}, - FAVOR: {Name: "favor zone id auto", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{ + FAVOR: {Name: "favor zone id auto", Help: "收藏夹", Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert zone=数据结构 type name=hi text=hello file line", Help: "添加"}, code.INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) { p := path.Join(m.Option(cli.PWD), m.Option(nfs.FILE)) diff --git a/misc/vim/input.go b/misc/vim/input.go index 15221597..1ad1f263 100644 --- a/misc/vim/input.go +++ b/misc/vim/input.go @@ -13,9 +13,9 @@ import ( const INPUT = "input" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ INPUT: {Name: INPUT, Help: "输入法", Value: kit.Data(mdb.FIELD, "time,id,type,name,text")}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ "/input": {Name: "/input", Help: "输入法", Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(TAGS, ctx.ACTION, INPUT, arg[0], m.Option("pre")); m.Length() > 0 { m.Cmd(m.PrefixKey(), mdb.INSERT, kit.SimpleKV("", "tags", arg[0], m.Result())) @@ -40,6 +40,6 @@ func init() { return // 本地命令 } }}, - INPUT: {Name: "input id auto export import", Help: "输入法", Action: mdb.ListAction()}, + INPUT: {Name: "input id auto export import", Help: "输入法", Actions: mdb.ListAction()}, }}) } diff --git a/misc/vim/sess.go b/misc/vim/sess.go index 13ddb505..60ed04a7 100644 --- a/misc/vim/sess.go +++ b/misc/vim/sess.go @@ -24,11 +24,11 @@ const ( const SESS = "sess" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SESS: {Name: SESS, Help: "会话流", Value: kit.Data( mdb.FIELD, "time,hash,status,username,hostname,pid,pwd", )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) { if f, _, e := m.R.FormFile(SUB); e == nil { defer f.Close() @@ -51,7 +51,7 @@ func init() { m.Option(tcp.HOSTNAME, msg.Append(tcp.HOSTNAME)) m.Warn(m.Option(aaa.USERNAME) == "", ice.ErrNotLogin, arg[0]) }}, - "/sess": {Name: "/sess", Help: "会话", Action: map[string]*ice.Action{ + "/sess": {Name: "/sess", Help: "会话", Actions: ice.Actions{ aaa.LOGOUT: {Name: "logout", Help: "退出", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SESS, mdb.MODIFY, mdb.STATUS, aaa.LOGOUT, ice.Option{mdb.HASH, m.Option(SID)}) }}, @@ -63,7 +63,7 @@ func init() { } m.Echo(m.Option(SID)) }}, - SESS: {Name: "sess hash auto prunes", Help: "会话流", Action: ice.MergeAction(map[string]*ice.Action{ + SESS: {Name: "sess hash auto prunes", Help: "会话流", Actions: ice.MergeAction(ice.Actions{ mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) { m.OptionFields(m.Config(mdb.FIELD)) m.Cmdy(mdb.PRUNES, m.PrefixKey(), "", mdb.HASH, mdb.STATUS, aaa.LOGOUT) diff --git a/misc/vim/sync.go b/misc/vim/sync.go index 50c0392c..ec215434 100644 --- a/misc/vim/sync.go +++ b/misc/vim/sync.go @@ -15,11 +15,11 @@ import ( const SYNC = "sync" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ SYNC: {Name: SYNC, Help: "同步流", Value: kit.Data( mdb.FIELD, "time,id,type,name,text,pwd,buf,row,col", )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ "/sync": {Name: "/sync", Help: "同步", Hand: func(m *ice.Message, arg ...string) { switch m.Option(ARG) { case "wq", "q", "qa": @@ -29,7 +29,7 @@ func init() { m.Cmd(SYNC, mdb.INSERT, mdb.TYPE, VIMRC, mdb.NAME, arg[0], mdb.TEXT, kit.Select(m.Option(ARG), m.Option(SUB)), m.OptionSimple(cli.PWD, BUF, ROW, COL)) }}, - SYNC: {Name: "sync id auto page export import", Help: "同步流", Action: ice.MergeAction(map[string]*ice.Action{ + SYNC: {Name: "sync id auto page export import", Help: "同步流", Actions: ice.MergeAction(ice.Actions{ code.INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) { p := path.Join(m.Option(cli.PWD), m.Option(BUF)) m.ProcessCommand(code.INNER, []string{path.Dir(p) + ice.PS, path.Base(p), m.Option(ROW)}, arg...) diff --git a/misc/vim/tags.go b/misc/vim/tags.go index 3835696b..031b95ee 100644 --- a/misc/vim/tags.go +++ b/misc/vim/tags.go @@ -26,11 +26,11 @@ func init() { func_pattern = "4\n%s\n/\\<%s: \\(shy\\|func\\)/\n" libs_pattern = "4\nusr/volcanos/lib/%s.js\n/\\<%s: \\(shy\\|func\\)/\n" ) - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TAGS: {Name: TAGS, Help: "索引", Value: kit.Data( mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line", )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ "/tags": {Name: "/tags", Help: "跳转", Hand: func(m *ice.Message, arg ...string) { switch m.Option(MODULE) { case ONIMPORT, ONACTION, ONEXPORT: @@ -38,7 +38,7 @@ func init() { case "msg", "res": m.Echo(libs_pattern, ice.MISC, m.Option(PATTERN)) default: - if mdb.ZoneSelectCB(m, m.Option(MODULE), func(value map[string]string) { + if mdb.ZoneSelectCB(m, m.Option(MODULE), func(value ice.Maps) { if value[mdb.NAME] == m.Option(PATTERN) { m.Echo(kit.Select(defs_pattern, func_pattern, value[mdb.TYPE] == "function"), path.Join(value[nfs.PATH], value[nfs.FILE]), m.Option(PATTERN)) @@ -48,7 +48,7 @@ func init() { } } }}, - TAGS: {Name: "tags zone id auto", Help: "索引", Action: ice.MergeAction(map[string]*ice.Action{ + TAGS: {Name: "tags zone id auto", Help: "索引", Actions: ice.MergeAction(ice.Actions{ "listTags": {Name: "listTags", Help: "索引", Hand: func(m *ice.Message, arg ...string) { kit.Fetch(kit.UnMarshal(m.Option(mdb.TEXT)), func(index int, value ice.Map) { m.Cmd(TAGS, mdb.INSERT, mdb.ZONE, value[mdb.ZONE], kit.Simple(value)) @@ -66,12 +66,12 @@ func init() { name := kit.Select("", kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t \n."), -1), 0) switch name { case "can": - mdb.ZoneSelectCB(m, "", func(value map[string]string) { + mdb.ZoneSelectCB(m, "", func(value ice.Maps) { m.Echo(value[mdb.NAME] + ice.NL) }) return } - mdb.ZoneSelectCB(m, name, func(value map[string]string) { + mdb.ZoneSelectCB(m, name, func(value ice.Maps) { if !strings.Contains(value[mdb.NAME], m.Option(mdb.NAME)) && m.Option(mdb.NAME) != "." { return } diff --git a/misc/vim/vim.go b/misc/vim/vim.go index 8d71d93f..bcc2e3a7 100644 --- a/misc/vim/vim.go +++ b/misc/vim/vim.go @@ -19,12 +19,12 @@ func _vim_pkg(m *ice.Message, url string) string { const VIM = "vim" -var Index = &ice.Context{Name: VIM, Help: "编辑器", Configs: map[string]*ice.Config{ +var Index = &ice.Context{Name: VIM, Help: "编辑器", Configs: ice.Configs{ VIM: {Name: VIM, Help: "编辑器", Value: kit.Data( nfs.SOURCE, "http://mirrors.tencent.com/macports/distfiles/vim/vim-8.2.2681.tar.gz", )}, -}, Commands: map[string]*ice.Command{ - VIM: {Name: "vim path auto order build download", Help: "编辑器", Action: ice.MergeAction(map[string]*ice.Action{ +}, Commands: ice.Commands{ + VIM: {Name: "vim path auto order build download", Help: "编辑器", Actions: ice.MergeAction(ice.Actions{ cli.BUILD: {Name: "build", Help: "构建", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, cli.BUILD, _vim_pkg(m, m.Config(nfs.SOURCE)), "--enable-multibyte=yes", "--enable-pythoninterp=yes", "--enable-luainterp=yes", "--enable-cscope=yes") diff --git a/misc/vim/vimrc.go b/misc/vim/vimrc.go index 240944bc..ac5c3431 100644 --- a/misc/vim/vimrc.go +++ b/misc/vim/vimrc.go @@ -10,8 +10,8 @@ import ( const VIMRC = "vimrc" func init() { - Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - VIMRC: {Name: "vimrc", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: ice.Commands{ + VIMRC: {Name: "vimrc", Help: "收藏夹", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.PLUGIN, mdb.CREATE, VIMRC, m.PrefixKey()) m.Cmd(mdb.RENDER, mdb.CREATE, VIMRC, m.PrefixKey()) @@ -20,7 +20,7 @@ func init() { code.LoadPlug(m, VIMRC) }}, }, code.PlugAction())}, - }, Configs: map[string]*ice.Config{ + }, Configs: ice.Configs{ VIMRC: {Name: VIMRC, Help: "收藏夹", Value: kit.Data( code.PLUG, kit.Dict( code.SPLIT, kit.Dict("space", " \t", "operator", "{[(&.,;!|<>)]}"), diff --git a/misc/wework/bot.go b/misc/wework/bot.go index b8e3292c..8c37f1a4 100644 --- a/misc/wework/bot.go +++ b/misc/wework/bot.go @@ -16,11 +16,11 @@ import ( const BOT = "bot" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ BOT: {Name: "bot", Help: "机器人", Value: kit.Data( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,token,ekey,hook", )}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) {}}, "/bot/": {Name: "/bot/", Help: "机器人", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(BOT, arg[0]) @@ -47,7 +47,7 @@ func init() { m.Debug("what %v", en_msg) m.RenderResult(en_msg) }}, - BOT: {Name: "bot name chat text:textarea auto create", Help: "机器人", Action: ice.MergeAction(map[string]*ice.Action{ + BOT: {Name: "bot name chat text:textarea auto create", Help: "机器人", Actions: ice.MergeAction(ice.Actions{ mdb.CREATE: {Name: "create name token ekey hook", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Cmd(web.SPIDE, mdb.CREATE, m.Option("name"), m.Option("hook")) m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, arg) diff --git a/misc/wx/access.go b/misc/wx/access.go index 82b76072..285f568f 100644 --- a/misc/wx/access.go +++ b/misc/wx/access.go @@ -56,12 +56,12 @@ const ( const ACCESS = "access" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ ACCESS: {Name: ACCESS, Help: "认证", Value: kit.Data( tcp.SERVER, "https://api.weixin.qq.com", ssh.SCRIPT, "/plugin/local/chat/wx.js", )}, - }, Commands: map[string]*ice.Command{ - ACCESS: {Name: "access appid auto config ticket tokens login", Help: "认证", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + ACCESS: {Name: "access appid auto config ticket tokens login", Help: "认证", Actions: ice.MergeAction(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(web.SPIDE, mdb.CREATE, WX, m.Config(tcp.SERVER)) }}, diff --git a/misc/wx/event.go b/misc/wx/event.go index f4dd9f98..21121049 100644 --- a/misc/wx/event.go +++ b/misc/wx/event.go @@ -8,10 +8,10 @@ import ( const EVENT = "event" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ EVENT: {Name: EVENT, Help: "事件", Value: kit.Data()}, - }, Commands: map[string]*ice.Command{ - EVENT: {Name: "event", Help: "事件", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + EVENT: {Name: "event", Help: "事件", Actions: ice.Actions{ "subscribe": {Name: "subscribe", Help: "订阅", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(MENU, "home") }}, diff --git a/misc/wx/favor.go b/misc/wx/favor.go index ca3bd7f7..09c0b1c5 100644 --- a/misc/wx/favor.go +++ b/misc/wx/favor.go @@ -10,16 +10,16 @@ import ( const FAVOR = "favor" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ FAVOR: {Name: "favor", Help: "收藏", Value: kit.Data( mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,type,name,text", mdb.LINK, "https://open.weixin.qq.com/qr/code", )}, - }, Commands: map[string]*ice.Command{ - FAVOR: {Name: "favor text:text auto create", Help: "收藏", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + 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 map[string]string, head []string) { + mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) { m.PushQRCode(mdb.SCAN, kit.MergeURL(m.Config(mdb.LINK), aaa.USERNAME, value[mdb.TEXT])) }) }}, diff --git a/misc/wx/login.go b/misc/wx/login.go index 26170de9..893a6849 100644 --- a/misc/wx/login.go +++ b/misc/wx/login.go @@ -63,9 +63,9 @@ func _wx_parse(m *ice.Message) { const LOGIN = "login" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ LOGIN: {Name: LOGIN, Help: "登录", Value: kit.Data()}, - }, Commands: map[string]*ice.Command{ + }, Commands: ice.Commands{ "/login/": {Name: "/login/", Help: "认证", Hand: func(m *ice.Message, arg ...string) { if m.Cmdx(ACCESS, CHECK) == "" { return // 验签失败 @@ -100,7 +100,7 @@ func init() { m.Cmdy(MENU, "home") } }}, - LOGIN: {Name: "login", Help: "登录", Action: map[string]*ice.Action{ + LOGIN: {Name: "login", Help: "登录", Actions: ice.Actions{ mdb.CREATE: {Name: "create appid appmm token", Help: "创建", Hand: func(m *ice.Message, arg ...string) { m.Conf(ACCESS, kit.Keym(APPID), m.Option(APPID)) m.Conf(ACCESS, kit.Keym(APPMM), m.Option(APPMM)) diff --git a/misc/wx/menu.go b/misc/wx/menu.go index 49ef7059..0789cd7b 100644 --- a/misc/wx/menu.go +++ b/misc/wx/menu.go @@ -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 map[string]string, head []string) { count++ }) + m.Table(func(index int, value ice.Maps, head []string) { count++ }) m.Echo(`%d`, count) share := m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN) m.Echo(``) - m.Table(func(index int, value map[string]string, head []string) { + m.Table(func(index int, value ice.Maps, head []string) { m.Echo(` <![CDATA[%s]]> @@ -44,12 +44,12 @@ func _wx_action(m *ice.Message) { const MENU = "menu" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ MENU: {Name: MENU, Help: "菜单", Value: kit.Data( mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,title,refer,image", )}, - }, Commands: map[string]*ice.Command{ - MENU: {Name: "menu zone id auto insert", Help: "菜单", Action: ice.MergeAction(map[string]*ice.Action{ + }, Commands: ice.Commands{ + MENU: {Name: "menu zone id auto insert", Help: "菜单", Actions: ice.MergeAction(ice.Actions{ mdb.INSERT: {Name: "insert zone=home title=hi refer=hello image", Help: "添加"}, }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.ZoneSelect(m, arg...); len(arg) > 0 { diff --git a/misc/wx/text.go b/misc/wx/text.go index dfd25e25..ccd8ce69 100644 --- a/misc/wx/text.go +++ b/misc/wx/text.go @@ -17,10 +17,10 @@ func _wx_reply(m *ice.Message, tmpl string) { const TEXT = "text" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + Index.Merge(&ice.Context{Configs: ice.Configs{ TEXT: {Name: TEXT, Help: "文本", Value: kit.Data(nfs.TEMPLATE, text)}, - }, Commands: map[string]*ice.Command{ - TEXT: {Name: "text", Help: "文本", Action: map[string]*ice.Action{ + }, Commands: ice.Commands{ + TEXT: {Name: "text", Help: "文本", Actions: ice.Actions{ MENU: {Name: "menu name", Help: "菜单", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(MENU, kit.Select("home", m.Option(mdb.NAME))) }}, diff --git a/render.go b/render.go index 01b15a2f..ca577a99 100644 --- a/render.go +++ b/render.go @@ -177,7 +177,7 @@ func (m *Message) PushAction(list ...Any) *Message { if len(m.meta[MSG_APPEND]) == 0 { return m } - return m.Set(MSG_APPEND, ACTION).Tables(func(value map[string]string) { m.PushButton(list...) }) + return m.Set(MSG_APPEND, ACTION).Tables(func(value Maps) { m.PushButton(list...) }) } func (m *Message) PushSearch(args ...Any) { data := kit.Dict(args...) @@ -198,16 +198,16 @@ func (m *Message) PushSearch(args ...Any) { } func (m *Message) PushPodCmd(cmd string, arg ...string) { if m.Length() > 0 && len(m.Appendv(POD)) == 0 { - m.Tables(func(value map[string]string) { m.Push(POD, m.Option(MSG_USERPOD)) }) + m.Tables(func(value Maps) { m.Push(POD, m.Option(MSG_USERPOD)) }) } - m.Cmd(SPACE, OptionFields("type,name")).Tables(func(value map[string]string) { + m.Cmd(SPACE, OptionFields("type,name")).Tables(func(value Maps) { switch value[TYPE] { case "server", "worker": if value[NAME] == Info.HostName { break } - m.Cmd(SPACE, value[NAME], m.Prefix(cmd), arg).Table(func(index int, val map[string]string, head []string) { + m.Cmd(SPACE, value[NAME], m.Prefix(cmd), arg).Table(func(index int, val Maps, head []string) { val[POD] = kit.Keys(value[NAME], val[POD]) m.Push("", val, head) }) @@ -270,16 +270,16 @@ func (m *Message) DisplayStoryJSON(arg ...Any) *Message { // /plugin/story/json. return m.DisplayStory("json", arg...) } -func DisplayBase(file string, arg ...string) map[string]string { - return map[string]string{DISPLAY: file, STYLE: kit.Join(arg, SP)} +func DisplayBase(file string, arg ...string) Maps { + return Maps{DISPLAY: file, STYLE: kit.Join(arg, SP)} } -func DisplayStory(file string, arg ...string) map[string]string { // /plugin/story/file +func DisplayStory(file string, arg ...string) Maps { // /plugin/story/file if !strings.HasPrefix(file, HTTP) && !strings.HasPrefix(file, PS) { file = path.Join(PLUGIN_STORY, file) } return DisplayBase(file, arg...) } -func DisplayLocal(file string, arg ...string) map[string]string { // /plugin/local/file +func DisplayLocal(file string, arg ...string) Maps { // /plugin/local/file if file == "" { file = path.Join(kit.PathName(2), kit.Keys(kit.FileName(2), JS)) } @@ -288,10 +288,10 @@ func DisplayLocal(file string, arg ...string) map[string]string { // /plugin/loc } return DisplayBase(file, arg...) } -func Display(file string, arg ...string) map[string]string { // repos local file +func Display(file string, arg ...string) Maps { // repos local file return displayRequire(2, file, arg...) } -func displayRequire(n int, file string, arg ...string) map[string]string { +func displayRequire(n int, file string, arg ...string) Maps { if file == "" { file = kit.Keys(kit.FileName(n+1), JS) } diff --git a/type.go b/type.go index 8bbc7d60..4fb28b32 100644 --- a/type.go +++ b/type.go @@ -15,8 +15,13 @@ import ( ) type Any = interface{} +type List = []Any type Map = map[string]Any +type Maps = map[string]string type CommandHandler func(m *Message, arg ...string) +type Commands = map[string]*Command +type Actions = map[string]*Action +type Configs = map[string]*Config type Cache struct { Name string @@ -35,12 +40,12 @@ type Action struct { List []Any } type Command struct { - Name string - Help string - Action map[string]*Action - Hand CommandHandler - List []Any - Meta Map + Name string + Help string + Actions map[string]*Action + Hand CommandHandler + List []Any + Meta Map } type Server interface { Spawn(m *Message, c *Context, arg ...string) Server @@ -161,7 +166,7 @@ func (c *Context) Merge(s *Context) *Context { cmd.Meta = kit.Dict() } - for k, a := range cmd.Action { + for k, a := range cmd.Actions { if p, ok := c.Commands[k]; ok { switch h := a.Hand; k { case CTX_INIT: @@ -199,8 +204,8 @@ func (c *Context) Merge(s *Context) *Context { cmd.Meta[k] = a.List } } - delete(cmd.Action, CTX_INIT) - delete(cmd.Action, CTX_EXIT) + delete(cmd.Actions, CTX_INIT) + delete(cmd.Actions, CTX_EXIT) } if c.Configs == nil { @@ -341,7 +346,7 @@ func (m *Message) Spawn(arg ...Any) *Message { for k, v := range val { msg.Option(k, v) } - case map[string]string: + case Maps: for k, v := range val { msg.Option(k, v) }
{{$v}}