From d83e0dfdb537447fc47c670c5d6fc275a020c8af Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 29 Oct 2020 17:08:47 +0800 Subject: [PATCH] opt merge --- base/aaa/role.go | 2 +- base/aaa/sess.go | 2 +- base/aaa/totp.go | 2 +- base/aaa/user.go | 2 +- base/cli/cli.go | 10 ++++++++++ base/cli/daemon.go | 3 ++- base/cli/output.go | 4 ++-- base/cli/proc.go | 2 +- base/cli/python.go | 2 +- base/cli/runtime.go | 2 +- base/cli/system.go | 2 +- base/ctx/command.go | 2 +- base/ctx/config.go | 2 +- base/ctx/context.go | 2 +- base/gdb/event.go | 2 +- base/gdb/routine.go | 5 ++++- base/gdb/signal.go | 2 +- base/gdb/timer.go | 2 +- base/mdb/engine.go | 2 +- base/mdb/mdb.go | 24 ++++++++++++++++-------- base/mdb/plugin.go | 2 +- base/mdb/render.go | 2 +- base/mdb/search.go | 2 +- base/nfs/nfs.go | 9 +++++++-- base/ssh/channel.go | 2 +- base/ssh/connect.go | 2 +- base/ssh/scripts.go | 2 +- base/ssh/service.go | 2 +- base/ssh/session.go | 2 +- base/tcp/client.go | 2 +- base/tcp/host.go | 2 +- base/tcp/port.go | 2 +- base/tcp/server.go | 2 +- base/web/cache.go | 2 +- base/web/dream.go | 6 +++--- base/web/route.go | 4 ++-- base/web/serve.go | 5 +++-- base/web/share.go | 2 +- base/web/space.go | 2 +- base/web/spide.go | 2 +- base/web/story.go | 2 +- conf.go | 8 ++++++++ core/chat/action.go | 2 +- core/chat/footer.go | 2 +- core/chat/header.go | 2 +- core/chat/location.go | 2 +- core/chat/paste.go | 2 +- core/chat/river.go | 2 +- core/chat/scan.go | 2 +- core/chat/search.go | 20 +++++++++----------- core/code/autogen.go | 2 +- core/code/bench.go | 2 +- core/code/compile.go | 2 +- core/code/favor.go | 2 +- core/code/inner.go | 2 +- core/code/install.go | 2 +- core/code/pack.go | 2 +- core/code/pprof.go | 2 +- core/code/publish.go | 2 +- core/code/upgrade.go | 2 +- core/code/vimer.go | 2 +- core/mall/asset.go | 2 +- core/mall/salary.go | 2 +- core/team/plan.go | 2 +- core/team/task.go | 2 +- core/wiki/data.go | 2 +- core/wiki/draw.go | 2 +- core/wiki/feel.go | 2 +- core/wiki/word.go | 2 +- misc/chrome/cache.go | 2 +- misc/chrome/favor.go | 2 +- misc/chrome/spide.go | 2 +- misc/chrome/sync.go | 2 +- misc/git/repos.go | 2 +- misc/git/spide.go | 2 +- misc/git/status.go | 2 +- misc/git/total.go | 2 +- misc/git/trend.go | 2 +- misc/tmux/tmux.go | 12 ++++++++++-- misc/vim/favor.go | 2 +- misc/vim/input.go | 2 +- misc/vim/sess.go | 2 +- misc/vim/sync.go | 2 +- misc/zsh/bash.go | 2 +- misc/zsh/download.go | 2 +- misc/zsh/favor.go | 2 +- misc/zsh/input.go | 2 +- misc/zsh/sess.go | 2 +- misc/zsh/sync.go | 2 +- misc/zsh/trash.go | 2 +- type.go | 6 ++---- 91 files changed, 156 insertions(+), 116 deletions(-) diff --git a/base/aaa/role.go b/base/aaa/role.go index 79fc8c34..6e5a1d26 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -142,5 +142,5 @@ func init() { m.PushAction(mdb.REMOVE) }}, }, - }, nil) + }) } diff --git a/base/aaa/sess.go b/base/aaa/sess.go index 1c1f1ce5..54c7a4b9 100644 --- a/base/aaa/sess.go +++ b/base/aaa/sess.go @@ -91,5 +91,5 @@ func init() { m.PushAction(mdb.REMOVE) }}, }, - }, nil) + }) } diff --git a/base/aaa/totp.go b/base/aaa/totp.go index c33af3af..2b54a0dc 100644 --- a/base/aaa/totp.go +++ b/base/aaa/totp.go @@ -104,5 +104,5 @@ func init() { }) }}, }, - }, nil) + }) } diff --git a/base/aaa/user.go b/base/aaa/user.go index 6a7f5a42..6c0c47d7 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -126,5 +126,5 @@ func init() { m.PushAction(mdb.REMOVE) }}, }, - }, nil) + }) } diff --git a/base/cli/cli.go b/base/cli/cli.go index 74a54007..55723042 100644 --- a/base/cli/cli.go +++ b/base/cli/cli.go @@ -2,6 +2,7 @@ package cli import ( ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" kit "github.com/shylinux/toolkits" "os" @@ -77,6 +78,15 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块", m.Conf(RUNTIME, "build.username", ice.Info.Build.UserName) }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + list := []string{} + m.Richs(DAEMON, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) { + if value = kit.GetMeta(value); kit.Value(value, mdb.CACHE_CLEAR_ON_EXIT) == "true" { + list = append(list, key) + } + }) + for _, k := range list { + m.Conf(DAEMON, kit.Keys(kit.MDB_HASH, k), "") + } m.Save() }}, }, diff --git a/base/cli/daemon.go b/base/cli/daemon.go index 6bcdff8e..0f485f1d 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -34,6 +34,7 @@ func _daemon_show(m *ice.Message, cmd *exec.Cmd, out, err string) { } h := m.Cmdx(mdb.INSERT, DAEMON, "", mdb.HASH, + mdb.CACHE_CLEAR_ON_EXIT, m.Option(mdb.CACHE_CLEAR_ON_EXIT), kit.MDB_STATUS, Status.Start, kit.SSH_CMD, strings.Join(cmd.Args, " "), kit.SSH_DIR, cmd.Dir, kit.SSH_ENV, kit.Select("", cmd.Env), kit.SSH_PID, cmd.Process.Pid, CMD_STDOUT, out, CMD_STDERR, err, @@ -139,5 +140,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/base/cli/output.go b/base/cli/output.go index c3117bdd..97b90d27 100644 --- a/base/cli/output.go +++ b/base/cli/output.go @@ -40,7 +40,7 @@ func Follow(m *ice.Message, action string) bool { }) if len(m.Resultv()) == 0 && m.Conf(OUTPUT, kit.Keys(kit.MDB_HASH, m.Option(mdb.CACHE_HASH), kit.MDB_META, kit.MDB_STATUS)) == STOP { - m.Echo(STOP) + m.Option(mdb.CACHE_STATUS, STOP) } return true } @@ -119,5 +119,5 @@ func init() { m.Sort(kit.MDB_ID) }}, }, - }, nil) + }) } diff --git a/base/cli/proc.go b/base/cli/proc.go index 5aecd2f0..9e7b968d 100644 --- a/base/cli/proc.go +++ b/base/cli/proc.go @@ -32,5 +32,5 @@ func init() { }) }}, }, - }, nil) + }) } diff --git a/base/cli/python.go b/base/cli/python.go index aa25ee18..14fe1d4d 100644 --- a/base/cli/python.go +++ b/base/cli/python.go @@ -44,5 +44,5 @@ func init() { m.Cmdy("web.code.install", path.Base(m.Conf(PYTHON, kit.META_SOURCE)), arg) }}, }, - }, nil) + }) } diff --git a/base/cli/runtime.go b/base/cli/runtime.go index f6dbceff..13c6992d 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -69,5 +69,5 @@ func init() { m.Cmdy(ctx.CONFIG, RUNTIME, arg) }}, }, - }, nil) + }) } diff --git a/base/cli/system.go b/base/cli/system.go index 05151e4a..6d0ab296 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -106,5 +106,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/base/ctx/command.go b/base/ctx/command.go index aafc88bc..21d5380a 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -49,5 +49,5 @@ func init() { _command_list(m, strings.Join(arg, ".")) }}, }, - }, nil) + }) } diff --git a/base/ctx/config.go b/base/ctx/config.go index feadb12e..4efc5b8a 100644 --- a/base/ctx/config.go +++ b/base/ctx/config.go @@ -122,5 +122,5 @@ func init() { _config_make(m, arg[0], arg[1:]...) }}, }, - }, nil) + }) } diff --git a/base/ctx/context.go b/base/ctx/context.go index 137ee01b..e22a8a0a 100644 --- a/base/ctx/context.go +++ b/base/ctx/context.go @@ -35,5 +35,5 @@ func init() { }) }}, }, - }, nil) + }) } diff --git a/base/gdb/event.go b/base/gdb/event.go index d86b2109..b187a629 100644 --- a/base/gdb/event.go +++ b/base/gdb/event.go @@ -50,5 +50,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/base/gdb/routine.go b/base/gdb/routine.go index 89b87634..e74629bd 100644 --- a/base/gdb/routine.go +++ b/base/gdb/routine.go @@ -8,6 +8,9 @@ import ( "strings" ) +const ( + TASK_HASH = "task.hash" +) const ( INNER = "inner" ) @@ -57,5 +60,5 @@ func init() { m.PushAction(INNER, mdb.REMOVE) }}, }, - }, nil) + }) } diff --git a/base/gdb/signal.go b/base/gdb/signal.go index 86e336fb..a08f66de 100644 --- a/base/gdb/signal.go +++ b/base/gdb/signal.go @@ -54,5 +54,5 @@ func init() { m.Sort(SIGNAL) }}, }, - }, nil) + }) } diff --git a/base/gdb/timer.go b/base/gdb/timer.go index 576cdd17..62272ce4 100644 --- a/base/gdb/timer.go +++ b/base/gdb/timer.go @@ -72,5 +72,5 @@ func init() { return }}, }, - }, nil) + }) } diff --git a/base/mdb/engine.go b/base/mdb/engine.go index dab3154a..39e13b82 100644 --- a/base/mdb/engine.go +++ b/base/mdb/engine.go @@ -32,5 +32,5 @@ func init() { m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), ENGINE, arg[0], arg[1], arg[2], arg[3:]) }) }}, - }}, nil) + }}) } diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index 259b199d..218eb2d8 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -40,16 +40,22 @@ func _hash_select(m *ice.Message, prefix, chain, field, value string) { value = kit.MDB_RANDOMS } fields := _hash_fields(m) + cb := m.Optionv(SELECT_CB) m.Richs(prefix, chain, value, func(key string, val map[string]interface{}) { val = kit.GetMeta(val) - if m.Option(FIELDS) == DETAIL { - m.Push(DETAIL, val) - } else { - m.Push(key, val, fields) + switch cb := cb.(type) { + case func(fields []string, value map[string]interface{}): + cb(fields, val) + default: + if m.Option(FIELDS) == DETAIL { + m.Push(DETAIL, val) + } else { + m.Push(key, val, fields) + } } }) if m.Option(FIELDS) != DETAIL { - m.Sort(kit.MDB_TIME, "time_r") + m.SortTimeR(kit.MDB_TIME) } } func _hash_modify(m *ice.Message, prefix, chain string, field, value string, arg ...string) { @@ -150,7 +156,7 @@ func _list_select(m *ice.Message, prefix, chain, field, value string) { } fields := _list_fields(m) cb := m.Optionv(SELECT_CB) - m.Grows(prefix, chain, kit.Select(m.Option("cache.field"), field), kit.Select(m.Option("cache.value"), value), func(index int, val map[string]interface{}) { + m.Grows(prefix, chain, kit.Select(m.Option("cache.field"), field), kit.Select(m.Option(CACHE_VALUE), value), func(index int, val map[string]interface{}) { val = kit.GetMeta(val) switch cb := cb.(type) { case func(fields []string, value map[string]interface{}): @@ -162,10 +168,9 @@ func _list_select(m *ice.Message, prefix, chain, field, value string) { m.Push("", val, fields) } } - }) if m.Option(FIELDS) != DETAIL { - m.Sort(kit.MDB_ID, "int_r") + m.SortIntR(kit.MDB_ID) } } func _list_modify(m *ice.Message, prefix, chain string, field, value string, arg ...string) { @@ -412,9 +417,12 @@ const ( CACHE_FILED = "cache.field" CACHE_VALUE = "cache.value" + CACHE_STATUS = "cache.status" CACHE_ACTION = "cache.action" CACHE_BEGIN = "cache.begin" CACHE_HASH = "cache.hash" + + CACHE_CLEAR_ON_EXIT = "cache.clear.on.exit" ) const MDB = "mdb" diff --git a/base/mdb/plugin.go b/base/mdb/plugin.go index 3023364e..d224e4fb 100644 --- a/base/mdb/plugin.go +++ b/base/mdb/plugin.go @@ -29,5 +29,5 @@ func init() { m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), PLUGIN, arg[0], arg[1], kit.Select("", arg, 2)) }) }}, - }}, nil) + }}) } diff --git a/base/mdb/render.go b/base/mdb/render.go index c28d22e9..d46437bf 100644 --- a/base/mdb/render.go +++ b/base/mdb/render.go @@ -29,5 +29,5 @@ func init() { m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), RENDER, arg[0], arg[1], kit.Select("", arg, 2)) }) }}, - }}, nil) + }}) } diff --git a/base/mdb/search.go b/base/mdb/search.go index e2d214f0..79c61e99 100644 --- a/base/mdb/search.go +++ b/base/mdb/search.go @@ -37,5 +37,5 @@ func init() { }) } }}, - }}, nil) + }}) } diff --git a/base/nfs/nfs.go b/base/nfs/nfs.go index 78592fda..4c3ff6ec 100644 --- a/base/nfs/nfs.go +++ b/base/nfs/nfs.go @@ -365,7 +365,11 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", }}, FILE: {Name: "file path auto", Help: "文件", Action: map[string]*ice.Action{ "append": {Name: "append", Help: "追加", Hand: func(m *ice.Message, arg ...string) { - if f, e := os.OpenFile(arg[0], os.O_WRONLY|os.O_APPEND, 0664); m.Assert(e) { + if strings.Contains(arg[0], "/") { + os.MkdirAll(path.Dir(arg[0]), ice.MOD_DIR) + } + + if f, e := os.OpenFile(arg[0], os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0664); m.Assert(e) { defer f.Close() for _, k := range arg[1:] { @@ -419,7 +423,7 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", for _, file := range kit.Split(m.Option(kit.MDB_FILE), ",") { func(file string) { r, w := io.Pipe() - m.Go(func(msg *ice.Message) { + m.Go(func() { for bio := bufio.NewScanner(r); bio.Scan(); { m.Grow(TAIL, kit.Keys(kit.MDB_HASH, h), kit.Dict( kit.MDB_FILE, file, kit.MDB_TEXT, bio.Text(), @@ -428,6 +432,7 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", }) m.Option(cli.CMD_STDOUT, w) m.Option(cli.CMD_STDERR, w) + m.Option(mdb.CACHE_CLEAR_ON_EXIT, "true") m.Cmd(cli.DAEMON, "tail", "-n", "0", "-f", file) }(file) } diff --git a/base/ssh/channel.go b/base/ssh/channel.go index a2eba9a4..3cc0aeb6 100644 --- a/base/ssh/channel.go +++ b/base/ssh/channel.go @@ -94,5 +94,5 @@ func init() { m.Cmdy(mdb.SELECT, CHANNEL, kit.Keys(kit.MDB_HASH, arg[0]), mdb.LIST, kit.MDB_ID, arg[1:]) }}, }, - }, nil) + }) } diff --git a/base/ssh/connect.go b/base/ssh/connect.go index 378e277f..9f5a5fb6 100644 --- a/base/ssh/connect.go +++ b/base/ssh/connect.go @@ -167,5 +167,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/base/ssh/scripts.go b/base/ssh/scripts.go index 44b42c8b..4d7d31b0 100644 --- a/base/ssh/scripts.go +++ b/base/ssh/scripts.go @@ -382,5 +382,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/base/ssh/service.go b/base/ssh/service.go index 26b8b752..c0301fe3 100644 --- a/base/ssh/service.go +++ b/base/ssh/service.go @@ -226,5 +226,5 @@ ssh {{.Option "user.name"}}@{{.Option "hostname"}} -p {{.Option "port"}} m.Cmdy(mdb.SELECT, SERVICE, kit.Keys(kit.MDB_HASH, kit.Hashs(arg[0])), mdb.LIST, kit.MDB_ID, arg[1:]) }}, }, - }, nil) + }) } diff --git a/base/ssh/session.go b/base/ssh/session.go index aac5a29a..6fbd1153 100644 --- a/base/ssh/session.go +++ b/base/ssh/session.go @@ -128,5 +128,5 @@ func init() { m.Sort(kit.MDB_ID) }}, }, - }, nil) + }) } diff --git a/base/tcp/client.go b/base/tcp/client.go index 8f6652b0..02d85c86 100644 --- a/base/tcp/client.go +++ b/base/tcp/client.go @@ -101,5 +101,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/base/tcp/host.go b/base/tcp/host.go index 6071d248..7d1dabb5 100644 --- a/base/tcp/host.go +++ b/base/tcp/host.go @@ -86,5 +86,5 @@ func init() { _host_list(m, kit.Select("", arg, 0)) }}, }, - }, nil) + }) } diff --git a/base/tcp/port.go b/base/tcp/port.go index b22c87f6..e6070963 100644 --- a/base/tcp/port.go +++ b/base/tcp/port.go @@ -73,5 +73,5 @@ func init() { _port_list(m, kit.Select("", arg, 0), kit.Select("", arg, 1)) }}, }, - }, nil) + }) } diff --git a/base/tcp/server.go b/base/tcp/server.go index 41bfea69..7442aab2 100644 --- a/base/tcp/server.go +++ b/base/tcp/server.go @@ -115,5 +115,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/base/web/cache.go b/base/web/cache.go index d90e13e9..76384ce4 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -178,5 +178,5 @@ func init() { } }) }}, - }}, nil) + }}) } diff --git a/base/web/dream.go b/base/web/dream.go index e35d46ad..57d301cb 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -98,8 +98,8 @@ ish_miss_prepare_install }, Commands: map[string]*ice.Command{ DREAM: {Name: "dream name path auto 启动", Help: "梦想家", Action: map[string]*ice.Action{ - gdb.START: {Name: "start type=worker,server repos", Help: "启动", Hand: func(m *ice.Message, arg ...string) { - _dream_show(m, m.Option(kit.MDB_NAME, path.Base(m.Option(kit.SSH_REPOS)))) + gdb.START: {Name: "start type=worker,server repos name", Help: "启动", Hand: func(m *ice.Message, arg ...string) { + _dream_show(m, m.Option(kit.MDB_NAME, kit.Select(path.Base(m.Option(kit.SSH_REPOS)), m.Option(kit.MDB_NAME)))) }}, gdb.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, m.Option(kit.MDB_NAME), "exit", "0") @@ -119,5 +119,5 @@ ish_miss_prepare_install m.Cmdy(nfs.DIR, arg[1:]) }}, }, - }, nil) + }) } diff --git a/base/web/route.go b/base/web/route.go index de43c1df..151a41f5 100644 --- a/base/web/route.go +++ b/base/web/route.go @@ -75,7 +75,7 @@ func init() { m.Sort(kit.MDB_PATH) } }}, - gdb.START: {Name: "start type=worker,server repos", Help: "启动", Hand: func(m *ice.Message, arg ...string) { + gdb.START: {Name: "start type=worker,server repos name", Help: "启动", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, m.Option(ROUTE), DREAM, gdb.START, arg) }}, gdb.STOP: {Name: "stop", Help: "结束", Hand: func(m *ice.Message, arg ...string) { @@ -150,5 +150,5 @@ func init() { }) } }}, - }}, nil) + }}) } diff --git a/base/web/serve.go b/base/web/serve.go index e6acd152..a5097ef5 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -136,7 +136,8 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon } // 用户请求 - msg.Option("cache.limit", "10") + msg.Option("name", "") + msg.Option(mdb.CACHE_LIMIT, "10") msg.Option(ice.MSG_OUTPUT, "") msg.Option(ice.MSG_METHOD, r.Method) msg.Option(ice.MSG_USERWEB, kit.Select(msg.Conf(SHARE, "meta.domain"), r.Header.Get("Referer"))) @@ -306,5 +307,5 @@ func init() { "/intshell/": {Name: "/intshell/", Help: "脚本", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Render(ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, "meta.intshell.path"), path.Join(arg...))) }}, - }}, nil) + }}) } diff --git a/base/web/share.go b/base/web/share.go index 5f501788..09a26253 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -148,5 +148,5 @@ func init() { } _share_local(m, p) }}, - }}, nil) + }}) } diff --git a/base/web/space.go b/base/web/space.go index 49e4d2ac..d5555dbc 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -238,5 +238,5 @@ func init() { }) } }}, - }}, nil) + }}) } diff --git a/base/web/spide.go b/base/web/spide.go index 1efcf5b0..c1af907a 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -310,5 +310,5 @@ func init() { } }) }}, - }}, nil) + }}) } diff --git a/base/web/story.go b/base/web/story.go index 160eec1d..102bf60c 100644 --- a/base/web/story.go +++ b/base/web/story.go @@ -249,7 +249,7 @@ func init() { m.Render(kit.Select(ice.RENDER_DOWNLOAD, ice.RENDER_RESULT, m.Append("file") == ""), m.Append("text")) } }}, - }}, nil) + }}) } func _story_pull(m *ice.Message, arg ...string) { diff --git a/conf.go b/conf.go index 866747a4..4a109b76 100644 --- a/conf.go +++ b/conf.go @@ -50,6 +50,14 @@ const ( // MSG MSG_ACTIVE = "sess.active" MSG_METHOD = "sess.method" ) +const ( + CONTROL_PAGE = "_page" + + PROCESS_REFRESH = "_refresh" + PROCESS_FOLLOW = "_follow" + PROCESS_INNER = "_inner" + PROCESS_FIELD = "_field" +) const ( // CTX CTX_FOLLOW = "follow" CTX_STATUS = "status" diff --git a/core/chat/action.go b/core/chat/action.go index 31ce0c19..05e7039b 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -123,5 +123,5 @@ func init() { _action_show(m, arg[0], arg[1], arg[2], arg[3:]...) }}, - }}, nil) + }}) } diff --git a/core/chat/footer.go b/core/chat/footer.go index 3135457b..c091f8f7 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -22,5 +22,5 @@ func init() { kit.Fetch(m.Confv(FOOTER, LEGAL), func(index int, value string) { m.Echo(value) }) }}, }, - }, nil) + }) } diff --git a/core/chat/header.go b/core/chat/header.go index 9ad1cfb8..829b0598 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -46,5 +46,5 @@ func init() { m.Echo(m.Conf(HEADER, TITLE)) }}, }, - }, nil) + }) } diff --git a/core/chat/location.go b/core/chat/location.go index e9768cc9..758f6791 100644 --- a/core/chat/location.go +++ b/core/chat/location.go @@ -60,5 +60,5 @@ func init() { m.PushAction("openLocation", mdb.REMOVE) }}, }, - }, nil) + }) } diff --git a/core/chat/paste.go b/core/chat/paste.go index 6c05063f..8c0f66ac 100644 --- a/core/chat/paste.go +++ b/core/chat/paste.go @@ -49,5 +49,5 @@ func init() { m.PushAction(mdb.REMOVE) }}, }, - }, nil) + }) } diff --git a/core/chat/river.go b/core/chat/river.go index adc7f6fb..3667087e 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -346,5 +346,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/core/chat/scan.go b/core/chat/scan.go index e102f484..c82d180d 100644 --- a/core/chat/scan.go +++ b/core/chat/scan.go @@ -45,5 +45,5 @@ func init() { m.PushAction(mdb.REMOVE) }}, }, - }, nil) + }) } diff --git a/core/chat/search.go b/core/chat/search.go index 46b66c24..e3180eb2 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -6,15 +6,13 @@ import ( ) func init() { - Index.Merge(&ice.Context{ - Commands: map[string]*ice.Command{ - "/search": {Name: "/search", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - if arg[0] == mdb.RENDER { - m.Cmdy(m.Space(m.Option(POD)), mdb.RENDER, arg[1:]) - return - } - m.Cmdy(m.Space(m.Option(POD)), mdb.SEARCH, arg) - }}, - }, - }, nil) + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + "/search": {Name: "/search", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if arg[0] == mdb.RENDER { + m.Cmdy(m.Space(m.Option(POD)), mdb.RENDER, arg[1:]) + return + } + m.Cmdy(m.Space(m.Option(POD)), mdb.SEARCH, arg) + }}, + }}) } diff --git a/core/code/autogen.go b/core/code/autogen.go index 33fa5b7f..abff9a0f 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -111,5 +111,5 @@ field "{{.Option "name"}}" web.code.{{.Option "name"}}.{{.Option "name"}} } }}, }, - }, nil) + }) } diff --git a/core/code/bench.go b/core/code/bench.go index 11025a9d..a5891bd7 100644 --- a/core/code/bench.go +++ b/core/code/bench.go @@ -98,5 +98,5 @@ func init() { m.Cmdy(m.Optionv("cmd")) }}, }, - }, nil) + }) } diff --git a/core/code/compile.go b/core/code/compile.go index dd0ccf51..1af93f73 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -74,5 +74,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/core/code/favor.go b/core/code/favor.go index 8ca57a7e..2673c7e1 100644 --- a/core/code/favor.go +++ b/core/code/favor.go @@ -62,5 +62,5 @@ func init() { m.PushAction(kit.Select(mdb.REMOVE, INNER, len(arg) > 0)) }}, }, - }, nil) + }) } diff --git a/core/code/inner.go b/core/code/inner.go index a3ec61d5..89ad3ac1 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -162,5 +162,5 @@ func init() { ), )}, }, - }, nil) + }) } diff --git a/core/code/install.go b/core/code/install.go index ac3696de..8d2c6f22 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -149,5 +149,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/core/code/pack.go b/core/code/pack.go index 4a86c50a..3cb82ee9 100644 --- a/core/code/pack.go +++ b/core/code/pack.go @@ -186,7 +186,7 @@ func init() { WEBPACK: {Name: WEBPACK, Help: "webpack", Value: kit.Data(kit.MDB_PATH, "usr/volcanos")}, BINPACK: {Name: BINPACK, Help: "binpack", Value: kit.Data()}, }, - }, nil) + }) } const _pack = ` diff --git a/core/code/pprof.go b/core/code/pprof.go index e918af78..8fbdde81 100644 --- a/core/code/pprof.go +++ b/core/code/pprof.go @@ -89,5 +89,5 @@ func init() { m.Render(ice.RENDER_VOID) }}, }, - }, nil) + }) } diff --git a/core/code/publish.go b/core/code/publish.go index 3d1018eb..ab20424d 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -95,7 +95,7 @@ func init() { m.Cmdy(nfs.DIR, kit.Select("", arg, 0), "time size path link") }}, }, - }, nil) + }) } var _contexts = kit.Dict( diff --git a/core/code/upgrade.go b/core/code/upgrade.go index f92a079b..f99ad116 100644 --- a/core/code/upgrade.go +++ b/core/code/upgrade.go @@ -41,5 +41,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/core/code/vimer.go b/core/code/vimer.go index 1cb70472..aea22fa0 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -35,5 +35,5 @@ func init() { m.Cmdy(INNER, arg) }}, }, - }, nil) + }) } diff --git a/core/mall/asset.go b/core/mall/asset.go index 58317417..fc9ef662 100644 --- a/core/mall/asset.go +++ b/core/mall/asset.go @@ -158,5 +158,5 @@ func init() { _asset_list(m, kit.Select("", arg, 0), kit.Select("", arg, 1)) }}, }, - }, nil) + }) } diff --git a/core/mall/salary.go b/core/mall/salary.go index 7dfe9128..dda59e6d 100644 --- a/core/mall/salary.go +++ b/core/mall/salary.go @@ -32,5 +32,5 @@ func init() { m.Cmdy(mdb.SELECT, SALARY, "", mdb.HASH, "month", arg) }}, }, - }, nil) + }) } diff --git a/core/team/plan.go b/core/team/plan.go index 484f267d..09582ac7 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -73,5 +73,5 @@ func init() { m.Cmd(mdb.SELECT, TASK, "", mdb.ZONE, kit.MDB_FOREACH) }}, }, - }, nil) + }) } diff --git a/core/team/task.go b/core/team/task.go index addcd409..9270c1e3 100644 --- a/core/team/task.go +++ b/core/team/task.go @@ -174,5 +174,5 @@ func init() { _task_list(m, kit.Select("", arg, 0), kit.Select("", arg, 1)) }}, }, - }, nil) + }) } diff --git a/core/wiki/data.go b/core/wiki/data.go index 65a89e42..53b91d2c 100644 --- a/core/wiki/data.go +++ b/core/wiki/data.go @@ -30,5 +30,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 4262244d..6378e17c 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -31,5 +31,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/core/wiki/feel.go b/core/wiki/feel.go index 56e0cb4e..d1ac951a 100644 --- a/core/wiki/feel.go +++ b/core/wiki/feel.go @@ -31,5 +31,5 @@ func init() { m.SortTimeR(kit.MDB_TIME) }}, }, - }, nil) + }) } diff --git a/core/wiki/word.go b/core/wiki/word.go index 9125e9ab..0a40d581 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -469,5 +469,5 @@ func init() { _word_show(m, arg[0]) }}, }, - }, nil) + }) } diff --git a/misc/chrome/cache.go b/misc/chrome/cache.go index 39d12a8d..9c8d4ecb 100644 --- a/misc/chrome/cache.go +++ b/misc/chrome/cache.go @@ -72,5 +72,5 @@ func init() { m.Cmdy(mdb.SELECT, m.Prefix(CACHE), "", mdb.HASH) }}, }, - }, nil) + }) } diff --git a/misc/chrome/favor.go b/misc/chrome/favor.go index a4f06db0..a8b39a5d 100644 --- a/misc/chrome/favor.go +++ b/misc/chrome/favor.go @@ -59,5 +59,5 @@ func init() { m.PushAction("删除") }}, }, - }, nil) + }) } diff --git a/misc/chrome/spide.go b/misc/chrome/spide.go index 0dedb79c..22efad82 100644 --- a/misc/chrome/spide.go +++ b/misc/chrome/spide.go @@ -41,5 +41,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/misc/chrome/sync.go b/misc/chrome/sync.go index be6c7e4a..2ad8f192 100644 --- a/misc/chrome/sync.go +++ b/misc/chrome/sync.go @@ -59,5 +59,5 @@ func init() { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }}, }, - }, nil) + }) } diff --git a/misc/git/repos.go b/misc/git/repos.go index b991b2f5..32143e24 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -70,5 +70,5 @@ func init() { m.Sort(kit.MDB_NAME) }}, }, - }, nil) + }) } diff --git a/misc/git/spide.go b/misc/git/spide.go index ca694431..8a925cd1 100644 --- a/misc/git/spide.go +++ b/misc/git/spide.go @@ -83,5 +83,5 @@ func init() { m.SortInt(kit.MDB_LINE) }}, }, - }, nil) + }) } diff --git a/misc/git/status.go b/misc/git/status.go index 33849f92..c6cdb6f2 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -111,5 +111,5 @@ func init() { m.Sort(kit.MDB_NAME) }}, }, - }, nil) + }) } diff --git a/misc/git/total.go b/misc/git/total.go index 6ebaf8a8..e84701a4 100644 --- a/misc/git/total.go +++ b/misc/git/total.go @@ -143,5 +143,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/misc/git/trend.go b/misc/git/trend.go index a892a0a1..fe42e875 100644 --- a/misc/git/trend.go +++ b/misc/git/trend.go @@ -19,5 +19,5 @@ func init() { m.Cmdy(TOTAL, arg) }}, }, - }, nil) + }) } diff --git a/misc/tmux/tmux.go b/misc/tmux/tmux.go index 10211ce9..c4904349 100644 --- a/misc/tmux/tmux.go +++ b/misc/tmux/tmux.go @@ -50,8 +50,13 @@ var Index = &ice.Context{Name: TMUX, Help: "工作台", )}, }, Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }}, + ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Load() + m.Watch(web.DREAM_START, m.Prefix(SESSION)) + }}, + ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Save() + }}, TMUX: {Name: "tmux port path auto start build download", Help: "服务", Action: map[string]*ice.Action{ web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) { @@ -156,6 +161,9 @@ var Index = &ice.Context{Name: TMUX, Help: "工作台", m.PushAction(mdb.REMOVE) }}, SESSION: {Name: "session session window pane cmd auto create script", Help: "会话管理", Action: map[string]*ice.Action{ + web.DREAM_START: {Name: "dream.start type name share river", Help: "梦想", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(m.Prefix(SESSION), mdb.CREATE) + }}, mdb.CREATE: {Name: "create name", Help: "添加", Hand: func(m *ice.Message, arg ...string) { m.Option(cli.CMD_ENV, "TMUX", "") if m.Option(PANE) != "" { diff --git a/misc/vim/favor.go b/misc/vim/favor.go index c2002964..781f166b 100644 --- a/misc/vim/favor.go +++ b/misc/vim/favor.go @@ -82,5 +82,5 @@ func init() { }) }}, }, - }, nil) + }) } diff --git a/misc/vim/input.go b/misc/vim/input.go index ed569bee..cc0f7766 100644 --- a/misc/vim/input.go +++ b/misc/vim/input.go @@ -64,5 +64,5 @@ func init() { m.Cmd(mdb.INSERT, m.Prefix(INPUT), "", mdb.LIST, kit.MDB_TYPE, "wubi", kit.MDB_NAME, arg[0], kit.MDB_TEXT, m.Result()) }}, }, - }, nil) + }) } diff --git a/misc/vim/sess.go b/misc/vim/sess.go index f6530d73..897ddd09 100644 --- a/misc/vim/sess.go +++ b/misc/vim/sess.go @@ -86,5 +86,5 @@ func init() { m.Render(ice.RENDER_RESULT) }}, }, - }, nil) + }) } diff --git a/misc/vim/sync.go b/misc/vim/sync.go index 8d0ab122..92c52344 100644 --- a/misc/vim/sync.go +++ b/misc/vim/sync.go @@ -54,5 +54,5 @@ func init() { "pwd", m.Option("pwd"), "buf", m.Option("buf"), "row", m.Option("row"), "col", m.Option("col")) }}, }, - }, nil) + }) } diff --git a/misc/zsh/bash.go b/misc/zsh/bash.go index ed7b088b..ccea0823 100644 --- a/misc/zsh/bash.go +++ b/misc/zsh/bash.go @@ -34,5 +34,5 @@ func init() { m.Cmdy(code.INSTALL, path.Base(m.Conf(BASH, kit.META_SOURCE)), arg) }}, }, - }, nil) + }) } diff --git a/misc/zsh/download.go b/misc/zsh/download.go index edef185f..a10e7ff8 100644 --- a/misc/zsh/download.go +++ b/misc/zsh/download.go @@ -37,5 +37,5 @@ func init() { m.Echo("size: %s\n", msg.Append("size")) }}, }, - }, nil) + }) } diff --git a/misc/zsh/favor.go b/misc/zsh/favor.go index 5b6da3cb..c1ecf2c8 100644 --- a/misc/zsh/favor.go +++ b/misc/zsh/favor.go @@ -74,5 +74,5 @@ func init() { m.Cmdy(m.Prefix(FAVOR)).Table() }}, }, - }, nil) + }) } diff --git a/misc/zsh/input.go b/misc/zsh/input.go index 37160cc5..008f9dcd 100644 --- a/misc/zsh/input.go +++ b/misc/zsh/input.go @@ -104,5 +104,5 @@ func init() { m.Info("trans: %v", m.Result()) }}, }, - }, nil) + }) } diff --git a/misc/zsh/sess.go b/misc/zsh/sess.go index b572c34c..20c0490f 100644 --- a/misc/zsh/sess.go +++ b/misc/zsh/sess.go @@ -71,5 +71,5 @@ func init() { m.Echo(m.Option(SID)) }}, }, - }, nil) + }) } diff --git a/misc/zsh/sync.go b/misc/zsh/sync.go index 81a6a7a3..48fe6faa 100644 --- a/misc/zsh/sync.go +++ b/misc/zsh/sync.go @@ -68,5 +68,5 @@ func init() { } }}, }, - }, nil) + }) } diff --git a/misc/zsh/trash.go b/misc/zsh/trash.go index 67a04a23..43355d73 100644 --- a/misc/zsh/trash.go +++ b/misc/zsh/trash.go @@ -54,5 +54,5 @@ func init() { "size", m.Option("size"), "from", m.Option("from"), "to", m.Option("to")) }}, }, - }, nil) + }) } diff --git a/type.go b/type.go index 5cfb0f23..6ba9274c 100644 --- a/type.go +++ b/type.go @@ -143,7 +143,7 @@ func (c *Context) Register(s *Context, x Server, name ...string) *Context { for _, n := range name { Name(n, s) } - s.Merge(s, x) + s.Merge(s) if c.contexts == nil { c.contexts = map[string]*Context{} @@ -154,7 +154,7 @@ func (c *Context) Register(s *Context, x Server, name ...string) *Context { s.server = x return s } -func (c *Context) Merge(s *Context, x Server) *Context { +func (c *Context) Merge(s *Context) *Context { if c.Commands == nil { c.Commands = map[string]*Command{} } @@ -195,8 +195,6 @@ func (c *Context) Merge(s *Context, x Server) *Context { for k, v := range s.Caches { c.Caches[k] = v } - - s.server = x return c } func (c *Context) _split(name string) []interface{} {