diff --git a/base/aaa/role.go b/base/aaa/role.go index e9f6d83f..7a102bb8 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -130,7 +130,7 @@ func init() { m.Echo(ice.OK) } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { _role_list(m, kit.Select("", arg, 0)) m.PushAction(mdb.DELETE) }}, diff --git a/base/aaa/sess.go b/base/aaa/sess.go index f1f755c9..53732204 100644 --- a/base/aaa/sess.go +++ b/base/aaa/sess.go @@ -77,7 +77,7 @@ func init() { }, Commands: map[string]*ice.Command{ SESS: {Name: "sess hash auto prunes", Help: "会话", Action: ice.MergeAction(map[string]*ice.Action{ mdb.CREATE: {Name: "create username", Help: "创建"}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, 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 197a91b0..fd98c453 100644 --- a/base/aaa/totp.go +++ b/base/aaa/totp.go @@ -66,8 +66,8 @@ func init() { m.Cmd(mdb.INSERT, TOTP, "", mdb.HASH, m.OptionSimple(mdb.NAME, SECRET, PERIOD, NUMBER)) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - mdb.HashSelect(m.Spawn(c), arg...).Table(func(index int, value map[string]string, head []string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { + mdb.HashSelect(m.Spawn(), arg...).Tables(func(value map[string]string) { if len(arg) > 0 { m.OptionFields(mdb.DETAIL) } diff --git a/base/aaa/user.go b/base/aaa/user.go index 5fae6c2b..3597967f 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -130,7 +130,7 @@ func init() { _user_create(m, m.Option(USERROLE), m.Option(USERNAME), m.Option(PASSWORD)) } }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) }}, }}) diff --git a/base/cli/daemon.go b/base/cli/daemon.go index 1b64f3c3..96170b82 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -50,6 +50,8 @@ func _daemon_exec(m *ice.Message, cmd *exec.Cmd) { cb(m.Conf(DAEMON, kit.Keys(mdb.HASH, h, kit.Keym(STATUS)))) case func(): cb() + default: + m.Error(true, ice.ErrNotImplement) } for _, p := range kit.Simple(CMD_INPUT, CMD_OUTPUT, CMD_ERRPUT) { @@ -131,7 +133,7 @@ func init() { m.SetAppend() } }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, 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) { switch value[STATUS] { case START: diff --git a/base/cli/forever.go b/base/cli/forever.go index 89bdbaf6..6d846771 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -54,7 +54,7 @@ func init() { STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) { _forever_kill(m, "QUIT") }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { _forever_kill(m, "") return diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index 2f3b71db..c040a10a 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -135,7 +135,7 @@ func init() { return m.Cmd(QRCODE, kit.Simple(args...)).Result() }) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Option(SIZE, kit.Select("240", arg, 3)) m.Option(BG, kit.Select(WHITE, arg, 2)) m.Option(FG, kit.Select(BLUE, arg, 1)) diff --git a/base/cli/runtime.go b/base/cli/runtime.go index 1a47ce2f..e710ba3a 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -219,7 +219,7 @@ func init() { m.Echo(kit.MergePOD(os.Getenv(CTX_DEV), os.Getenv(CTX_POD))) } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == BOOTINFO { arg = arg[1:] } diff --git a/base/cli/system.go b/base/cli/system.go index adab1514..5955810b 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -154,7 +154,7 @@ func init() { nfs.FIND: {Name: "find", Help: "查找", Hand: func(m *ice.Message, arg ...string) { m.Echo(_system_find(m, arg[0], arg[1:]...)) }}, - }, Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { mdb.ListSelect(m, arg...) return diff --git a/base/ctx/command.go b/base/ctx/command.go index 09de07fc..911720ee 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -72,8 +72,8 @@ func _command_search(m *ice.Message, kind, name, text string) { }) } -func CmdAction(fields ...string) map[string]*ice.Action { - return ice.SelectAction(map[string]*ice.Action{ +func CmdAction(args ...ice.Any) map[string]*ice.Action { + return map[string]*ice.Action{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) @@ -84,7 +84,7 @@ func CmdAction(fields ...string) map[string]*ice.Action { m.Cmdy(arg) } }}, - }, fields...) + } } const ( @@ -110,7 +110,7 @@ func init() { _command_search(m, arg[0], kit.Select("", arg, 1), kit.Select("", arg, 2)) } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { arg = append(arg, "") } diff --git a/base/ctx/config.go b/base/ctx/config.go index 137f6f1f..24eaa177 100644 --- a/base/ctx/config.go +++ b/base/ctx/config.go @@ -126,7 +126,7 @@ func init() { m.Conf(m.Option("key"), m.Option("sub"), "") m.Go(func() { m.Cmd(ice.EXIT, 1) }) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { _config_list(m) return diff --git a/base/ctx/context.go b/base/ctx/context.go index 6cd1fe46..7f7d5c35 100644 --- a/base/ctx/context.go +++ b/base/ctx/context.go @@ -54,7 +54,7 @@ func init() { m.Cmdy(COMMAND, kit.Keys(index, strings.Split(arg[2], ice.SP)[0])) } }}, - }, CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, CmdAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { arg = append(arg, m.Source().Cap(ice.CTX_FOLLOW)) } diff --git a/base/ctx/message.go b/base/ctx/message.go index 12973d3f..f5028163 100644 --- a/base/ctx/message.go +++ b/base/ctx/message.go @@ -13,7 +13,7 @@ const MESSAGE = "message" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - MESSAGE: {Name: "message", Help: "消息", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + MESSAGE: {Name: "message", Help: "消息", Hand: func(m *ice.Message, arg ...string) { t := reflect.TypeOf(m) for i := 0; i < t.NumMethod(); i++ { method := t.Method(i) diff --git a/base/gdb/event.go b/base/gdb/event.go index 97ade45c..72628871 100644 --- a/base/gdb/event.go +++ b/base/gdb/event.go @@ -29,7 +29,7 @@ func init() { HAPPEN: {Name: "happen event arg", Help: "触发", Hand: func(m *ice.Message, arg ...string) { _event_action(m, m.Option(EVENT), arg[2:]...) }}, - }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.ZoneSelect(m, arg...); len(arg) == 0 { m.PushAction(HAPPEN, mdb.REMOVE) } diff --git a/base/gdb/gdb.go b/base/gdb/gdb.go index 565a5756..5bafee78 100644 --- a/base/gdb/gdb.go +++ b/base/gdb/gdb.go @@ -46,10 +46,10 @@ 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{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Load(TIMER) }}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Save(TIMER) }}, }} diff --git a/base/gdb/routine.go b/base/gdb/routine.go index 0cbba1af..eaeef50f 100644 --- a/base/gdb/routine.go +++ b/base/gdb/routine.go @@ -26,7 +26,7 @@ func init() { ls := kit.Split(m.Option("fileline"), ":") m.ProcessCommand("inner", []string{path.Dir(ls[0]), path.Base(ls[0]), ls[1]}, arg...) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) m.PushAction("inner", mdb.REMOVE) }}, diff --git a/base/gdb/signal.go b/base/gdb/signal.go index d178484c..b222c334 100644 --- a/base/gdb/signal.go +++ b/base/gdb/signal.go @@ -67,7 +67,7 @@ func init() { HAPPEN: {Name: "happen signal", Help: "触发", Hand: func(m *ice.Message, arg ...string) { _signal_action(m, m.Option(SIGNAL)) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Sort(SIGNAL) m.PushAction(HAPPEN, mdb.REMOVE) }}, diff --git a/base/gdb/timer.go b/base/gdb/timer.go index ffbf264d..cebc3de8 100644 --- a/base/gdb/timer.go +++ b/base/gdb/timer.go @@ -57,7 +57,7 @@ func init() { HAPPEN: {Name: "happen", Help: "执行", Hand: func(m *ice.Message, arg ...string) { _timer_action(m, arg...) }}, - }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { m.Fields(len(arg), m.Config(mdb.FIELD), "time,id,res") mdb.ZoneSelect(m, arg...) }}, diff --git a/base/lex/matrix.go b/base/lex/matrix.go index 6218ad6e..5ce8f23d 100644 --- a/base/lex/matrix.go +++ b/base/lex/matrix.go @@ -398,6 +398,8 @@ func init() { switch cb := m.OptionCB(MATRIX).(type) { case func(string, *Matrix): cb(h, mat) + default: + m.Error(true, ice.ErrNotImplement) } m.Echo(h) }}, @@ -438,7 +440,7 @@ func init() { }) m.ProcessInner() }}, - }, Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Action(mdb.CREATE); len(arg) == 0 { // 矩阵列表 m.Fields(len(arg), "time,hash,npage,nhash") m.Cmdy(mdb.SELECT, m.PrefixKey(), "", mdb.HASH) diff --git a/base/lex/split.go b/base/lex/split.go index 52617816..d08abfae 100644 --- a/base/lex/split.go +++ b/base/lex/split.go @@ -59,6 +59,8 @@ func _split_list(m *ice.Message, file string, arg ...string) ice.Map { ls = cb(ls, data) case func([]string): cb(ls) + default: + m.Error(true, ice.ErrNotImplement) } // 参数字段 @@ -102,7 +104,7 @@ func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ SPLIT: {Name: "split", Help: "解析", Value: kit.Data()}, }, Commands: map[string]*ice.Command{ - SPLIT: {Name: "split path key auto", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + 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) return diff --git a/base/log/log.go b/base/log/log.go index a7c6cd16..b4fe2a7d 100644 --- a/base/log/log.go +++ b/base/log/log.go @@ -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{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { if log.LogDisable { return // 禁用日志 } @@ -143,7 +143,7 @@ var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: map[string] } }) }}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, + ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {}}, }} func init() { ice.Index.Register(Index, &Frame{}) } diff --git a/base/mdb/engine.go b/base/mdb/engine.go index 459dab8b..3b9c02aa 100644 --- a/base/mdb/engine.go +++ b/base/mdb/engine.go @@ -17,7 +17,7 @@ func init() { m.Option(TYPE, kit.Ext(m.Option(TYPE))) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) }}, - }, HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, HashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 1 { m.Cmdy(SELECT, m.PrefixKey(), "", HASH, m.Config(SHORT), arg, func(value ice.Map) { m.Cmdy(kit.Keys(value[TEXT], value[NAME]), m.CommandKey(), arg[0], arg[1], kit.Select("", arg, 2), kit.Slice(arg, 3)) diff --git a/base/mdb/hash.go b/base/mdb/hash.go index 3d6d0f00..a8606d1d 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -151,7 +151,7 @@ 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()].Meta[CREATE] != nil { + if cs := m.Target().Commands; cs[m.CommandKey()] == nil || cs[m.CommandKey()].Meta[CREATE] != nil { return } @@ -176,7 +176,7 @@ func HashAction(args ...ice.Any) map[string]*ice.Action { } return kit.Select(HASH, m.Config(SHORT)) } - return ice.SelectAction(map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...), + return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...), INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INPUTS, m.PrefixKey(), "", HASH, arg) }}, @@ -204,7 +204,7 @@ func HashAction(args ...ice.Any) map[string]*ice.Action { SELECT: &ice.Action{Name: "select hash auto", Help: "列表", Hand: func(m *ice.Message, arg ...string) { HashSelect(m, arg...) }}, - }) + } } func HashActionStatus(args ...ice.Any) map[string]*ice.Action { list := HashAction(args...) diff --git a/base/mdb/list.go b/base/mdb/list.go index 9beed6ff..3ac291a8 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(fields ...string) map[string]*ice.Action { - return ice.SelectAction(map[string]*ice.Action{ +func ListAction(args ...ice.Any) map[string]*ice.Action { + return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...), INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INPUTS, m.PrefixKey(), "", LIST, arg) }}, @@ -169,7 +169,7 @@ func ListAction(fields ...string) map[string]*ice.Action { SELECT: {Name: "select", Help: "列表", Hand: func(m *ice.Message, arg ...string) { ListSelect(m, arg...) }}, - }, fields...) + } } func ListSelect(m *ice.Message, arg ...string) *ice.Message { m.OptionPage(kit.Slice(arg, 1)...) diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index e73210e4..9b495ab4 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -143,9 +143,9 @@ func NextPageLimit(m *ice.Message, total string, arg ...string) { const MDB = "mdb" var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, - INSERT: {Name: "insert key sub type arg...", Help: "添加", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + 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) { switch arg[2] { case ZONE: // insert key sub type zone arg... _list_insert(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), arg[4:]...) @@ -156,7 +156,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]* } m.ProcessRefresh3ms() }}, - DELETE: {Name: "delete key sub type field value", Help: "删除", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + DELETE: {Name: "delete key sub type field value", Help: "删除", Hand: func(m *ice.Message, arg ...string) { switch arg[2] { case ZONE: // delete key sub type zone field value _list_delete(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), arg[4], arg[5]) @@ -167,7 +167,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]* } m.ProcessRefresh3ms() }}, - MODIFY: {Name: "modify key sub type field value arg...", Help: "编辑", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + MODIFY: {Name: "modify key sub type field value arg...", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { switch arg[2] { case ZONE: // modify key sub type zone id field value _list_modify(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), ID, arg[4], arg[5:]...) @@ -177,7 +177,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]* _list_modify(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4], arg[5:]...) } }}, - SELECT: {Name: "select key sub type field value", Help: "查询", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SELECT: {Name: "select key sub type field value", Help: "查询", Hand: func(m *ice.Message, arg ...string) { switch arg[2] { case ZONE: _zone_select(m, arg[0], _domain_chain(m, arg[1]), kit.Select("", arg, 3), kit.Select("", arg, 4)) @@ -187,7 +187,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]* _list_select(m, arg[0], _domain_chain(m, arg[1]), kit.Select("", arg, 3), kit.Select("", arg, 4)) } }}, - INPUTS: {Name: "inputs key sub type field value", Help: "补全", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + INPUTS: {Name: "inputs key sub type field value", Help: "补全", Hand: func(m *ice.Message, arg ...string) { switch arg[2] { case ZONE: // inputs key sub type zone field value _list_inputs(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), kit.Select(NAME, arg, 4), kit.Select("", arg, 5)) @@ -197,7 +197,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]* _list_inputs(m, arg[0], _domain_chain(m, arg[1]), kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) } }}, - PRUNES: {Name: "prunes key sub type [field value]...", Help: "清理", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + PRUNES: {Name: "prunes key sub type [field value]...", Help: "清理", Hand: func(m *ice.Message, arg ...string) { switch arg[2] { case ZONE: // prunes key sub type zone field value _list_prunes(m, arg[0], _domain_chain(m, kit.Keys(arg[1], kit.KeyHash(arg[3]))), arg[4:]...) @@ -207,7 +207,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]* _list_prunes(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...) } }}, - EXPORT: {Name: "export key sub type file", Help: "导出", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + EXPORT: {Name: "export key sub type file", Help: "导出", Hand: func(m *ice.Message, arg ...string) { if m.Option(ice.CACHE_LIMIT) == "" { m.Option(ice.CACHE_LIMIT, "-1") } @@ -220,7 +220,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]* _list_export(m, arg[0], _domain_chain(m, arg[1]), file) } }}, - IMPORT: {Name: "import key sub type file", Help: "导入", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + IMPORT: {Name: "import key sub type file", Help: "导入", Hand: func(m *ice.Message, arg ...string) { switch file := _file_name(m, arg...); arg[2] { case ZONE: _zone_import(m, arg[0], _domain_chain(m, arg[1]), file) diff --git a/base/mdb/plugin.go b/base/mdb/plugin.go index 7180650e..33a5f52b 100644 --- a/base/mdb/plugin.go +++ b/base/mdb/plugin.go @@ -17,7 +17,7 @@ func init() { m.Option(TYPE, kit.Ext(m.Option(TYPE))) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) > 1 { m.Cmdy(SELECT, m.PrefixKey(), "", HASH, m.Config(SHORT), arg, func(value ice.Map) { m.Cmdy(kit.Keys(value[TEXT], value[NAME]), m.CommandKey(), arg[0], arg[1], kit.Select("", arg, 2), kit.Slice(arg, 3)) diff --git a/base/mdb/render.go b/base/mdb/render.go index 44274de0..429fa4b7 100644 --- a/base/mdb/render.go +++ b/base/mdb/render.go @@ -17,7 +17,7 @@ func init() { m.Option(TYPE, kit.Ext(m.Option(TYPE))) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) > 1 { m.Cmdy(SELECT, m.PrefixKey(), "", HASH, m.Config(SHORT), arg, func(value ice.Map) { m.Cmdy(kit.Keys(value[TEXT], value[NAME]), m.CommandKey(), arg[0], arg[1], kit.Select("", arg, 2), kit.Slice(arg, 3)) diff --git a/base/mdb/search.go b/base/mdb/search.go index e9ebfc22..615da125 100644 --- a/base/mdb/search.go +++ b/base/mdb/search.go @@ -17,7 +17,7 @@ func init() { m.Option(TYPE, kit.Ext(m.Option(TYPE))) m.Cmdy(INSERT, m.PrefixKey(), "", HASH, m.OptionSimple("type,name,text")) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) > 1 { m.Cmdy(SELECT, m.PrefixKey(), "", HASH, m.Config(SHORT), kit.Slice(arg, 0, 1), func(value ice.Map) { m.OptionFields(kit.Select("ctx,cmd,type,name,text", kit.Select(m.OptionFields()))) diff --git a/base/mdb/zone.go b/base/mdb/zone.go index 58edc5ee..0acfcbb3 100644 --- a/base/mdb/zone.go +++ b/base/mdb/zone.go @@ -148,7 +148,7 @@ const ZONE = "zone" func ZoneAction(args ...ice.Any) map[string]*ice.Action { _zone := func(m *ice.Message) string { return kit.Select(ZONE, m.Config(SHORT)) } - return ice.SelectAction(map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...), + return map[string]*ice.Action{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]))) @@ -208,7 +208,7 @@ func ZoneAction(args ...ice.Any) map[string]*ice.Action { SELECT: {Name: "select", Help: "列表", Hand: func(m *ice.Message, arg ...string) { ZoneSelect(m, arg...) }}, - }) + } } func ZoneSelect(m *ice.Message, arg ...string) *ice.Message { arg = kit.Slice(arg, 0, 2) diff --git a/base/nfs/cat.go b/base/nfs/cat.go index 4d1a06fe..65fc1cd9 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -58,6 +58,8 @@ func _cat_find(m *ice.Message, name string) io.ReadCloser { if s := h(m, name); s != "" { return NewReadCloser(bytes.NewBufferString(s)) } + default: + m.Error(true, ice.ErrNotImplement) } } @@ -182,7 +184,7 @@ func init() { mdb.RENDER: {Name: "render type name text", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { _cat_list(m, path.Join(arg[2], arg[1])) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) { m.Cmdy(DIR, arg) return diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 82d94901..f54eefde 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -84,6 +84,9 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d case func(p string): cb(p) continue + case nil: + default: + m.Error(true, ice.ErrNotImplement) } for _, field := range fields { @@ -258,7 +261,7 @@ func init() { TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TRASH, m.Option(PATH)) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Option(DIR_ROOT) != "" { m.Info("dir_root: %v", m.Option(DIR_ROOT)) } diff --git a/base/nfs/find.go b/base/nfs/find.go index 2e6c9696..6f65e342 100644 --- a/base/nfs/find.go +++ b/base/nfs/find.go @@ -10,7 +10,7 @@ const FIND = "find" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - FIND: {Name: "find path word auto", Help: "搜索", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + 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 92ec1512..1954c79a 100644 --- a/base/nfs/grep.go +++ b/base/nfs/grep.go @@ -6,7 +6,7 @@ const GREP = "grep" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - GREP: {Name: "grep path word auto", Help: "搜索", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + 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 3e2ba6d5..793c3f50 100644 --- a/base/nfs/save.go +++ b/base/nfs/save.go @@ -73,7 +73,7 @@ func _link_file(m *ice.Message, name string, from string) { os.Remove(name) MkdirAll(m, path.Dir(name)) if e := os.Link(from, name); e != nil { - if m.Warn(os.Symlink(from, name), ice.ErrFailure, from) { + if m.Warn(os.Symlink(from, name), ice.ErrWarn, from) { return } } @@ -93,22 +93,22 @@ const LINK = "link" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - DEFS: {Name: "defs file text...", Help: "默认", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + DEFS: {Name: "defs file text...", Help: "默认", Hand: func(m *ice.Message, arg ...string) { _defs_file(m, arg[0], arg[1:]...) }}, - SAVE: {Name: "save file text...", Help: "保存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SAVE: {Name: "save file text...", Help: "保存", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 1 { arg = append(arg, m.Option(CONTENT)) } _save_file(m, arg[0], arg[1:]...) }}, - PUSH: {Name: "push file text...", Help: "追加", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + PUSH: {Name: "push file text...", Help: "追加", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 1 { arg = append(arg, m.Option(CONTENT)) } _push_file(m, arg[0], arg[1:]...) }}, - COPY: {Name: "copy file from...", Help: "复制", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + COPY: {Name: "copy file from...", Help: "复制", Hand: func(m *ice.Message, arg ...string) { for _, file := range arg[1:] { if kit.FileExists(file) { _copy_file(m, arg[0], arg[1:]...) @@ -116,7 +116,7 @@ func init() { } } }}, - LINK: {Name: "link file from", Help: "链接", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + LINK: {Name: "link file from", Help: "链接", Hand: func(m *ice.Message, arg ...string) { _link_file(m, arg[0], arg[1]) }}, }}) diff --git a/base/nfs/tail.go b/base/nfs/tail.go index 6acf7fdb..c1e17de5 100644 --- a/base/nfs/tail.go +++ b/base/nfs/tail.go @@ -62,11 +62,11 @@ func init() { mdb.CREATE: {Name: "create file name", Help: "创建", Hand: func(m *ice.Message, arg ...string) { _tail_create(m, arg...) }}, - }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { 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(c), arg...).Table(func(index int, value map[string]string, head []string) { + mdb.ZoneSelect(m.Spawn(), arg...).Table(func(index int, value map[string]string, 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 6d1e4cfa..c39f3a16 100644 --- a/base/nfs/tar.go +++ b/base/nfs/tar.go @@ -31,7 +31,7 @@ func init() { m.Cmd("cli.system", "tar", "xvf", arg) m.Echo(arg[0]) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Option("cmd_dir", m.Option(DIR_ROOT)) m.Debug("cmd_dir: %v", m.Option("cmd_dir")) m.Cmdy("cli.system", "tar", "zcvf", arg) diff --git a/base/nfs/trash.go b/base/nfs/trash.go index 5bc65ee9..c3e31142 100644 --- a/base/nfs/trash.go +++ b/base/nfs/trash.go @@ -59,7 +59,7 @@ func init() { return false }) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) == 0 || !kit.FileExists(arg[0]) { m.PushAction(mdb.REVERT, mdb.REMOVE) return diff --git a/base/ssh/scripts.go b/base/ssh/scripts.go index 06f2d179..d8b84cfe 100644 --- a/base/ssh/scripts.go +++ b/base/ssh/scripts.go @@ -266,33 +266,33 @@ func init() { PS2, []ice.Any{mdb.COUNT, " ", TARGET, "> "}, )}, }, Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {}}, SOURCE: {Name: "source file", Help: "脚本解析", Action: ice.MergeAction(map[string]*ice.Action{ "repeat": {Name: "repeat", Help: "执行", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SCREEN, m.Option(mdb.TEXT)) m.ProcessInner() }}, - }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && kit.Ext(arg[0]) == ice.SHY { (&Frame{}).Start(m, arg...) return // 脚本解析 } }}, - TARGET: {Name: "target name run", Help: "当前模块", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - f := c.Server().(*Frame) + TARGET: {Name: "target name run", Help: "当前模块", Hand: func(m *ice.Message, arg ...string) { + f := m.Target().Server().(*Frame) m.Search(arg[0]+ice.PT, func(p *ice.Context, s *ice.Context, key string) { f.target = s }) f.prompt(m) }}, - PROMPT: {Name: "prompt arg run", Help: "命令提示", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + PROMPT: {Name: "prompt arg run", Help: "命令提示", Hand: func(m *ice.Message, arg ...string) { f := m.Optionv(FRAME).(*Frame) f.ps1 = arg f.prompt(m) }}, - PRINTF: {Name: "printf run text", Help: "输出显示", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + PRINTF: {Name: "printf run text", Help: "输出显示", Hand: func(m *ice.Message, arg ...string) { f := m.Optionv(FRAME).(*Frame) f.printf(m, arg[0]) }}, - SCREEN: {Name: "screen run text", Help: "输出命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SCREEN: {Name: "screen run text", Help: "输出命令", Hand: func(m *ice.Message, arg ...string) { f := m.Optionv(FRAME).(*Frame) for _, line := range kit.Split(arg[0], ice.NL, ice.NL) { fmt.Fprintf(f.pipe, line+ice.NL) @@ -301,7 +301,7 @@ func init() { } m.Echo(f.res) }}, - RETURN: {Name: "return", Help: "结束脚本", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + RETURN: {Name: "return", Help: "结束脚本", Hand: func(m *ice.Message, arg ...string) { f := m.Optionv(FRAME).(*Frame) f.Close(m, arg...) }}, diff --git a/base/tcp/client.go b/base/tcp/client.go index bf754d37..5ac213b2 100644 --- a/base/tcp/client.go +++ b/base/tcp/client.go @@ -92,7 +92,7 @@ func init() { DIAL: {Name: "dial type name port=9010 host=", Help: "连接", Hand: func(m *ice.Message, arg ...string) { _client_dial(m, arg...) }}, - }, mdb.HashActionStatus()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) { m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == OPEN)) }) diff --git a/base/tcp/host.go b/base/tcp/host.go index 59f8f3af..5e861658 100644 --- a/base/tcp/host.go +++ b/base/tcp/host.go @@ -92,7 +92,7 @@ func init() { m.Log_CREATE(aaa.WHITE, arg[0]) m.Rich(HOST, kit.Keym(aaa.WHITE), kit.Dict(mdb.TEXT, arg[0])) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { _host_list(m, kit.Select("", arg, 0)) }}, }}) diff --git a/base/tcp/port.go b/base/tcp/port.go index f557fdbb..559a9ee1 100644 --- a/base/tcp/port.go +++ b/base/tcp/port.go @@ -58,7 +58,7 @@ func init() { m.Cmd(nfs.TRASH, path.Join(ice.USR_LOCAL_DAEMON, m.Option(PORT))) } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { current := kit.Int(m.Config(BEGIN)) m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_DAEMON) diff --git a/base/tcp/server.go b/base/tcp/server.go index 45c96401..3f2ab3bd 100644 --- a/base/tcp/server.go +++ b/base/tcp/server.go @@ -100,7 +100,7 @@ func init() { LISTEN: {Name: "LISTEN type name port=9030 host=", Help: "监听", Hand: func(m *ice.Message, arg ...string) { _server_listen(m, arg...) }}, - }, mdb.HashActionStatus()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) { m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == CLOSE)) }) diff --git a/base/web/broad.go b/base/web/broad.go index 321fc5bb..e4c2d7be 100644 --- a/base/web/broad.go +++ b/base/web/broad.go @@ -81,7 +81,7 @@ func init() { }}, }, mdb.HashAction( mdb.SHORT, "host,port", mdb.FIELD, "time,hash,host,port", - )), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + )), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) m.PushAction(SPACE, mdb.REMOVE) }}, diff --git a/base/web/cache.go b/base/web/cache.go index 7ed17217..e2ea6b44 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -142,7 +142,7 @@ func init() { mdb.LIMIT, "50", mdb.LEAST, "30", )}, }, Commands: map[string]*ice.Command{ - "/cache/": {Name: "/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/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]) == "" { m.RenderResult(value[mdb.TEXT]) @@ -172,7 +172,7 @@ func init() { _cache_save(m, arg[0], arg[1], "", file, size) } }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) == 0 { return } diff --git a/base/web/dream.go b/base/web/dream.go index d8bc17e7..e56ef5e5 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -137,7 +137,7 @@ func init() { m.Cmd(nfs.TRASH, mdb.CREATE, path.Join(m.Config(nfs.PATH), m.Option(mdb.NAME))) m.ProcessRefresh30ms() }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { _dream_list(m) m.SetAppend("text") diff --git a/base/web/route.go b/base/web/route.go index 2c054208..edb7897d 100644 --- a/base/web/route.go +++ b/base/web/route.go @@ -98,7 +98,7 @@ func init() { m.Cmdy(SPACE, m.Option(ROUTE), ctx.CONTEXT, SPIDE, "", m.Option(ctx.CONTEXT), m.Option(mdb.NAME)) } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[0] == "" { // 路由列表 if _route_travel(m, kit.Select("", arg, 0)); m.W != nil { _route_list(m) diff --git a/base/web/serve.go b/base/web/serve.go index ac1e298d..80ad9991 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -92,6 +92,8 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool { if h(w, r) { return false } + default: + m.Error(true, ice.ErrNotImplement) } } return true @@ -374,30 +376,30 @@ func init() { return } }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) }}, - "/intshell/": {Name: "/intshell/", Help: "命令行", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/intshell/": {Name: "/intshell/", Help: "命令行", Hand: func(m *ice.Message, arg ...string) { m.RenderIndex(SERVE, ice.INTSHELL, arg...) }}, - "/volcanos/": {Name: "/volcanos/", Help: "浏览器", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/volcanos/": {Name: "/volcanos/", Help: "浏览器", Hand: func(m *ice.Message, arg ...string) { m.RenderIndex(SERVE, ice.VOLCANOS, arg...) }}, - "/require/src/": {Name: "/require/src/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/require/src/": {Name: "/require/src/", Help: "代码库", Hand: func(m *ice.Message, arg ...string) { if p := path.Join(ice.SRC, path.Join(arg...)); m.Option(ice.POD) != "" { m.RenderResult(m.Cmdx(SPACE, m.Option(ice.POD), nfs.CAT, p)) } else { m.RenderDownload(p) } }}, - "/require/usr/": {Name: "/require/usr/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/require/usr/": {Name: "/require/usr/", Help: "代码库", Hand: func(m *ice.Message, arg ...string) { m.RenderDownload(path.Join(ice.USR, path.Join(arg...))) }}, - "/require/": {Name: "/require/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/require/": {Name: "/require/", Help: "代码库", Hand: func(m *ice.Message, arg ...string) { _share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...) }}, - "/publish/": {Name: "/publish/", Help: "定制化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/publish/": {Name: "/publish/", Help: "定制化", Hand: func(m *ice.Message, arg ...string) { if arg[0] == ice.ORDER_JS { if p := path.Join(ice.USR_PUBLISH, ice.ORDER_JS); m.PodCmd(nfs.CAT, p) { if m.IsErr() { @@ -415,7 +417,7 @@ func init() { } _share_local(m, m.Conf(SERVE, kit.Keym(ice.PUBLISH)), path.Join(arg...)) }}, - "/help/": {Name: "/help/", Help: "帮助", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/help/": {Name: "/help/", Help: "帮助", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { arg = append(arg, "tutor.shy") } diff --git a/base/web/share.go b/base/web/share.go index 574e7ff2..274dafd4 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -154,7 +154,7 @@ func init() { m.EchoQRCode(msg.Option(mdb.LINK)) m.ProcessInner() }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if m.PodCmd(SHARE, arg) && m.Length() > 0 { return } @@ -169,7 +169,7 @@ func init() { m.PushAction(mdb.REMOVE) m.StatusTimeCount() }}, - "/share/": {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/share/": {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, arg ...string) { m.Option(SHARE, kit.Select(m.Option(SHARE), arg, 0)) if msg := m.Cmd(SHARE, m.Option(SHARE)); kit.Int(msg.Append(mdb.TIME)) < kit.Int(msg.FormatTime()) { m.RenderResult("共享超时") @@ -189,27 +189,27 @@ func init() { } }}, - SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, m.Option(ice.POD), m.Optionv("cmds")) }}, - SHARE_CACHE: {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_CACHE: {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, arg ...string) { _share_cache(m, arg...) }}, - SHARE_REPOS: {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_REPOS: {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, arg ...string) { _share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...) }}, - SHARE_PROXY: {Name: "/share/proxy/", Help: "文件流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_PROXY: {Name: "/share/proxy/", Help: "文件流", Hand: func(m *ice.Message, arg ...string) { _share_proxy(m) }}, - SHARE_LOCAL: {Name: "/share/local/", Help: "文件夹", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_LOCAL: {Name: "/share/local/", Help: "文件夹", Hand: func(m *ice.Message, arg ...string) { _share_local(m, arg...) }}, - SHARE_LOCAL_AVATAR: {Name: "avatar", Help: "头像", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_LOCAL_AVATAR: {Name: "avatar", Help: "头像", Hand: func(m *ice.Message, arg ...string) { // RenderType(m.W, "", "image/svg+xml") // m.RenderResult(``) m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.AVATAR), SHARE_LOCAL)) }}, - SHARE_LOCAL_BACKGROUND: {Name: "background", Help: "壁纸", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHARE_LOCAL_BACKGROUND: {Name: "background", Help: "壁纸", Hand: func(m *ice.Message, arg ...string) { m.RenderDownload(strings.TrimPrefix(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)).Append(aaa.BACKGROUND), SHARE_LOCAL)) }}, }}) diff --git a/base/web/space.go b/base/web/space.go index 7d60b974..7e6c1afe 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -319,7 +319,7 @@ func init() { tcp.DIAL: {Name: "dial dev=ops name", Help: "连接", Hand: func(m *ice.Message, arg ...string) { _space_dial(m, m.Option(ice.DEV), kit.Select(ice.Info.NodeName, m.Option(mdb.NAME))) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, 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) { @@ -337,7 +337,7 @@ func init() { // 下发命令 _space_send(m, strings.ToLower(arg[0]), arg[1:]...) }}, - "/space/": {Name: "/space/ type name share river", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/space/": {Name: "/space/ type name share river", Help: "空间站", Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }}, }}) diff --git a/base/web/spide.go b/base/web/spide.go index fd3f1b20..b529d935 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -372,7 +372,7 @@ func init() { "submit": {Name: "submit dev pod path size cache", Help: "发布", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPIDE, ice.DEV, SPIDE_RAW, m.Option("dev"), SPIDE_PART, "pod", m.Option("pod"), nfs.PATH, "bin/ice.bin", UPLOAD, "@"+"bin/ice.bin") }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") { mdb.HashSelect(m, kit.Slice(arg, 0, 1)...) m.Sort("client.name") @@ -385,14 +385,14 @@ func init() { 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, c *ice.Context, cmd string, arg ...string) { + }, 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{ 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, c *ice.Context, cmd string, arg ...string) { + }, 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:])))) }}, }}) diff --git a/base/web/story.go b/base/web/story.go index a2568504..904f78e6 100644 --- a/base/web/story.go +++ b/base/web/story.go @@ -184,10 +184,10 @@ func init() { HISTORY: {Name: "history name", Help: "历史", Hand: func(m *ice.Message, arg ...string) { _story_history(m, arg[0]) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { _story_list(m, kit.Select("", arg, 0), kit.Select("", arg, 1)) }}, - "/story/": {Name: "/story/", Help: "故事会", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/story/": {Name: "/story/", Help: "故事会", Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case PULL: list := m.Cmd(STORY, INDEX, m.Option("begin")).Append("list") diff --git a/base/yac/matrix.go b/base/yac/matrix.go index 6e5b7416..c2ad05cf 100644 --- a/base/yac/matrix.go +++ b/base/yac/matrix.go @@ -358,6 +358,8 @@ func init() { switch cb := m.OptionCB(MATRIX).(type) { case func(string, *Matrix): cb(h, mat) + default: + m.Error(true, ice.ErrNotImplement) } m.Echo(h) }}, @@ -397,6 +399,8 @@ func init() { switch cb := m.OptionCB(MATRIX).(type) { case func(string, int, []string, int, *lex.Stream) (int, []string): return cb(nhash, hash, word, begin, stream) + default: + m.Error(true, ice.ErrNotImplement) } return hash, word }, mat.index(m, NPAGE, m.Option(NPAGE)), stream, 1) @@ -415,7 +419,7 @@ func init() { }) m.ProcessInner() }}, - }, Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Option(ice.CACHE_LIMIT, -1) if m.Action(mdb.CREATE); len(arg) == 0 { // 矩阵列表 m.Fields(len(arg), "time,name,npage,nhash") diff --git a/base/yac/script.go b/base/yac/script.go index a49e747a..8261b408 100644 --- a/base/yac/script.go +++ b/base/yac/script.go @@ -195,7 +195,7 @@ func init() { stream.P = frame.pos } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 { m.Cmdy(MATRIX, arg) return @@ -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 := c.Commands[SCRIPT].Action[nhash]; ok && stack.can_run(nhash) { + if _, ok := m.Target().Commands[SCRIPT].Action[nhash]; ok && stack.can_run(nhash) { msg := m.Cmd(SCRIPT, nhash, word, ice.Option{"begin", begin}) return hash, msg.Resultv() } diff --git a/conf.go b/conf.go index 9dc70bff..8cdf6ba8 100644 --- a/conf.go +++ b/conf.go @@ -4,6 +4,8 @@ const ( TB = "\t" SP = " " DF = ":" + EQ = "=" + AT = "@" PS = "/" PT = "." FS = "," @@ -293,20 +295,17 @@ const ( // LOG LOG_IMPORT = "import" ) const ( // Err - ErrWarn = "warn: " - ErrPanic = "panic: " - ErrExists = "exists: " - ErrExpire = "expire: " - ErrTimeout = "timeout: " - ErrFailure = "failure: " + ErrWarn = "warn: " + ErrExpire = "expire: " + ErrNotLogin = "not login: " - ErrNotFound = "not found: " ErrNotRight = "not right: " + ErrNotFound = "not found: " ErrNotStart = "not start: " ErrNotImplement = "not implement: " ) -const ( +const ( // ice // CTX = "ctx" CLI = "cli" WEB = "web" @@ -335,6 +334,14 @@ const ( // web SPACE = "space" SPIDE = "spide" CACHE = "cache" + + WEBSITE = "website" +) +const ( // aaa + ROLE = "role" + RIGHT = "right" + USERROLE = "userrole" + ROOT = "root" ) const ( // mdb KEY = "key" @@ -358,9 +365,3 @@ const ( // gdb HAPPEN = "happen" FILELINE = "fileline" ) -const ( // aaa - ROLE = "role" - RIGHT = "right" - USERROLE = "userrole" - ROOT = "root" -) diff --git a/core/chat/action.go b/core/chat/action.go index 04046218..ee1d2948 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -185,7 +185,7 @@ func init() { "_share": {Name: "_share", Help: "共享", Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { return // 没有登录 } diff --git a/core/chat/cmd.go b/core/chat/cmd.go index 649fdcc9..c9954629 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -65,7 +65,7 @@ func init() { m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, k, mdb.NAME, "web.code.inner") } }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if strings.HasSuffix(m.R.URL.Path, ice.PS) { m.RenderCmd(CMD) return // 目录 @@ -101,7 +101,7 @@ func init() { m.ProcessLocation(nfs.PWD) } }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if _cmd_file(m, arg...) { return } diff --git a/core/chat/div.go b/core/chat/div.go index 93f59b0f..b02f17f6 100644 --- a/core/chat/div.go +++ b/core/chat/div.go @@ -31,7 +31,7 @@ func init() { nfs.TEMPLATE, _div_template, )}, }, Commands: map[string]*ice.Command{ - "/div/": {Name: "/div/", Help: "定制", Action: ice.MergeAction(ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/div/": {Name: "/div/", Help: "定制", Action: 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) @@ -65,7 +65,7 @@ func init() { } }) }}, - }, mdb.HashAction(), ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { switch kit.Ext(kit.Select("", arg, 0)) { case "shy": m.Fields(0) diff --git a/core/chat/files.go b/core/chat/files.go index 2e43861d..3207dd08 100644 --- a/core/chat/files.go +++ b/core/chat/files.go @@ -25,7 +25,7 @@ func init() { } m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, mdb.TYPE, kit.Ext(up[1]), mdb.NAME, up[1], nfs.SIZE, up[2], mdb.DATA, up[0]) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) m.Table(func(index int, value map[string]string, head []string) { link := web.SHARE_CACHE + value[mdb.DATA] diff --git a/core/chat/footer.go b/core/chat/footer.go index efc2cddc..9d28dfde 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -24,7 +24,7 @@ func init() { m.Set(ice.MSG_RESULT).Cmdy(cli.SYSTEM, arg) } }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { m.Confm(FOOTER, LEGAL, func(index int, value string) { m.Echo(value) }) }}, }}) diff --git a/core/chat/header.go b/core/chat/header.go index 39ffe436..498f8559 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -71,7 +71,7 @@ func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(aaa.LOGIN, kit.List("登录", "扫码"))}, }, Commands: map[string]*ice.Command{ - web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case "/sso": return @@ -105,7 +105,7 @@ func init() { } }}, aaa.LOGOUT: {Name: "logout", Help: "退出登录", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(aaa.SESS, mdb.REMOVE, ice.OptionHash(m.Option(ice.MSG_SESSID))) + m.Cmd(aaa.SESS, mdb.REMOVE, kit.Dict(mdb.HASH, m.Option(ice.MSG_SESSID))) }}, aaa.USERNICK: {Name: "usernick", Help: "用户昵称", Hand: func(m *ice.Message, arg ...string) { _header_users(m, m.ActionKey(), arg...) @@ -134,7 +134,7 @@ func init() { code.WEBPACK: {Name: "webpack", Help: "打包页面", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.WEBPACK, cli.BUILD, m.OptionSimple(mdb.NAME)) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME)) for _, k := range []string{aaa.LANGUAGE, aaa.BACKGROUND, aaa.AVATAR, aaa.USERNICK} { m.Option(k, msg.Append(k)) @@ -150,7 +150,7 @@ func init() { m.Option(GRANT, ice.TRUE) } - m.Option(TRANS, kit.Format(kit.Value(c.Commands[cmd].Meta, "_trans"))) + m.Option(TRANS, kit.Format(kit.Value(m.Target().Commands[m.CommandKey()].Meta, "_trans"))) m.Option(MENUS, m.Config(MENUS)) m.Echo(m.Config(TITLE)) // m.Cmdy(WEBSITE) @@ -159,7 +159,7 @@ func init() { GRANT: {Name: "grant space", Help: "授权", Hand: func(m *ice.Message, arg ...string) { _header_grant(m, arg...) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { }}, }}) diff --git a/core/chat/info.go b/core/chat/info.go index f0f49a03..f5611c60 100644 --- a/core/chat/info.go +++ b/core/chat/info.go @@ -13,7 +13,7 @@ func init() { 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) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.OptionFields(mdb.DETAIL) m.Cmdy(mdb.SELECT, RIVER, "", mdb.HASH, mdb.HASH, m.Option(ice.MSG_RIVER)) }}, diff --git a/core/chat/location.go b/core/chat/location.go index cf28419e..463a987f 100644 --- a/core/chat/location.go +++ b/core/chat/location.go @@ -41,7 +41,7 @@ func init() { OPENLOCATION: {Name: "location", Help: "地图"}, GETLOCATION: {Name: "location create", Help: "打卡"}, mdb.CREATE: {Name: "create type=text name text latitude longitude", Help: "添加"}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) m.PushAction(OPENLOCATION, mdb.REMOVE) }}, diff --git a/core/chat/meet.go b/core/chat/meet.go index 95fe842c..f52133df 100644 --- a/core/chat/meet.go +++ b/core/chat/meet.go @@ -19,7 +19,7 @@ func init() { }, 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{ mdb.CREATE: {Name: "create name 照片 性别 年龄 身高 体重 籍贯 户口 学历 学校 职业 公司 年薪 资产 家境", Help: "添加"}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { total := kit.Int(arg[0]) count := kit.Int(arg[1]) for i := 1; i <= total; i++ { @@ -40,7 +40,7 @@ func init() { }}, MISS: {Name: "miss name auto create", Help: "资料", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Action: ice.MergeAction(map[string]*ice.Action{ mdb.CREATE: {Name: "create name 照片 性别 年龄 身高 体重 籍贯 户口 学历 学校 职业 公司 年薪 资产 家境", Help: "添加"}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, 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) { value["照片"] = ice.Render(m, ice.RENDER_IMAGES, value["照片"], kit.Select("100", "400", msg.FieldsIsDetail())) diff --git a/core/chat/node.go b/core/chat/node.go index c4b881b8..676e0bd1 100644 --- a/core/chat/node.go +++ b/core/chat/node.go @@ -47,7 +47,7 @@ func init() { m.Option(web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, RIVER)) m.Cmdy(code.PUBLISH, ice.CONTEXTS, "tool") }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.OptionFields("time,type,name,share") m.Cmdy(mdb.SELECT, RIVER, _river_key(m, NODE), mdb.HASH) diff --git a/core/chat/oauth/oauth.go b/core/chat/oauth/oauth.go index c83a97e7..2d15faf1 100644 --- a/core/chat/oauth/oauth.go +++ b/core/chat/oauth/oauth.go @@ -81,7 +81,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string 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")}, - web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Action: ctx.CmdAction(), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Action: 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, c *ice.Context, cmd string, arg ...string) { + web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Action: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { if m.Option(OFFER) == "" { m.RenderStatusBadRequest() // 参数错误 @@ -97,7 +97,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string m.RenderCmd(m.Prefix(OAUTH), REPLY) } }}, - web.P(OFFER): {Name: "/offer access_token", Help: "访问", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + web.P(OFFER): {Name: "/offer access_token", Help: "访问", Hand: func(m *ice.Message, arg ...string) { if m.Option(ACCESS_TOKEN) == "" { m.RenderStatusBadRequest() // 参数错误 @@ -113,7 +113,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string 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")}, - web.P(AUTHORIZE): {Name: "/authorize state scope client_id redirect_uri", Help: "认证", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + 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) == "" { m.RenderStatusBadRequest() // 参数错误 @@ -127,7 +127,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string m.RenderRedirect(m.Option(REDIRECT_URI), CODE, m.Cmdx(TOKEN, mdb.CREATE, m.OptionSimple(STATE, SCOPE, REDIRECT_URI)), m.OptionSimple(STATE)) } }}, - web.P(TOKEN): {Name: "/token code redirect_uri", Help: "授权", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + web.P(TOKEN): {Name: "/token code redirect_uri", Help: "授权", Hand: func(m *ice.Message, arg ...string) { if m.Option(CODE) == "" || m.Option(REDIRECT_URI) == "" { m.RenderStatusBadRequest() // 参数错误 return @@ -153,7 +153,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string m.Cmdx(TOKEN, mdb.MODIFY, mdb.HASH, m.Option(CODE), USED, ice.TRUE) } }}, - web.P(USERINFO): {Name: "/userinfo Authorization", Help: "信息", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + web.P(USERINFO): {Name: "/userinfo Authorization", Help: "信息", Hand: func(m *ice.Message, arg ...string) { if ls := strings.SplitN(m.R.Header.Get(web.Authorization), ice.SP, 2); m.Warn(len(ls) != 2 || ls[1] == "", ice.ErrNotFound, web.Bearer) { m.RenderStatusBadRequest() // 参数错误 diff --git a/core/chat/ocean.go b/core/chat/ocean.go index 560bb751..85b12413 100644 --- a/core/chat/ocean.go +++ b/core/chat/ocean.go @@ -21,7 +21,7 @@ func init() { mdb.DELETE: {Name: "delete", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.DELETE, RIVER, _river_key(m, OCEAN), mdb.HASH, m.OptionSimple(aaa.USERNAME)) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, 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) { diff --git a/core/chat/paste.go b/core/chat/paste.go index bc31ebda..91ddeed7 100644 --- a/core/chat/paste.go +++ b/core/chat/paste.go @@ -21,7 +21,7 @@ func init() { m.Cmdy(PASTE, mdb.CREATE, arg) }}, mdb.CREATE: {Name: "create type=text name=hi text:textarea=hi", Help: "添加"}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) > 0 { m.PushScript(ssh.SCRIPT, m.Append(mdb.TEXT)) m.PushQRCode(cli.QRCODE, m.Append(mdb.TEXT)) diff --git a/core/chat/pod.go b/core/chat/pod.go index 7857a4aa..438163ed 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -22,7 +22,7 @@ func init() { "/pod/": {Name: "/pod/", Help: "节点", Action: ice.MergeAction(map[string]*ice.Action{ ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) { }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if strings.HasPrefix(m.R.Header.Get("User-Agent"), "curl") || strings.HasPrefix(m.R.Header.Get("User-Agent"), "Wget") { m.Option(ice.MSG_USERNAME, "root") m.Option(ice.MSG_USERROLE, "root") diff --git a/core/chat/river.go b/core/chat/river.go index fb6a6051..1ca92216 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -89,7 +89,7 @@ func init() { ), )) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, RIVER) { m.Render(web.STATUS, 401) return // 没有登录 diff --git a/core/chat/room.go b/core/chat/room.go index 302b2572..7148ee52 100644 --- a/core/chat/room.go +++ b/core/chat/room.go @@ -43,7 +43,7 @@ func init() { m.Cmdy(mdb.DELETE, m.Prefix(ROOM), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, m.OptionSimple(web.SPACE)) m.Cmdy(mdb.DELETE, m.Prefix(JOIN), kit.KeyHash(m.Option(web.SPACE)), mdb.HASH, m.OptionSimple(mdb.ZONE)) }}, - }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.ZoneSelect(m, arg...); len(arg) == 0 { m.Action(mdb.CREATE) m.PushAction(mdb.INSERT, JOIN) @@ -72,7 +72,7 @@ func init() { mdb.DELETE: {Name: "delete zone socket", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.DELETE, m.Prefix(JOIN), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, m.OptionSimple(web.SOCKET)) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { m.Fields(len(arg), "time,space", "time,zone") if len(arg) == 0 { m.Cmdy(mdb.SELECT, m.Prefix(JOIN), "", mdb.HASH) diff --git a/core/chat/scan.go b/core/chat/scan.go index f866fc3b..1b4cd992 100644 --- a/core/chat/scan.go +++ b/core/chat/scan.go @@ -22,7 +22,7 @@ func init() { "scanQRCode0": {Name: "scan create", Help: "本机扫码"}, "scanQRCode": {Name: "scan create", Help: "扫码"}, mdb.CREATE: {Name: "create type=text name=hi text:textarea=hi", Help: "添加"}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) > 0 { if m.Append(mdb.TYPE) == "image" { m.PushImages("image", m.Append(mdb.TEXT)) diff --git a/core/chat/search.go b/core/chat/search.go index 64e750f6..03df1909 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -25,7 +25,7 @@ func init() { mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(m.Space(m.Option(ice.POD)), mdb.RENDER, arg[1:]) }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if kit.Contains(arg[1], ";") { arg = kit.Split(arg[1], ";", ";", ";") } diff --git a/core/chat/sso.go b/core/chat/sso.go index 167c3906..3067f234 100644 --- a/core/chat/sso.go +++ b/core/chat/sso.go @@ -13,7 +13,7 @@ const SSO = "sso" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - "/sso": {Name: "/sso", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/sso": {Name: "/sso", Help: "登录", Hand: func(m *ice.Message, arg ...string) { if m.Option(ice.MSG_USERNAME) == "" { m.RenderIndex(web.SERVE, ice.VOLCANOS) return diff --git a/core/chat/storm.go b/core/chat/storm.go index cbc29283..90f42377 100644 --- a/core/chat/storm.go +++ b/core/chat/storm.go @@ -60,7 +60,7 @@ func init() { m.Cmdy(cmd, mdb.IMPORT) }}, SHARE: {Name: "share", Help: "共享", Hand: func(m *ice.Message, arg ...string) { _header_share(m, arg...) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { // 应用列表 m.OptionFields("time,hash,type,name,count") m.Cmdy(mdb.SELECT, RIVER, _river_key(m, STORM), mdb.HASH) diff --git a/core/chat/trans.go b/core/chat/trans.go index a9d26b4a..c457c253 100644 --- a/core/chat/trans.go +++ b/core/chat/trans.go @@ -39,7 +39,7 @@ func init() { m.PushAction(SEND, nfs.TRASH) } }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Cmdy(web.ROUTE).RenameAppend(web.ROUTE, FROM) return diff --git a/core/chat/website.go b/core/chat/website.go index 9d4303c5..b495d2bd 100644 --- a/core/chat/website.go +++ b/core/chat/website.go @@ -91,7 +91,7 @@ func _website_parse(m *ice.Message, text string, args ...string) (ice.Map, bool) case ctx.ARGS: data[ls[i]] = kit.Split(ls[i+1]) case ctx.DISPLAY: - data[ls[i]] = ice.DisplayRequire(1, ls[i+1])[ctx.DISPLAY] + data[ls[i]] = ice.Display(ls[i+1])[ctx.DISPLAY] case "title", "menus", "action", "style": data[ls[i]] = kit.UnMarshal(ls[i+1]) @@ -250,7 +250,7 @@ func init() { } }) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) { m.PushAnchor(m.MergeWebsite(value[nfs.PATH])) }) diff --git a/core/code/autogen.go b/core/code/autogen.go index 4e91d016..365136e2 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -213,7 +213,7 @@ func init() { m.Cmd(nfs.SAVE, path.Join(kit.Env(cli.HOME), ".ssh/"+m.Option(mdb.ALIAS)+".json"), kit.Formats(kit.Dict(m.OptionSimple("username,host,port,list")))) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, arg[0], kit.Dict(nfs.DIR_ROOT, ice.SRC)) }}, }}) diff --git a/core/code/bench.go b/core/code/bench.go index 95bab876..918b8a86 100644 --- a/core/code/bench.go +++ b/core/code/bench.go @@ -72,7 +72,7 @@ func init() { _bench_redis(m, m.Option(mdb.TEXT)) } }}, - }, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,nconn,nreqs")), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,nconn,nreqs")), Hand: func(m *ice.Message, arg ...string) { mdb.ZoneSelect(m, arg...).PushAction(kit.Select(mdb.REMOVE, ice.RUN, len(arg) > 0)) }}, }}) diff --git a/core/code/binpack.go b/core/code/binpack.go index d0be7246..72dc1433 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -178,7 +178,7 @@ func init() { m.Log_EXPORT(nfs.FILE, kit.WriteFile(key, value), nfs.SIZE, len(value)) } }}, - }, mdb.HashAction(mdb.SHORT, nfs.PATH)), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction(mdb.SHORT, nfs.PATH)), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { for k, v := range ice.Info.Pack { m.Push(nfs.PATH, k).Push(nfs.SIZE, len(v)) diff --git a/core/code/case.go b/core/code/case.go index 2695379e..1dec9104 100644 --- a/core/code/case.go +++ b/core/code/case.go @@ -60,7 +60,7 @@ func init() { m.Info(`curl "` + m.Option(cli.API) + `" -H "Content-Type: application/json"` + ` -d '` + m.Option(ice.ARG) + `'`) m.ProcessDisplay("/plugin/story/json.js") }}, - }, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,name,cmd,api,arg,res")), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,name,cmd,api,arg,res")), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Cmdy(web.SPIDE).RenameAppend("client.name", "dev", "client.url", "address").Action(mdb.CREATE) return @@ -102,7 +102,7 @@ func init() { } } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[0] == "" { m.Cmdy(nfs.DIR, nfs.PWD) return diff --git a/core/code/compile.go b/core/code/compile.go index a3e39b90..eeb807d8 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -68,7 +68,7 @@ func init() { RELAY: {Name: "relay", Help: "跳板", Hand: func(m *ice.Message, arg ...string) { m.Cmd(COMPILE, ice.SRC_RELAY_GO, path.Join(ice.USR_PUBLISH, RELAY)) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { // 下载依赖 _autogen_version(m.Spawn()) m.Cmd(cli.SYSTEM, GO, "get", "shylinux.com/x/ice") diff --git a/core/code/favor.go b/core/code/favor.go index f023d5a9..a85aded6 100644 --- a/core/code/favor.go +++ b/core/code/favor.go @@ -15,7 +15,7 @@ func init() { INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) { m.ProcessCommand(INNER, m.OptionSplit("path,file,line"), arg...) }}, - }, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line")), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line")), Hand: func(m *ice.Message, arg ...string) { mdb.ZoneSelect(m, arg...).PushAction(kit.Select(mdb.REMOVE, INNER, len(arg) > 0)) }}, }}) diff --git a/core/code/go.go b/core/code/go.go index 767c513e..63421520 100644 --- a/core/code/go.go +++ b/core/code/go.go @@ -224,7 +224,7 @@ const GODOC = "godoc" func init() { Index.Register(&ice.Context{Name: GO, Help: "后端", Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + 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)) diff --git a/core/code/inner.go b/core/code/inner.go index bb78a9cd..e9bfda65 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -167,7 +167,7 @@ func init() { _inner_make(m, m.Cmd(cli.SYSTEM, cli.MAKE, arg)) }}, FAVOR: {Name: "favor", Help: "收藏"}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if arg[0] = strings.Split(arg[0], ice.FS)[0]; !strings.HasSuffix(arg[0], ice.PS) { arg[1] = kit.Slice(strings.Split(arg[0], ice.PS), -1)[0] arg[0] = strings.TrimSuffix(arg[0], arg[1]) diff --git a/core/code/install.go b/core/code/install.go index 27ca79ed..726c9db6 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -118,6 +118,8 @@ func _install_start(m *ice.Message, arg ...string) { args = append(args, cb(p)...) case func(string): cb(p) + default: + m.Error(true, ice.ErrNotImplement) } if m.Cmdy(cli.DAEMON, arg[1:], args); cli.IsSuccess(m) { @@ -186,7 +188,7 @@ func init() { cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) { _install_stop(m, arg...) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { switch len(arg) { case 0: // 源码列表 mdb.HashSelect(m, arg...) @@ -203,7 +205,7 @@ func init() { } func InstallAction(args ...ice.Any) map[string]*ice.Action { - return ice.SelectAction(map[string]*ice.Action{ice.CTX_INIT: mdb.AutoConfig(args...), + return map[string]*ice.Action{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)) }}, @@ -216,7 +218,7 @@ func InstallAction(args ...ice.Any) map[string]*ice.Action { nfs.TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmd(nfs.TRASH, m.Option(nfs.PATH)) }}, - }) + } } func InstallSoftware(m *ice.Message, bin string, list ice.Any) (ok bool) { if cli.SystemFind(m, bin) != "" { diff --git a/core/code/oauth.go b/core/code/oauth.go index e4563ba4..4107b5d7 100644 --- a/core/code/oauth.go +++ b/core/code/oauth.go @@ -55,13 +55,13 @@ func init() { m.Push("", res) m.Echo("https://github.com/settings/keys") }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...).PushAction("user", "public", ACCESS_TOKEN, mdb.REMOVE); len(arg) == 0 { m.Action(mdb.CREATE) m.Echo(kit.MergeURL2(LOGIN_OAUTH, "authorize", m.ConfigSimple(REDIRECT_URI, CLIENT_ID), "scope", "read:user read:public_key write:public_key repo")) } }}, - "/oauth": {Name: "/oauth", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/oauth": {Name: "/oauth", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if m.Option(CODE) != "" { m.RenderCmd(m.PrefixKey(), m.Cmdx(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(CODE))) } diff --git a/core/code/pprof.go b/core/code/pprof.go index 27279362..0c0880c5 100644 --- a/core/code/pprof.go +++ b/core/code/pprof.go @@ -65,7 +65,7 @@ func init() { m.Cmd(cli.DAEMON, m.Configv(PPROF), "-http="+p, m.Option(BINNARY), m.Option(nfs.FILE)) m.Echo("http://%s/ui/top", p).ProcessInner() }}, - }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { m.Fields(len(arg), "time,zone,count,binnary,service,seconds", m.Config(mdb.FIELD)) if mdb.ZoneSelect(m, arg...); len(arg) == 0 { m.PushAction(ice.RUN, mdb.REMOVE) @@ -78,7 +78,7 @@ func init() { m.PushButton(web.SERVE) }) }}, - "/pprof/": {Name: "/pprof/", Help: "性能分析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/pprof/": {Name: "/pprof/", Help: "性能分析", Hand: func(m *ice.Message, arg ...string) { defer m.Render(ice.RENDER_VOID) m.R.URL.Path = "/debug" + m.R.URL.Path http.DefaultServeMux.ServeHTTP(m.W, m.R) diff --git a/core/code/publish.go b/core/code/publish.go index ed58471c..ad25ced9 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -143,7 +143,7 @@ func init() { m.Cmd(nfs.TAR, kit.Path(ice.USR_PUBLISH, "contexts.home.tar.gz"), ".vim/plugged", kit.Dict(nfs.DIR_ROOT, kit.Env(cli.HOME))) m.Cmd("web.code.git.server", mdb.IMPORT) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Option(nfs.DIR_ROOT, m.Config(nfs.PATH)) m.Cmdy(nfs.DIR, kit.Select("", arg, 0), nfs.DIR_WEB_FIELDS) }}, diff --git a/core/code/py.go b/core/code/py.go index 140b4de5..3d9eddef 100644 --- a/core/code/py.go +++ b/core/code/py.go @@ -38,7 +38,7 @@ func init() { mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _py_main_script(m, arg...) }}, - }, PlugAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, PlugAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && kit.Ext(arg[0]) == PY { _py_main_script(m, PY, arg[0], ice.SRC) return diff --git a/core/code/sh.go b/core/code/sh.go index bc7df135..5b722770 100644 --- a/core/code/sh.go +++ b/core/code/sh.go @@ -82,7 +82,7 @@ func init() { mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { _sh_main_script(m, arg...) }}, - }, PlugAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, PlugAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && kit.Ext(arg[0]) == SH { _sh_main_script(m, SH, arg[0], ice.SRC) return diff --git a/core/code/shy.go b/core/code/shy.go index ab315804..e0204046 100644 --- a/core/code/shy.go +++ b/core/code/shy.go @@ -54,7 +54,7 @@ func init() { _go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2]) } }}, - }, PlugAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, PlugAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() { m.Cmdy("web.wiki.word", path.Join(ice.SRC, arg[0])) return diff --git a/core/code/template.go b/core/code/template.go index ef6dd435..2fd4ac09 100644 --- a/core/code/template.go +++ b/core/code/template.go @@ -34,7 +34,7 @@ func init() { } } }}, - }, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,args")), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,args")), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...).Sort(mdb.NAME); len(arg) == 0 { m.Cut("time,action,type,name,text,args") m.Action(mdb.CREATE) diff --git a/core/code/upgrade.go b/core/code/upgrade.go index 21b2b5bb..cb5be301 100644 --- a/core/code/upgrade.go +++ b/core/code/upgrade.go @@ -27,8 +27,8 @@ func init() { cli.RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) { m.Sleep("1s").Go(func() { m.Cmd(ice.EXIT, 1) }) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Grows(cmd, kit.Keys(mdb.HASH, kit.Select(cli.SYSTEM, arg, 0)), "", "", func(index int, value ice.Map) { + }, Hand: func(m *ice.Message, arg ...string) { + m.Grows(m.CommandKey(), kit.Keys(mdb.HASH, kit.Select(cli.SYSTEM, arg, 0)), "", "", func(index int, value ice.Map) { if value[nfs.FILE] == ice.ICE_BIN { // 程序文件 value[nfs.FILE] = kit.Keys(ice.ICE, runtime.GOOS, runtime.GOARCH) defer m.Cmd(cli.SYSTEM, "mv", value[nfs.FILE], ice.BIN_ICE_BIN) diff --git a/core/code/vimer.go b/core/code/vimer.go index 5d7a42b3..55aadfbe 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -209,6 +209,6 @@ func init() { m.ProcessInner() m.ToastSuccess() }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Cmdy(INNER, arg) }}, + }, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INNER, arg) }}, }}) } diff --git a/core/code/webpack.go b/core/code/webpack.go index cad52ca1..7ba46a8f 100644 --- a/core/code/webpack.go +++ b/core/code/webpack.go @@ -151,7 +151,7 @@ func init() { _webpack_cache(m.Spawn(), _volcanos(m), true) _webpack_build(m, _publish(m, WEBPACK, m.Option(mdb.NAME))) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Option(nfs.DIR_DEEP, true) m.Option(nfs.DIR_TYPE, nfs.CAT) m.OptionFields(nfs.DIR_WEB_FIELDS) diff --git a/core/mall/asset.go b/core/mall/asset.go index e2d3cce7..785f8216 100644 --- a/core/mall/asset.go +++ b/core/mall/asset.go @@ -91,7 +91,7 @@ func init() { } m.Toast("核算成功") }}, - }, mdb.ZoneAction(), ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { m.Fields(len(arg), "time,account,amount,count", m.Config(mdb.FIELD)) amount, count := 0, 0 if mdb.ZoneSelect(m, arg...); len(arg) == 0 { diff --git a/core/mall/salary.go b/core/mall/salary.go index 9239cdf6..55efa21a 100644 --- a/core/mall/salary.go +++ b/core/mall/salary.go @@ -21,7 +21,7 @@ func init() { }, Commands: map[string]*ice.Command{ SALARY: {Name: "salary month auto create", Help: "工资", Action: ice.MergeAction(map[string]*ice.Action{ mdb.CREATE: {Name: "create month company amount income tax 公积金 养老保险 医疗保险 生育保险 工伤保险 失业保险 企业公积金 企业养老保险 企业医疗保险 企业生育保险 企业工伤保险 企业失业保险", Help: "添加"}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, 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) { diff --git a/core/team/count.go b/core/team/count.go index 92641e34..c3b84bb4 100644 --- a/core/team/count.go +++ b/core/team/count.go @@ -19,7 +19,7 @@ func init() { 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) }}, - }, TASK), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, TASK), Hand: func(m *ice.Message, arg ...string) { begin_time, end_time := _plan_scope(m, 8, append([]string{LONG}, arg...)...) msg := _plan_list(m.Spawn(), begin_time, end_time) msg.SortTime(BEGIN_TIME) diff --git a/core/team/plan.go b/core/team/plan.go index 3a84468b..13c52018 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -90,11 +90,11 @@ func init() { msg := m.Cmd(TASK, arg[0], arg[1]) m.Cmdy(kit.Simple(kit.Keys(msg.Append(kit.KeyExtra(ice.CTX)), msg.Append(kit.KeyExtra(ice.CMD))), arg[2:])) }}, - }, TASK), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, TASK), Hand: func(m *ice.Message, arg ...string) { arg = kit.Slice(arg, 0, 2) begin_time, end_time := _plan_scope(m, 8, arg...) _plan_list(m, begin_time, end_time) - m.PushPodCmd(cmd, arg...) + m.PushPodCmd(m.CommandKey(), arg...) }}, }}) } diff --git a/core/team/task.go b/core/team/task.go index 327f944a..380f9c46 100644 --- a/core/team/task.go +++ b/core/team/task.go @@ -93,7 +93,7 @@ func init() { END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }}, - }, mdb.ZoneAction(), ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, 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) { diff --git a/core/team/todo.go b/core/team/todo.go index 79a34aa2..35e76a20 100644 --- a/core/team/todo.go +++ b/core/team/todo.go @@ -20,10 +20,10 @@ func init() { m.Cmd(TASK, mdb.INSERT, m.OptionSimple("zone,type,name,text"), BEGIN_TIME, m.Time()) m.Cmd(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(mdb.HASH)) }}, - }, mdb.HashAction(mdb.FIELD, "time,hash,zone,name,text")), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction(mdb.FIELD, "time,hash,zone,name,text")), Hand: func(m *ice.Message, arg ...string) { m.Display("/plugin/table.js", "style", "card") mdb.HashSelect(m, arg...).PushAction(cli.START, mdb.REMOVE) - m.PushPodCmd(cmd, arg...) + m.PushPodCmd(m.CommandKey(), arg...) }}, }}) } diff --git a/core/wiki/brief.go b/core/wiki/brief.go index 9fb0f7fb..d2b12057 100644 --- a/core/wiki/brief.go +++ b/core/wiki/brief.go @@ -10,8 +10,8 @@ const BRIEF = "brief" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - BRIEF: {Name: "brief text", Help: "摘要", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - _wiki_template(m, cmd, "", arg[0], arg[1:]...) + 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{ BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data(nfs.TEMPLATE, `
{{.Option "text"}}
`)}, diff --git a/core/wiki/chart.go b/core/wiki/chart.go index be7e54a9..8cfac2a8 100644 --- a/core/wiki/chart.go +++ b/core/wiki/chart.go @@ -183,7 +183,7 @@ const CHART = "chart" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - CHART: {Name: "chart type=label,chain,sequence auto text", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + 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:]...) } diff --git a/core/wiki/data.go b/core/wiki/data.go index 0e2270ea..43eff085 100644 --- a/core/wiki/data.go +++ b/core/wiki/data.go @@ -17,7 +17,7 @@ func init() { nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, m.CommandKey(), arg[0], arg[1]) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if !_wiki_list(m, m.CommandKey(), kit.Select(nfs.PWD, arg, 0)) { m.CSV(m.Cmd(nfs.CAT, arg[0]).Result()) } diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 09e4c267..127b7027 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -29,7 +29,7 @@ func init() { nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, DRAW, arg[0], m.Option("content")) }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if !_wiki_list(m, DRAW, kit.Select(nfs.PWD, arg, 0)) { _wiki_show(m, DRAW, arg[0]) } diff --git a/core/wiki/feel.go b/core/wiki/feel.go index 6b379ffc..bdabb77b 100644 --- a/core/wiki/feel.go +++ b/core/wiki/feel.go @@ -27,7 +27,7 @@ func init() { m.Debug("remove %v", p) os.Remove(p) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { _wiki_list(m, m.CommandKey(), kit.Select(nfs.PWD, arg, 0)) }}, }}) diff --git a/core/wiki/field.go b/core/wiki/field.go index c4dd59f5..1a6d5d18 100644 --- a/core/wiki/field.go +++ b/core/wiki/field.go @@ -126,7 +126,7 @@ func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ FIELD: {Name: "field [name] cmd", Help: "插件", Action: ice.MergeAction(map[string]*ice.Action{ ice.RUN: {Name: "run", Help: "执行"}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { if arg = _name(m, arg); strings.Contains(arg[1], ice.NL) { arg = kit.Simple(arg[0], "web.chat.div", "auto.cmd", "split", "opts.text", arg[1], arg[2:]) } diff --git a/core/wiki/image.go b/core/wiki/image.go index 92bbec07..05d823d8 100644 --- a/core/wiki/image.go +++ b/core/wiki/image.go @@ -30,7 +30,7 @@ func init() { mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { _image_show(m, path.Join(arg[2], arg[1])) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { return } diff --git a/core/wiki/local.go b/core/wiki/local.go index 1a0d2ba4..64fc65f0 100644 --- a/core/wiki/local.go +++ b/core/wiki/local.go @@ -15,7 +15,7 @@ const LOCAL = "local" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - LOCAL: {Name: "local [name] file", Help: "文件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + LOCAL: {Name: "local [name] file", Help: "文件", Hand: func(m *ice.Message, arg ...string) { arg = _name(m, arg) _local_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) }}, diff --git a/core/wiki/order.go b/core/wiki/order.go index 370508d3..2ab0d10a 100644 --- a/core/wiki/order.go +++ b/core/wiki/order.go @@ -18,7 +18,7 @@ const ORDER = "order" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - ORDER: {Name: "order `[item\n]...`", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + ORDER: {Name: "order `[item\n]...`", Help: "列表", Hand: func(m *ice.Message, arg ...string) { _order_show(m, arg[0], arg[1:]...) }}, }, Configs: map[string]*ice.Config{ diff --git a/core/wiki/parse.go b/core/wiki/parse.go index 8ea55e7e..39713df2 100644 --- a/core/wiki/parse.go +++ b/core/wiki/parse.go @@ -20,7 +20,7 @@ const PARSE = "parse" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - PARSE: {Name: "parse type=auto,base64,json,http,form,time,list auto text", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + PARSE: {Name: "parse type=auto,base64,json,http,form,time,list auto text", Help: "解析", Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 { return } diff --git a/core/wiki/refer.go b/core/wiki/refer.go index c961a374..e44458fc 100644 --- a/core/wiki/refer.go +++ b/core/wiki/refer.go @@ -27,7 +27,7 @@ const REFER = "refer" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - REFER: {Name: "refer `[[name] url\n]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + REFER: {Name: "refer `[[name] url\n]...`", Help: "参考", Hand: func(m *ice.Message, arg ...string) { _refer_show(m, arg[0], arg[1:]...) }}, }, Configs: map[string]*ice.Config{ diff --git a/core/wiki/shell.go b/core/wiki/shell.go index 0a7da73f..68d7a09a 100644 --- a/core/wiki/shell.go +++ b/core/wiki/shell.go @@ -20,7 +20,7 @@ const SHELL = "shell" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, arg ...string) { arg = _name(m, arg) _shell_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) }}, diff --git a/core/wiki/spark.go b/core/wiki/spark.go index 4931f7a2..34f68483 100644 --- a/core/wiki/spark.go +++ b/core/wiki/spark.go @@ -112,7 +112,7 @@ func init() { }) text() }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Echo(`