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(`hello`) 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(`
`) return diff --git a/core/wiki/table.go b/core/wiki/table.go index e75f034a..f51934f2 100644 --- a/core/wiki/table.go +++ b/core/wiki/table.go @@ -66,7 +66,7 @@ func init() { ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { _table_run(m, arg...) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { _table_show(m, arg[0], arg[1:]...) }}, }, Configs: map[string]*ice.Config{ diff --git a/core/wiki/title.go b/core/wiki/title.go index a950797d..4316461b 100644 --- a/core/wiki/title.go +++ b/core/wiki/title.go @@ -78,7 +78,7 @@ const TITLE = "title" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TITLE: {Name: "title [navmenu|premenu|chapter|section|endmenu] text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + TITLE: {Name: "title [navmenu|premenu|chapter|section|endmenu] text", Help: "标题", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { arg = append(arg, kit.Slice(kit.Split(ice.Info.NodeName, "-"), -1)[0]) } diff --git a/core/wiki/video.go b/core/wiki/video.go index 25e632f8..58398b18 100644 --- a/core/wiki/video.go +++ b/core/wiki/video.go @@ -27,7 +27,7 @@ func init() { mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { _video_show(m, path.Join(arg[2], arg[1])) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { _video_show(m, arg[0], arg[1:]...) }}, }, Configs: map[string]*ice.Config{ diff --git a/core/wiki/word.go b/core/wiki/word.go index f9b32750..e37a7927 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -80,9 +80,9 @@ func init() { m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:]) }}, ice.PLAY: {Name: "play", Help: "演示"}, - }, ctx.CmdAction(), mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, ctx.CmdAction(), mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { m.Option(nfs.DIR_REG, m.Config(lex.REGEXP)) - if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, cmd, arg...) { + if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, m.CommandKey(), arg...) { if !kit.FileExists(arg[0]) && kit.FileExists(path.Join("src", arg[0])) { arg[0] = path.Join("src/", arg[0]) } diff --git a/exec.go b/exec.go index 070ec08c..d3d32377 100644 --- a/exec.go +++ b/exec.go @@ -48,7 +48,7 @@ func (m *Message) Assert(expr Any) bool { default: expr = errors.New(kit.Format("error: %v", expr)) } - m.Result(ErrPanic, expr) + m.Result(ErrWarn, expr) panic(expr) } func (m *Message) Sleep(d string, arg ...Any) *Message { @@ -89,7 +89,7 @@ func (m *Message) Call(sync bool, cb func(*Message) *Message) *Message { p := kit.Select("10s", m.Option("timeout")) t := time.AfterFunc(kit.Duration(p), func() { - m.Warn(true, ErrTimeout, m.Detailv()) + m.Warn(true, ErrExpire, m.Detailv()) m.Back(nil) wait <- false }) @@ -125,6 +125,8 @@ func (m *Message) Go(cb Any) *Message { cb(m.Spawn()) case func(): cb() + default: + m.Error(true, ErrNotImplement) } }) return nil diff --git a/info.go b/info.go index 00d414cd..64df8ade 100644 --- a/info.go +++ b/info.go @@ -37,6 +37,7 @@ var Info = struct { CtxRiver string Help string + cans string Route map[string]string // 路由命令 File map[string]string // 文件命令 Pack map[string][]byte // 打包文件 @@ -53,6 +54,17 @@ var Info = struct { report: shylinuxc@gmail.com server: https://shylinux.com source: https://shylinux.com/x/icebergs +`, + cans: ` + + + + + + + + + `, Route: map[string]string{}, File: map[string]string{}, diff --git a/init.go b/init.go index e05e72f5..385267ff 100644 --- a/init.go +++ b/init.go @@ -56,39 +56,40 @@ func (f *Frame) Close(m *Message, arg ...string) bool { var Index = &Context{Name: ICE, Help: "冰山模块", Configs: map[string]*Config{ HELP: {Value: kit.Data(INDEX, Info.Help)}, }, Commands: map[string]*Command{ - CTX_INIT: {Hand: func(m *Message, c *Context, cmd string, arg ...string) { + CTX_INIT: {Hand: func(m *Message, arg ...string) { defer m.Cost(CTX_INIT) m.root.Travel(func(p *Context, c *Context) { if cmd, ok := c.Commands[CTX_INIT]; ok && p != nil { - c.cmd(m.Spawn(c), cmd, CTX_INIT, arg...) + c._command(m.Spawn(c), cmd, CTX_INIT, arg...) } }) }}, - INIT: {Name: "init", Help: "启动", Hand: func(m *Message, c *Context, cmd string, arg ...string) { + INIT: {Name: "init", Help: "启动", Hand: func(m *Message, arg ...string) { m.root.Cmd(CTX_INIT) m.Cmd(SOURCE, ETC_INIT_SHY) }}, - HELP: {Name: "help", Help: "帮助", Hand: func(m *Message, c *Context, cmd string, arg ...string) { + HELP: {Name: "help", Help: "帮助", Hand: func(m *Message, arg ...string) { m.Echo(m.Config(INDEX)) }}, - EXIT: {Name: "exit", Help: "结束", Hand: func(m *Message, c *Context, cmd string, arg ...string) { + EXIT: {Name: "exit", Help: "结束", Hand: func(m *Message, arg ...string) { m.root.Option(EXIT, kit.Select("0", arg, 0)) - defer c.Close(m.root.Spawn(), arg...) + defer m.Target().Close(m.root.Spawn(), arg...) m.Cmd(SOURCE, ETC_EXIT_SHY) m.root.Cmd(CTX_EXIT) }}, - CTX_EXIT: {Hand: func(m *Message, c *Context, cmd string, arg ...string) { + CTX_EXIT: {Hand: func(m *Message, arg ...string) { defer m.Cost(CTX_EXIT) m.Option("cmd_dir", "") m.Option("dir_root", "") m.root.Travel(func(p *Context, c *Context) { if cmd, ok := c.Commands[CTX_EXIT]; ok && p != nil { m.TryCatch(m.Spawn(c), true, func(msg *Message) { - c.cmd(msg, cmd, CTX_EXIT, arg...) + c._command(msg, cmd, CTX_EXIT, arg...) }) } }) + _exit <- kit.Int(m.Option(EXIT)) }}, }, server: &Frame{}, wg: &sync.WaitGroup{}} var Pulse = &Message{time: time.Now(), code: 0, @@ -96,6 +97,8 @@ var Pulse = &Message{time: time.Now(), code: 0, source: Index, target: Index, Hand: true, } +var _exit = make(chan int, 1) + func init() { Index.root, Pulse.root = Index, Pulse } func Run(arg ...string) string { @@ -127,7 +130,7 @@ func Run(arg ...string) string { } if log.LogDisable = false; Index.Start(Pulse, arg...) { Pulse.TryCatch(Pulse, true, func(Pulse *Message) { Index.wg.Wait() }) - os.Exit(kit.Int(Pulse.Option(EXIT))) + os.Exit(<-_exit) } default: // 执行命令 if len(arg) == 0 { diff --git a/logs.go b/logs.go index aa68bea5..dff5733f 100644 --- a/logs.go +++ b/logs.go @@ -230,3 +230,8 @@ func (m *Message) FormatChain() string { } return kit.Join(meta, NL) } + +func (m *Message) IsErr(arg ...string) bool { + return len(arg) > 0 && m.Result(1) == arg[0] || m.Result(0) == ErrWarn +} +func (m *Message) IsErrNotFound() bool { return m.Result(1) == ErrNotFound } diff --git a/misc.go b/misc.go index 2dca606a..4853c011 100644 --- a/misc.go +++ b/misc.go @@ -3,7 +3,6 @@ package ice import ( "bytes" "encoding/csv" - "path" "reflect" "strings" @@ -82,12 +81,6 @@ func (m *Message) PushRecord(value Any, arg ...string) *Message { return m.Push("", value, kit.Split(kit.Join(arg))) } -func (m *Message) OptionCB(key string, cb ...Any) Any { - if len(cb) > 0 { - return m.Optionv(kit.Keycb(key), cb...) - } - return m.Optionv(kit.Keycb(key)) -} func (m *Message) ToLowerAppend(arg ...string) *Message { for _, k := range m.meta[MSG_APPEND] { m.RenameAppend(k, strings.ToLower(k)) @@ -144,14 +137,32 @@ func (m *Message) SetResult(arg ...string) *Message { return m.Set(MSG_RESULT, arg...) } -func (m *Message) IsErr(arg ...string) bool { - return len(arg) > 0 && m.Result(1) == arg[0] || m.Result(0) == ErrWarn +func (m *Message) Design(action Any, help string, input ...Any) { + list := kit.List() + for _, input := range input { + switch input := input.(type) { + case string: + list = append(list, SplitCmd("action "+input)...) + case Map: + if kit.Format(input[TYPE]) != "" && kit.Format(input[NAME]) != "" { + list = append(list, input) + continue + } + kit.Fetch(kit.KeyValue(nil, "", input), func(k string, v Any) { + list = append(list, kit.Dict(NAME, k, TYPE, "text", VALUE, v)) + }) + default: + m.Error(true, ErrNotImplement) + } + } + k := kit.Format(action) + if a, ok := m._cmd.Action[k]; ok { + m._cmd.Meta[k], a.List = list, list + kit.Value(m._cmd.Meta, kit.Keys("_trans", k), help) + } } -func (m *Message) IsErrNotFound() bool { return m.Result(1) == ErrNotFound } - -func (m *Message) cmd(arg ...Any) *Message { - opts := Map{} - args := []Any{} +func (m *Message) _command(arg ...Any) *Message { + args, opts := []Any{}, Map{} var cbs Any // 解析参数 @@ -175,7 +186,7 @@ func (m *Message) cmd(arg ...Any) *Message { case func(int, map[string]string, []string): defer func() { m.Table(val) }() default: - if reflect.Func == reflect.TypeOf(val).Kind() { + if reflect.TypeOf(val).Kind() == reflect.Func { cbs = val } else { args = append(args, v) @@ -203,7 +214,7 @@ func (m *Message) cmd(arg ...Any) *Message { // 执行命令 key = kit.Slice(strings.Split(key, PT), -1)[0] - m.TryCatch(msg, true, func(msg *Message) { m = ctx.cmd(msg, cmd, key, arg...) }) + m.TryCatch(msg, true, func(msg *Message) { m = ctx._command(msg, cmd, key, arg...) }) } // 查找命令 @@ -222,26 +233,20 @@ func (m *Message) cmd(arg ...Any) *Message { m.Warn(!ok, ErrNotFound, kit.Format(list)) return m } -func (c *Context) PrefixKey(arg ...string) string { - return kit.Keys(c.Cap(CTX_FOLLOW), arg) -} -func (c *Context) RoutePath(arg ...string) string { - return path.Join(strings.TrimPrefix(strings.ReplaceAll(c.Cap(CTX_FOLLOW), PT, PS), "web"), path.Join(arg...)) -} -func (c *Context) cmd(m *Message, cmd *Command, key string, arg ...string) *Message { +func (c *Context) _command(m *Message, cmd *Command, key string, arg ...string) *Message { if m._key, m._cmd = key, cmd; cmd == nil { return m } - - m.meta[MSG_DETAIL] = kit.Simple(key, arg) - if m.Hand = true; len(arg) > 1 && arg[0] == ACTION && cmd.Action != nil { - if h, ok := cmd.Action[arg[1]]; ok { - return c._cmd(m, cmd, key, arg[1], h, arg[2:]...) + if m.Hand, m.meta[MSG_DETAIL] = true, kit.Simple(key, arg); cmd.Action != nil { + if len(arg) > 1 && arg[0] == ACTION { + if h, ok := cmd.Action[arg[1]]; ok { + return c._action(m, cmd, key, arg[1], h, arg[2:]...) + } } - } - if len(arg) > 0 && arg[0] != COMMAND && cmd.Action != nil { - if h, ok := cmd.Action[arg[0]]; ok { - return c._cmd(m, cmd, key, arg[0], h, arg[1:]...) + if len(arg) > 0 && arg[0] != COMMAND { + if h, ok := cmd.Action[arg[0]]; ok { + return c._action(m, cmd, key, arg[0], h, arg[1:]...) + } } } @@ -249,19 +254,18 @@ func (c *Context) cmd(m *Message, cmd *Command, key string, arg ...string) *Mess kit.Select(kit.FileLine(cmd.Hand, 3), kit.FileLine(9, 3), m.target.Name == MDB)) if cmd.Hand != nil { - cmd.Hand(m, c, key, arg...) + cmd.Hand(m, arg...) } else if cmd.Action != nil && cmd.Action["select"] != nil { cmd.Action["select"].Hand(m, arg...) } return m } -func (c *Context) _cmd(m *Message, cmd *Command, key string, sub string, h *Action, arg ...string) *Message { +func (c *Context) _action(m *Message, cmd *Command, key string, sub string, h *Action, arg ...string) *Message { if h.Hand == nil { m.Cmdy(kit.Split(h.Name), arg) return m } - m.Log(LOG_CMDS, "%s.%s %s %d %v %s", c.Name, key, sub, len(arg), arg, kit.FileLine(h.Hand, 3)) if m._sub = sub; len(h.List) > 0 && sub != "search" { order := false for i, v := range h.List { @@ -284,54 +288,62 @@ func (c *Context) _cmd(m *Message, cmd *Command, key string, sub string, h *Acti } } + m.Log(LOG_CMDS, "%s.%s %s %d %v %s", c.Name, key, sub, len(arg), arg, kit.FileLine(h.Hand, 3)) h.Hand(m, arg...) return m } + func SplitCmd(name string) (list []Any) { const ( TEXT = "text" - ARGS = "args" TEXTAREA = "textarea" PASSWORD = "password" SELECT = "select" BUTTON = "button" ) + const ( + RUN = "run" + LIST = "list" + BACK = "back" + AUTO = "auto" + PAGE = "page" + ARGS = "args" + ) item, button := kit.Dict(), false ls := kit.Split(name, SP, ":=@") for i := 1; i < len(ls); i++ { switch ls[i] { - case "run": - item = kit.Dict(TYPE, BUTTON, NAME, "run") - list = append(list, item) + case RUN: + list = append(list, kit.Dict(TYPE, BUTTON, NAME, RUN)) button = true - case "list": - list = append(list, kit.List(TYPE, BUTTON, NAME, "list", ACTION, AUTO)...) + case LIST: + list = append(list, kit.Dict(TYPE, BUTTON, NAME, LIST, ACTION, AUTO)) button = true - case "auto": - list = append(list, kit.List(TYPE, BUTTON, NAME, "list", ACTION, AUTO)...) - list = append(list, kit.List(TYPE, BUTTON, NAME, "back")...) + case AUTO: + list = append(list, kit.Dict(TYPE, BUTTON, NAME, LIST, ACTION, AUTO)) + list = append(list, kit.Dict(TYPE, BUTTON, NAME, BACK)) button = true - case "page": - list = append(list, kit.List(TYPE, TEXT, NAME, "limit")...) - list = append(list, kit.List(TYPE, TEXT, NAME, "offend")...) - list = append(list, kit.List(TYPE, BUTTON, NAME, "prev")...) - list = append(list, kit.List(TYPE, BUTTON, NAME, "next")...) - case "text", "args": + case PAGE: + list = append(list, kit.Dict(TYPE, TEXT, NAME, "limit")) + list = append(list, kit.Dict(TYPE, TEXT, NAME, "offend")) + list = append(list, kit.Dict(TYPE, BUTTON, NAME, "prev")) + list = append(list, kit.Dict(TYPE, BUTTON, NAME, "next")) + case ARGS, TEXT, TEXTAREA: item = kit.Dict(TYPE, TEXTAREA, NAME, ls[i]) list = append(list, item) - case "password": + case PASSWORD: item = kit.Dict(TYPE, PASSWORD, NAME, ls[i]) list = append(list, item) - case ":": + case DF: if item[TYPE] = kit.Select("", ls, i+1); item[TYPE] == BUTTON { button = true } i++ - case "=": - if value := kit.Select("", ls, i+1); strings.Contains(value, ",") { + case EQ: + if value := kit.Select("", ls, i+1); strings.Contains(value, FS) { vs := kit.Split(value) if strings.Count(value, vs[0]) > 1 { item["values"] = vs[1:] @@ -344,7 +356,7 @@ func SplitCmd(name string) (list []Any) { item[VALUE] = value } i++ - case "@": + case AT: item[ACTION] = kit.Select("", ls, i+1) i++ @@ -355,39 +367,15 @@ func SplitCmd(name string) (list []Any) { } return list } -func (m *Message) Design(action Any, help string, input ...Any) { - list := kit.List() - for _, input := range input { - switch input := input.(type) { - case string: - list = append(list, SplitCmd("action "+input)...) - case Map: - if kit.Format(input[TYPE]) != "" && kit.Format(input[NAME]) != "" { - list = append(list, input) - continue - } - kit.Fetch(kit.KeyValue(nil, "", input), func(k string, v Any) { - list = append(list, kit.Dict(NAME, k, TYPE, "text", VALUE, v)) - }) - } - } - k := kit.Format(action) - if a, ok := m._cmd.Action[k]; ok { - a.List = list - m._cmd.Meta[k] = list - kit.Value(m._cmd.Meta, kit.Keys("_trans", k), help) - } -} - func MergeAction(list ...Any) map[string]*Action { if len(list) == 0 { return nil } base := list[0].(map[string]*Action) - for _, item := range list[1:] { - switch item := item.(type) { + for _, from := range list[1:] { + switch from := from.(type) { case map[string]*Action: - for k, v := range item { + for k, v := range from { if h, ok := base[k]; !ok { base[k] = v } else if h.Hand == nil { @@ -403,23 +391,14 @@ func MergeAction(list ...Any) map[string]*Action { } case string: base[CTX_INIT] = &Action{Hand: func(m *Message, arg ...string) { - m.Search(item, func(p *Context, s *Context, key string, cmd *Command) { + m.Search(from, func(p *Context, s *Context, key string, cmd *Command) { MergeAction(base, cmd.Action) m.target.Merge(m.target) }) }} + default: + Pulse.Error(true, ErrNotImplement) } } return base } -func SelectAction(list map[string]*Action, fields ...string) map[string]*Action { - if len(fields) == 0 { - return list - } - - res := map[string]*Action{} - for _, field := range fields { - res[field] = list[field] - } - return res -} diff --git a/misc/bash/bash.go b/misc/bash/bash.go index f5bb6727..e23de53a 100644 --- a/misc/bash/bash.go +++ b/misc/bash/bash.go @@ -20,7 +20,7 @@ var Index = &ice.Context{Name: BASH, Help: "命令行", Configs: map[string]*ice cli.ORDER: {Name: "order", Help: "加载", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, cli.ORDER, m.Config(nfs.SOURCE), "_install/bin") }}, - }, code.InstallAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, code.InstallAction()), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, nfs.SOURCE, m.Config(nfs.SOURCE), arg) }}, }} diff --git a/misc/bash/configs.go b/misc/bash/configs.go index 4463e9d1..be8c146f 100644 --- a/misc/bash/configs.go +++ b/misc/bash/configs.go @@ -9,7 +9,7 @@ import ( func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - "/configs": {Name: "/configs", Help: "配置", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/configs": {Name: "/configs", Help: "配置", Hand: func(m *ice.Message, arg ...string) { m.Cmd("web.code.git.configs").Table(func(index int, value map[string]string, head []string) { if strings.HasPrefix(value[mdb.NAME], "url") { m.Echo(`git config --global "%s" "%s"`, value[mdb.NAME], value[mdb.VALUE]) diff --git a/misc/bash/download.go b/misc/bash/download.go index 15c1b866..caeb371b 100644 --- a/misc/bash/download.go +++ b/misc/bash/download.go @@ -11,7 +11,7 @@ import ( func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - "/download": {Name: "/download", Help: "下载", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/download": {Name: "/download", Help: "下载", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[0] == "" { m.Cmdy(chat.FILES).Table() return // 文件列表 @@ -21,7 +21,7 @@ func init() { m.Cmdy(web.CACHE, m.Cmd(chat.FILES, arg[0]).Append(mdb.DATA)) m.Render(kit.Select(ice.RENDER_DOWNLOAD, ice.RENDER_RESULT, m.Append(nfs.FILE) == ""), m.Append(mdb.TEXT)) }}, - "/upload": {Name: "/upload", Help: "上传", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/upload": {Name: "/upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(chat.FILES, web.UPLOAD) // 上传文件 for _, k := range []string{mdb.DATA, mdb.TIME, mdb.TYPE, mdb.NAME, nfs.SIZE} { m.Echo("%s: %s\n", k, msg.Append(k)) diff --git a/misc/bash/favor.go b/misc/bash/favor.go index 0fb52e11..f75230dc 100644 --- a/misc/bash/favor.go +++ b/misc/bash/favor.go @@ -24,7 +24,7 @@ func init() { } }) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(FAVOR).Table() }}, FAVOR: {Name: "favor zone id auto", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{ @@ -34,7 +34,7 @@ func init() { m.ProcessCommand(cli.SYSTEM, kit.Split(m.Option(mdb.TEXT)), arg...) m.ProcessCommandOpt(arg, cli.PWD) }}, - }, 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, mdb.EXPORT, mdb.IMPORT) } else { diff --git a/misc/bash/grant.go b/misc/bash/grant.go index 11b9530c..74b02fdd 100644 --- a/misc/bash/grant.go +++ b/misc/bash/grant.go @@ -19,7 +19,7 @@ func init() { "remove": {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { m.Cmd(SESS, mdb.REMOVE, mdb.HASH, m.Option(mdb.HASH)) }}, - }, 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.Cmdy(SESS, arg); len(arg) > 0 && m.Append("grant") == "" { m.Process("_confirm", "授权设备") } diff --git a/misc/bash/input.go b/misc/bash/input.go index 95469ebe..2b2137ce 100644 --- a/misc/bash/input.go +++ b/misc/bash/input.go @@ -10,7 +10,7 @@ import ( func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - "/input": {Name: "/input", Help: "补全", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/input": {Name: "/input", Help: "补全", Hand: func(m *ice.Message, arg ...string) { list := kit.Split(m.Option("line"), m.Option("break")) word := list[kit.Int(m.Option("index"))] switch arg[0] { diff --git a/misc/bash/sess.go b/misc/bash/sess.go index 19457739..d91c2a35 100644 --- a/misc/bash/sess.go +++ b/misc/bash/sess.go @@ -26,7 +26,7 @@ func init() { mdb.FIELD, "time,hash,status,username,hostname,pid,pwd,grant", )}, }, 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) { if f, _, e := m.R.FormFile(SUB); e == nil { defer f.Close() if b, e := ioutil.ReadAll(f); e == nil { @@ -52,14 +52,14 @@ func init() { } m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) }}, - "/qrcode": {Name: "/qrcode", Help: "二维码", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/qrcode": {Name: "/qrcode", Help: "二维码", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(cli.QRCODE, m.Option(mdb.TEXT), m.Option(cli.FG), m.Option(cli.BG)) }}, "/sess": {Name: "/sess", Help: "会话", Action: map[string]*ice.Action{ aaa.LOGOUT: {Name: "logout", Help: "退出", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SESS, mdb.MODIFY, mdb.STATUS, aaa.LOGOUT, ice.Option{mdb.HASH, m.Option(SID)}) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Option(SID) == "" { // 终端登录 m.Option(SID, m.Cmdx(SESS, mdb.CREATE, mdb.STATUS, aaa.LOGIN, m.OptionSimple(aaa.USERNAME, tcp.HOSTNAME, cli.PID, cli.PWD))) } else { // 更新状态 @@ -72,7 +72,7 @@ func init() { m.OptionFields(m.Config(mdb.FIELD)) m.Cmdy(mdb.PRUNES, m.PrefixKey(), "", mdb.HASH, mdb.STATUS, aaa.LOGOUT) }}, - }, 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/misc/bash/sync.go b/misc/bash/sync.go index bee4dc6b..fac4c810 100644 --- a/misc/bash/sync.go +++ b/misc/bash/sync.go @@ -41,7 +41,7 @@ func init() { FAVOR: {Name: "favor zone=some@key type name text pwd", Help: "收藏", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(FAVOR, mdb.INSERT) }}, - }, mdb.ListAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ListAction()), Hand: func(m *ice.Message, arg ...string) { m.OptionPage(kit.Slice(arg, 1)...) mdb.ListSelect(m, kit.Slice(arg, 0, 1)...) m.PushAction(cli.SYSTEM, FAVOR) diff --git a/misc/bash/trash.go b/misc/bash/trash.go index a1775068..e065969e 100644 --- a/misc/bash/trash.go +++ b/misc/bash/trash.go @@ -52,7 +52,7 @@ func init() { m.ProcessCommand(nfs.CAT, []string{}, arg...) m.ProcessCommandOpt(arg, TO) }}, - }, 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(nfs.CAT, mdb.REVERT, mdb.REMOVE) }}, diff --git a/misc/bash/zsh.go b/misc/bash/zsh.go index 627c746a..7183f959 100644 --- a/misc/bash/zsh.go +++ b/misc/bash/zsh.go @@ -20,7 +20,7 @@ func init() { cli.ORDER: {Name: "order", Help: "加载", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, cli.ORDER, m.Config(nfs.SOURCE), "_install/bin") }}, - }, code.InstallAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, code.InstallAction()), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, nfs.SOURCE, m.Config(nfs.SOURCE), arg) }}, }}) diff --git a/misc/git/configs.go b/misc/git/configs.go index 73925dea..8a2633e8 100644 --- a/misc/git/configs.go +++ b/misc/git/configs.go @@ -63,7 +63,7 @@ func init() { _configs_set(m, m.Option(mdb.NAME), 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 { _configs_list(m) return diff --git a/misc/git/count.go b/misc/git/count.go index 2f2de7d9..e02d8317 100644 --- a/misc/git/count.go +++ b/misc/git/count.go @@ -63,7 +63,7 @@ func init() { m.SortIntR("lines") m.StatusTime() }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, arg) }}, }}) diff --git a/misc/git/git.go b/misc/git/git.go index d1133cec..ca460d4f 100644 --- a/misc/git/git.go +++ b/misc/git/git.go @@ -27,7 +27,7 @@ var Index = &ice.Context{Name: GIT, Help: "代码库", Configs: map[string]*ice. m.Cmd(code.INSTALL, cli.ORDER, m.Config(nfs.SOURCE), "_install/bin") m.Cmdy(code.INSTALL, cli.ORDER, m.Config(nfs.SOURCE), "_install/libexec/git-core") }}, - }, code.InstallAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, code.InstallAction()), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, nfs.SOURCE, m.Config(nfs.SOURCE), arg) m.Echo("hello world %v", arg) }}, diff --git a/misc/git/repos.go b/misc/git/repos.go index ff2cf36e..0f535964 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -87,7 +87,7 @@ func init() { m.Option(REPOS), m.Option(nfs.PATH)) } }}, - }, 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) == 0 { // 仓库列表 mdb.HashSelect(m, arg...).Sort(mdb.NAME).RenameAppend(mdb.NAME, REPOS) return diff --git a/misc/git/server.go b/misc/git/server.go index 23b887d4..bab7d772 100644 --- a/misc/git/server.go +++ b/misc/git/server.go @@ -114,7 +114,7 @@ const SERVER = "server" func init() { Index.Merge(&ice.Context{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) { m.Render(ice.RENDER_VOID) }}, "/repos/": {Name: "/repos/", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{ @@ -138,7 +138,7 @@ func init() { return false }) }}, - }, 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.IsCliUA() { p := kit.Split(m.MergeURL2("/x/"+path.Join(arg...)), "?")[0] m.RenderResult("git clone %v", p) @@ -189,7 +189,7 @@ func init() { m.Cmd(cli.SYSTEM, GIT, PUSH, "--tags", remote, MASTER) }) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_ROOT, path.Join(ice.USR_LOCAL, REPOS)); len(arg) == 0 { m.Cmdy(nfs.DIR, nfs.PWD).Table(func(index int, value map[string]string, head []string) { m.PushScript("git clone " + m.MergeLink("/x/"+strings.TrimSuffix(value[nfs.PATH], ice.PS))) diff --git a/misc/git/spide.go b/misc/git/spide.go index 91bc37c3..e449ea6d 100644 --- a/misc/git/spide.go +++ b/misc/git/spide.go @@ -101,7 +101,7 @@ func init() { m.SortIntR("count") m.ProcessInner() }}, - }, 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(REPOS) return diff --git a/misc/git/status.go b/misc/git/status.go index c1271fc7..c2de6756 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -308,7 +308,7 @@ func init() { m.Cmdy(nfs.CAT, ice.GO_MOD) m.Cmdy(code.VIMER, code.BINPACK) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Action(PULL, MAKE, PUSH, TAGS, STASH, PIE, "publish") diff --git a/misc/git/total.go b/misc/git/total.go index 14f5b0c1..3487226a 100644 --- a/misc/git/total.go +++ b/misc/git/total.go @@ -38,7 +38,7 @@ func init() { m.Push("value", value["rest"]) }) }}, - }, 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] = kit.Replace(arg[0], "src", "contexts") m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) { @@ -86,7 +86,7 @@ func init() { m.SortIntR("rest") m.StatusTimeCount() }}, - "_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 { if s, e := os.Stat(path.Join(arg[0], ".git")); e == nil && s.IsDir() { m.Option(cli.CMD_DIR, arg[0]) diff --git a/misc/git/trend.go b/misc/git/trend.go index 734408a3..d7c7e574 100644 --- a/misc/git/trend.go +++ b/misc/git/trend.go @@ -18,7 +18,7 @@ func init() { mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("name,time")) }}, code.INNER: {Name: "web.code.inner"}, - }, 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(REPOS) return diff --git a/misc/lark/app.go b/misc/lark/app.go index 952302c5..5e667efb 100644 --- a/misc/lark/app.go +++ b/misc/lark/app.go @@ -46,7 +46,7 @@ func init() { } m.Echo(msg.Append(TOKEN)) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...) }}, }}) diff --git a/misc/lark/company.go b/misc/lark/company.go index 4a8f5366..3c5e182a 100644 --- a/misc/lark/company.go +++ b/misc/lark/company.go @@ -40,7 +40,7 @@ const COMPANY = "company" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - COMPANY: {Name: "company appid ship_id open_id text auto", Help: "组织", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + COMPANY: {Name: "company appid ship_id open_id text auto", Help: "组织", Hand: func(m *ice.Message, arg ...string) { switch len(arg) { case 0: // 应用列表 m.Cmdy(APP) diff --git a/misc/lark/duty.go b/misc/lark/duty.go index 44ece266..70e75edf 100644 --- a/misc/lark/duty.go +++ b/misc/lark/duty.go @@ -8,7 +8,7 @@ const DUTY = "duty" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - DUTY: {Name: "duty [title] text run", Help: "通告", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + DUTY: {Name: "duty [title] text run", Help: "通告", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(APP, m.Option(APP_ID)) m.Cmdy(SEND, msg.Append(APPID), msg.Append(DUTY), arg) }}, diff --git a/misc/lark/employee.go b/misc/lark/employee.go index ec988821..e9c08083 100644 --- a/misc/lark/employee.go +++ b/misc/lark/employee.go @@ -32,7 +32,7 @@ const EMPLOYEE = "employee" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - EMPLOYEE: {Name: "employee appid open_id|mobile|email auto", Help: "员工", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + EMPLOYEE: {Name: "employee appid open_id|mobile|email auto", Help: "员工", Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 { return } diff --git a/misc/lark/event.go b/misc/lark/event.go index d69ab30c..4008298d 100644 --- a/misc/lark/event.go +++ b/misc/lark/event.go @@ -33,7 +33,7 @@ func init() { m.Cmdy(SEND, m.Option(APP_ID), m.Option(OPEN_CHAT_ID), m.Conf(APP, kit.Keym(nfs.TEMPLATE, m.Option(mdb.TYPE)))) } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(MSG, m.Option(MSG_TYPE)) }}, }}) diff --git a/misc/lark/form.go b/misc/lark/form.go index 3d1d8f5e..f9dbcdfb 100644 --- a/misc/lark/form.go +++ b/misc/lark/form.go @@ -11,7 +11,7 @@ const FORM = "form" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - FORM: {Name: "form [chat_id|open_id|user_id|email] target title text [confirm|value|url arg...]...", Help: "消息", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + FORM: {Name: "form [chat_id|open_id|user_id|email] target title text [confirm|value|url arg...]...", Help: "消息", Hand: func(m *ice.Message, arg ...string) { var form = kit.Dict() switch arg[0] { case CHAT_ID, OPEN_ID, USER_ID, aaa.EMAIL: diff --git a/misc/lark/group.go b/misc/lark/group.go index 7703a408..487be888 100644 --- a/misc/lark/group.go +++ b/misc/lark/group.go @@ -35,7 +35,7 @@ const GROUP = "group" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - GROUP: {Name: "group appid chat_id open_id text auto", Help: "群组", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + GROUP: {Name: "group appid chat_id open_id text auto", Help: "群组", Hand: func(m *ice.Message, arg ...string) { switch len(arg) { case 0: // 应用列表 m.Cmdy(APP) diff --git a/misc/lark/home.go b/misc/lark/home.go index a35a941e..8b200a2d 100644 --- a/misc/lark/home.go +++ b/misc/lark/home.go @@ -12,7 +12,7 @@ const HOME = "home" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - HOME: {Name: "home river storm title content", Help: "首页", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + HOME: {Name: "home river storm title content", Help: "首页", Hand: func(m *ice.Message, arg ...string) { name := kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK)) if len(name) > 10 { name = name[:10] diff --git a/misc/lark/msg.go b/misc/lark/msg.go index 2deaced5..be44203e 100644 --- a/misc/lark/msg.go +++ b/misc/lark/msg.go @@ -60,10 +60,10 @@ const MSG = "msg" func init() { Index.Merge(&ice.Context{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) { m.Option(ice.MSG_USERZONE, LARK) }}, - "/msg": {Name: "/msg", Help: "聊天消息", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + "/msg": {Name: "/msg", Help: "聊天消息", Hand: func(m *ice.Message, arg ...string) { data := m.Optionv(ice.MSG_USERDATA) if kit.Value(data, "action") != nil { // 卡片回调 m.Cmd(MSG, "card") @@ -93,7 +93,7 @@ func init() { m.Cmd(SEND, m.Option(APP_ID), CHAT_ID, m.Option(OPEN_CHAT_ID), m.Option(wiki.TITLE)+" "+m.Option(ice.CMD), m.Result()) }}, - }, Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Option(OPEN_CHAT_ID) == "" { m.Cmdy(DUTY, m.Option(mdb.TYPE), kit.Formats(m.Optionv(ice.MSG_USERDATA))) } else { diff --git a/misc/lark/rand.go b/misc/lark/rand.go index 489863df..43fa5878 100644 --- a/misc/lark/rand.go +++ b/misc/lark/rand.go @@ -12,7 +12,7 @@ const RAND = "rand" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - RAND: {Name: "rand", Help: "随机", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + RAND: {Name: "rand", Help: "随机", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(GROUP, m.Option(APP_ID), EMPLOYEE, m.Option(OPEN_CHAT_ID)) list := msg.Appendv(mdb.NAME) if strings.Contains(m.Option(CONTENT), "誰") { diff --git a/misc/lark/send.go b/misc/lark/send.go index 98cb3c05..cfe436f8 100644 --- a/misc/lark/send.go +++ b/misc/lark/send.go @@ -49,7 +49,7 @@ const SEND = "send" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - SEND: {Name: "send appid [chat_id|open_id|user_id|email] target [title] text", Help: "消息", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + SEND: {Name: "send appid [chat_id|open_id|user_id|email] target [title] text", Help: "消息", Hand: func(m *ice.Message, arg ...string) { form := kit.Dict(CONTENT, kit.Dict()) appid, arg := arg[0], arg[1:] switch arg[0] { diff --git a/misc/lark/sso.go b/misc/lark/sso.go index 90d363ee..aa0f8461 100644 --- a/misc/lark/sso.go +++ b/misc/lark/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, key 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/misc/lark/talk.go b/misc/lark/talk.go index 1399aca8..d34aae40 100644 --- a/misc/lark/talk.go +++ b/misc/lark/talk.go @@ -14,7 +14,7 @@ const TALK = "talk" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - TALK: {Name: "talk text", Help: "聊天", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + TALK: {Name: "talk text", Help: "聊天", Hand: func(m *ice.Message, arg ...string) { cmds := kit.Split(strings.Join(arg, " ")) if aaa.UserLogin(m, m.Option(OPEN_ID), ""); !m.Right(cmds) { if aaa.UserLogin(m, m.Option(OPEN_CHAT_ID), ""); !m.Right(cmds) { diff --git a/misc/mp/login.go b/misc/mp/login.go index c2a0578c..274383a0 100644 --- a/misc/mp/login.go +++ b/misc/mp/login.go @@ -87,7 +87,7 @@ func init() { m.Echo(kit.Format(``, base64.StdEncoding.EncodeToString([]byte(msg.Result())), "some")) m.ProcessInner() }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Config(APPID)) }}, }}) diff --git a/misc/ssh/channel.go b/misc/ssh/channel.go index 0c05a0a0..39b0ac2c 100644 --- a/misc/ssh/channel.go +++ b/misc/ssh/channel.go @@ -96,7 +96,7 @@ func init() { }) m.ProcessRefresh300ms() }}, - }, 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) == 0 { // 通道列表 m.Action(mdb.PRUNES) mdb.HashSelect(m, arg...) diff --git a/misc/ssh/connect.go b/misc/ssh/connect.go index cd95db6d..295168f1 100644 --- a/misc/ssh/connect.go +++ b/misc/ssh/connect.go @@ -203,7 +203,7 @@ func init() { } }) }}, - }, 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("", "command,session", value[mdb.STATUS] == tcp.OPEN), mdb.REMOVE) }) diff --git a/misc/ssh/rsa.go b/misc/ssh/rsa.go index b8c36864..5edb87f6 100644 --- a/misc/ssh/rsa.go +++ b/misc/ssh/rsa.go @@ -48,7 +48,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) { if mdb.HashSelect(m, arg...).PushAction(mdb.EXPORT, mdb.REMOVE); len(arg) == 0 { m.Action(mdb.CREATE, mdb.IMPORT) } diff --git a/misc/ssh/service.go b/misc/ssh/service.go index d882fe15..f7ba537e 100644 --- a/misc/ssh/service.go +++ b/misc/ssh/service.go @@ -159,7 +159,7 @@ func init() { m.EchoScript(string(buf)) } }}, - }, mdb.HashActionStatus()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { // 服务列表 mdb.HashSelect(m, arg...) m.PushAction(mdb.IMPORT, mdb.INSERT, mdb.EXPORT, aaa.INVITE) diff --git a/misc/ssh/session.go b/misc/ssh/session.go index 500f7d81..6b24081a 100644 --- a/misc/ssh/session.go +++ b/misc/ssh/session.go @@ -74,7 +74,7 @@ func init() { }) m.ProcessRefresh300ms() }}, - }, 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 { mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) { m.PushButton(kit.Select("", ctx.COMMAND, value[mdb.STATUS] == tcp.OPEN), mdb.REMOVE) diff --git a/misc/tmux/buffer.go b/misc/tmux/buffer.go index c7905c36..f2a6e1c2 100644 --- a/misc/tmux/buffer.go +++ b/misc/tmux/buffer.go @@ -47,7 +47,7 @@ func init() { m.Cmd(cli.SYSTEM, TMUX, "set-buffer", "-b", value[mdb.NAME], value[mdb.TEXT]) }) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) > 1 && arg[1] != "" { // 设置缓存 m.Cmd(cli.SYSTEM, TMUX, "set-buffer", "-b", arg[0], arg[1]) } @@ -85,7 +85,7 @@ func init() { } } }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { text := m.Cmdx(cli.SYSTEM, TMUX, "show-buffer") if m.EchoQRCode(text); strings.HasPrefix(text, ice.HTTP) { m.Echo(ice.NL) diff --git a/misc/tmux/script.go b/misc/tmux/script.go index 71a5f483..452a048e 100644 --- a/misc/tmux/script.go +++ b/misc/tmux/script.go @@ -16,7 +16,7 @@ func init() { }, Commands: map[string]*ice.Command{ SCRIPT: {Name: "script name auto create export import", Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{ mdb.CREATE: {Name: "create type=shell,tmux,vim name=hi text:textarea=pwd", 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/misc/tmux/session.go b/misc/tmux/session.go index 462ff2d0..ace20833 100644 --- a/misc/tmux/session.go +++ b/misc/tmux/session.go @@ -147,7 +147,7 @@ func init() { }) m.Sleep30ms() }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Action(SCRIPT) if len(arg) > 3 { // 执行命令 m.Cmd(CMD, _tmux_key(arg[0], arg[1], arg[2]), arg[3:]) @@ -179,16 +179,16 @@ func init() { } }) }}, - WINDOW: {Name: "windows", Help: "窗口", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + WINDOW: {Name: "windows", Help: "窗口", Hand: func(m *ice.Message, arg ...string) { m.Split(m.Cmdx(cli.SYSTEM, TMUX, "list-windows", "-t", kit.Select("", arg, 0), "-F", m.Config(FORMAT)), m.Config(FIELDS), ice.FS, ice.NL) }}, - PANE: {Name: "panes", Help: "终端", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + PANE: {Name: "panes", Help: "终端", Hand: func(m *ice.Message, arg ...string) { m.Split(m.Cmdx(cli.SYSTEM, TMUX, "list-panes", "-t", kit.Select("", arg, 0), "-F", m.Config(FORMAT)), m.Config(FIELDS), ice.FS, ice.NL) }}, - VIEW: {Name: "view", Help: "内容", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + VIEW: {Name: "view", Help: "内容", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(cli.SYSTEM, TMUX, "capture-pane", "-pt", kit.Select("", arg, 0)).Set(ice.MSG_APPEND) }}, - CMD: {Name: "cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + CMD: {Name: "cmd", Help: "命令", Hand: func(m *ice.Message, arg ...string) { m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", arg[0], strings.Join(arg[1:], ice.SP), "Enter") m.Sleep300ms() }}, diff --git a/misc/tmux/tmux.go b/misc/tmux/tmux.go index 34ce38cb..25f5f1f4 100644 --- a/misc/tmux/tmux.go +++ b/misc/tmux/tmux.go @@ -23,7 +23,7 @@ var Index = &ice.Context{Name: TMUX, Help: "工作台", Configs: map[string]*ice }) m.Cmdy(code.INSTALL, cli.START, m.Config(nfs.SOURCE), "bin/tmux") }}, - }, code.InstallAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, code.InstallAction()), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, nfs.SOURCE, m.Config(nfs.SOURCE), arg) }}, }} diff --git a/misc/vim/favor.go b/misc/vim/favor.go index 22410a62..37d0e4eb 100644 --- a/misc/vim/favor.go +++ b/misc/vim/favor.go @@ -28,7 +28,7 @@ func init() { mdb.INSERT: {Name: "insert", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Cmd(FAVOR, mdb.INSERT) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { m.Cmd(FAVOR, m.Option(mdb.ZONE)).Table(func(index int, value map[string]string, head []string) { m.Echo("%v\n", m.Option(mdb.ZONE)).Echo("%v:%v:%v:(%v): %v\n", value[nfs.FILE], value[nfs.LINE], "1", value[mdb.NAME], value[mdb.TEXT]) @@ -40,7 +40,7 @@ func init() { p := path.Join(m.Option(cli.PWD), m.Option(nfs.FILE)) m.ProcessCommand(code.INNER, []string{path.Dir(p) + ice.PS, path.Base(p), m.Option(nfs.LINE)}, arg...) }}, - }, 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, mdb.EXPORT, mdb.IMPORT) } else { diff --git a/misc/vim/input.go b/misc/vim/input.go index 4d451a15..15221597 100644 --- a/misc/vim/input.go +++ b/misc/vim/input.go @@ -16,7 +16,7 @@ func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ INPUT: {Name: INPUT, Help: "输入法", Value: kit.Data(mdb.FIELD, "time,id,type,name,text")}, }, Commands: map[string]*ice.Command{ - "/input": {Name: "/input", Help: "输入法", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/input": {Name: "/input", Help: "输入法", Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(TAGS, ctx.ACTION, INPUT, arg[0], m.Option("pre")); m.Length() > 0 { m.Cmd(m.PrefixKey(), mdb.INSERT, kit.SimpleKV("", "tags", arg[0], m.Result())) return // 代码补全 diff --git a/misc/vim/sess.go b/misc/vim/sess.go index a6098fa9..13ddb505 100644 --- a/misc/vim/sess.go +++ b/misc/vim/sess.go @@ -29,7 +29,7 @@ func init() { mdb.FIELD, "time,hash,status,username,hostname,pid,pwd", )}, }, 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) { if f, _, e := m.R.FormFile(SUB); e == nil { defer f.Close() if b, e := ioutil.ReadAll(f); e == nil { @@ -55,7 +55,7 @@ func init() { aaa.LOGOUT: {Name: "logout", Help: "退出", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SESS, mdb.MODIFY, mdb.STATUS, aaa.LOGOUT, ice.Option{mdb.HASH, m.Option(SID)}) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Option(SID) == "" { // 终端登录 m.Option(SID, m.Cmdx(SESS, mdb.CREATE, mdb.STATUS, aaa.LOGIN, m.OptionSimple(aaa.USERNAME, tcp.HOSTNAME, cli.PID, cli.PWD))) } else { @@ -68,7 +68,7 @@ func init() { m.OptionFields(m.Config(mdb.FIELD)) m.Cmdy(mdb.PRUNES, m.PrefixKey(), "", mdb.HASH, mdb.STATUS, aaa.LOGOUT) }}, - }, 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/misc/vim/sync.go b/misc/vim/sync.go index 626cbe76..50c0392c 100644 --- a/misc/vim/sync.go +++ b/misc/vim/sync.go @@ -20,7 +20,7 @@ func init() { mdb.FIELD, "time,id,type,name,text,pwd,buf,row,col", )}, }, Commands: map[string]*ice.Command{ - "/sync": {Name: "/sync", Help: "同步", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/sync": {Name: "/sync", Help: "同步", Hand: func(m *ice.Message, arg ...string) { switch m.Option(ARG) { case "wq", "q", "qa": m.Cmd("/sess", aaa.LOGOUT) @@ -41,7 +41,7 @@ func init() { m.Cmdy(FAVOR, mdb.INSERT, m.OptionSimple(mdb.ZONE, "type,name,text,pwd"), nfs.FILE, m.Option(BUF), nfs.LINE, m.Option(ROW)) }}, - }, mdb.ListAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ListAction()), Hand: func(m *ice.Message, arg ...string) { m.OptionPage(kit.Slice(arg, 1)...) mdb.ListSelect(m, kit.Slice(arg, 0, 1)...) m.PushAction(code.INNER, FAVOR) diff --git a/misc/vim/tags.go b/misc/vim/tags.go index 79f46985..3835696b 100644 --- a/misc/vim/tags.go +++ b/misc/vim/tags.go @@ -31,7 +31,7 @@ func init() { mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line", )}, }, Commands: map[string]*ice.Command{ - "/tags": {Name: "/tags", Help: "跳转", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/tags": {Name: "/tags", Help: "跳转", Hand: func(m *ice.Message, arg ...string) { switch m.Option(MODULE) { case ONIMPORT, ONACTION, ONEXPORT: m.Echo(func_pattern, m.Option(BUF), m.Option(PATTERN)) @@ -82,7 +82,7 @@ func init() { m.Echo("%s: %s"+ice.NL, value[mdb.NAME], strings.Split(value[mdb.TEXT], ice.NL)[0]) }) }}, - }, 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.ZoneSelectAll(m, arg...); len(arg) == 0 { m.Action("listTags", mdb.CREATE, mdb.EXPORT, mdb.IMPORT) } else { diff --git a/misc/vim/vim.go b/misc/vim/vim.go index 33454e99..8d71d93f 100644 --- a/misc/vim/vim.go +++ b/misc/vim/vim.go @@ -32,7 +32,7 @@ var Index = &ice.Context{Name: VIM, Help: "编辑器", Configs: map[string]*ice. cli.ORDER: {Name: "order", Help: "加载", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, cli.ORDER, _vim_pkg(m, m.Config(nfs.SOURCE)), "_install/bin") }}, - }, code.InstallAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, code.InstallAction()), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(code.INSTALL, nfs.SOURCE, _vim_pkg(m, m.Config(nfs.SOURCE)), arg) }}, }} diff --git a/misc/wework/bot.go b/misc/wework/bot.go index b5973685..b8e3292c 100644 --- a/misc/wework/bot.go +++ b/misc/wework/bot.go @@ -21,8 +21,8 @@ func init() { mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,token,ekey,hook", )}, }, Commands: map[string]*ice.Command{ - web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, - "/bot/": {Name: "/bot/", Help: "机器人", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) {}}, + "/bot/": {Name: "/bot/", Help: "机器人", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(BOT, arg[0]) check := kit.Sort([]string{msg.Append("token"), m.Option("nonce"), m.Option("timestamp"), m.Option("echostr")}) @@ -52,7 +52,7 @@ func init() { m.Cmd(web.SPIDE, mdb.CREATE, m.Option("name"), m.Option("hook")) m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, arg) }}, - }, 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) > 2 { m.Cmdy(web.SPIDE, arg[0], "", kit.Format(kit.Dict( "chatid", arg[1], "msgtype", "text", "text.content", arg[2], diff --git a/misc/wx/access.go b/misc/wx/access.go index a74016e3..82b76072 100644 --- a/misc/wx/access.go +++ b/misc/wx/access.go @@ -102,7 +102,7 @@ func init() { CHECK: {Name: "check", Help: "检验", Hand: func(m *ice.Message, arg ...string) { _wx_check(m) }}, - }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Config(APPID)) }}, }}) diff --git a/misc/wx/favor.go b/misc/wx/favor.go index a3f8caac..ca3bd7f7 100644 --- a/misc/wx/favor.go +++ b/misc/wx/favor.go @@ -18,7 +18,7 @@ func init() { }, Commands: map[string]*ice.Command{ FAVOR: {Name: "favor text:text auto create", Help: "收藏", Action: ice.MergeAction(map[string]*ice.Action{ mdb.CREATE: {Name: "create type name text", 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...).Table(func(index int, value map[string]string, head []string) { m.PushQRCode(mdb.SCAN, kit.MergeURL(m.Config(mdb.LINK), aaa.USERNAME, value[mdb.TEXT])) }) diff --git a/misc/wx/login.go b/misc/wx/login.go index 350dd184..26170de9 100644 --- a/misc/wx/login.go +++ b/misc/wx/login.go @@ -66,7 +66,7 @@ func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ LOGIN: {Name: LOGIN, Help: "登录", Value: kit.Data()}, }, Commands: map[string]*ice.Command{ - "/login/": {Name: "/login/", Help: "认证", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/login/": {Name: "/login/", Help: "认证", Hand: func(m *ice.Message, arg ...string) { if m.Cmdx(ACCESS, CHECK) == "" { return // 验签失败 } @@ -106,7 +106,7 @@ func init() { m.Conf(ACCESS, kit.Keym(APPMM), m.Option(APPMM)) m.Conf(ACCESS, kit.Keym(TOKEN), m.Option(TOKEN)) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { }}, }}) } diff --git a/misc/wx/menu.go b/misc/wx/menu.go index c5df5e49..49ef7059 100644 --- a/misc/wx/menu.go +++ b/misc/wx/menu.go @@ -51,7 +51,7 @@ func init() { }, Commands: map[string]*ice.Command{ MENU: {Name: "menu zone id auto insert", Help: "菜单", Action: ice.MergeAction(map[string]*ice.Action{ mdb.INSERT: {Name: "insert zone=home title=hi refer=hello image", Help: "添加"}, - }, 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 { _wx_action(m) } diff --git a/misc/wx/text.go b/misc/wx/text.go index 70c748dd..dfd25e25 100644 --- a/misc/wx/text.go +++ b/misc/wx/text.go @@ -24,7 +24,7 @@ func init() { MENU: {Name: "menu name", Help: "菜单", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(MENU, kit.Select("home", m.Option(mdb.NAME))) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(arg); m.Length() == 0 && (m.Result() == "" || m.Result(1) == ice.ErrNotFound) { m.Set(ice.MSG_RESULT) m.Cmdy(cli.SYSTEM, arg) // 系统命令 diff --git a/option.go b/option.go index 98dff0b9..042cecb9 100644 --- a/option.go +++ b/option.go @@ -16,19 +16,20 @@ type Option struct { Value Any } -func OptionHash(arg string) Option { return Option{HASH, arg} } func OptionFields(arg ...string) Option { return Option{MSG_FIELDS, kit.Join(arg)} } +func (m *Message) OptionCB(key string, cb ...Any) Any { + if len(cb) > 0 { + return m.Optionv(kit.Keycb(key), cb...) + } + return m.Optionv(kit.Keycb(key)) +} func (m *Message) OptionFields(arg ...string) string { if len(arg) > 0 { m.Option(MSG_FIELDS, kit.Join(arg)) } return kit.Join(kit.Simple(m.Optionv(MSG_FIELDS))) } -func (m *Message) OptionPage(arg ...string) int { - page, _ := m.OptionPages(arg...) - return page -} func (m *Message) OptionPages(arg ...string) (page int, size int) { m.Option(CACHE_LIMIT, kit.Select("", arg, 0)) m.Option(CACHE_OFFEND, kit.Select("", arg, 1)) @@ -39,6 +40,10 @@ func (m *Message) OptionPages(arg ...string) (page int, size int) { page = kit.Int(m.Option("offend"))/size + 1 return } +func (m *Message) OptionPage(arg ...string) int { + page, _ := m.OptionPages(arg...) + return page +} func (m *Message) OptionLoad(file string) *Message { if f, e := os.Open(file); e == nil { defer f.Close() @@ -52,18 +57,18 @@ func (m *Message) OptionLoad(file string) *Message { } return m } -func (m *Message) OptionSplit(key ...string) (res []string) { - for _, k := range kit.Split(kit.Join(key)) { - res = append(res, m.Option(k)) - } - return res -} func (m *Message) OptionDefault(key, value string) string { if m.Option(key) == "" { m.Option(key, value) } return m.Option(key) } +func (m *Message) OptionSplit(key ...string) (res []string) { + for _, k := range kit.Split(kit.Join(key)) { + res = append(res, m.Option(k)) + } + return res +} func (m *Message) OptionSimple(key ...string) (res []string) { for _, k := range kit.Split(kit.Join(key)) { if k == "" || m.Option(k) == "" { @@ -276,14 +281,6 @@ func (m *Message) MergeURL2(url string, arg ...Any) string { func (m *Message) MergeLink(url string, arg ...Any) string { return strings.Split(m.MergeURL2(url, arg...), "?")[0] } -func (m *Message) MergePodURL(url string, arg ...Any) string { - if m.Option(MSG_USERPOD) == "" { - url = strings.TrimPrefix(url, "web.") - return kit.MergeURL(m.MergeLink(url), arg...) - } - url = strings.TrimPrefix(url, "web.chat.") - return kit.MergeURL(m.MergeLink(path.Join("/chat/pod/", m.Option(MSG_USERPOD), url)), arg...) -} func (m *Message) MergePod(pod string, arg ...Any) string { return kit.MergePOD(kit.Select(Info.Domain, m.Option(MSG_USERWEB)), pod, arg...) } diff --git a/render.go b/render.go index 23d3a561..2aed73f6 100644 --- a/render.go +++ b/render.go @@ -25,9 +25,6 @@ func Render(m *Message, cmd string, args ...Any) string { return kit.Format(`%s`, p, arg[0]) case RENDER_BUTTON: // name... - if m._cmd == nil || m._cmd.Meta == nil { - break - } list := []string{} for _, k := range kit.Split(kit.Join(arg)) { list = append(list, kit.Format(``, k, @@ -35,13 +32,13 @@ func Render(m *Message, cmd string, args ...Any) string { } return kit.Join(list, SP) - case RENDER_IMAGES: // src [size] + case RENDER_IMAGES: // src [height] return kit.Format(``, arg[0], kit.Select("120", arg, 1)) - case RENDER_VIDEOS: // src [size] + case RENDER_VIDEOS: // src [height] return kit.Format(`