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, `