From f0ce8e75ef147ab40bde5e98d6753368050cab5b Mon Sep 17 00:00:00 2001 From: harveyshao Date: Wed, 10 Nov 2021 12:47:57 +0800 Subject: [PATCH] opt some --- base/cli/system.go | 2 +- base/tcp/port.go | 3 ++- core/chat/cmd.go | 2 +- core/chat/river.go | 4 +++- core/code/autogen.go | 6 +++--- core/code/compile.go | 10 +++++++--- core/code/vimer.go | 5 ++--- data.go | 2 +- 8 files changed, 20 insertions(+), 14 deletions(-) diff --git a/base/cli/system.go b/base/cli/system.go index a479cf09..09d74a6c 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -76,7 +76,7 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) { m.Push(kit.MDB_CODE, int(cmd.ProcessState.ExitCode())) } func IsSuccess(m *ice.Message) bool { - return m.Append(kit.MDB_CODE) == "0" + return m.Append(kit.MDB_CODE) == "0" || m.Append(kit.MDB_CODE) == "" } const ( diff --git a/base/tcp/port.go b/base/tcp/port.go index afad97d0..cab26ea8 100644 --- a/base/tcp/port.go +++ b/base/tcp/port.go @@ -56,7 +56,8 @@ func init() { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { m.Option(nfs.DIR_ROOT, m.Conf(cli.DAEMON, kit.META_PATH)) - m.Cmd(nfs.DIR, "./").Table(func(index int, value map[string]string, head []string) { + m.Cmd(nfs.DIR, "./", "time,path,size").Table(func(index int, value map[string]string, head []string) { + m.Debug("what %v", value) m.Push(kit.MDB_TIME, value[kit.MDB_TIME]) m.Push(PORT, path.Base(value[kit.MDB_PATH])) m.Push(kit.MDB_SIZE, value[kit.MDB_SIZE]) diff --git a/core/chat/cmd.go b/core/chat/cmd.go index e6eff316..1b22f863 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -37,7 +37,7 @@ func init() { } p := path.Join(m.Config(kit.MDB_PATH), path.Join(arg...)) - if mdb.HashSelect(m, kit.Ext(m.R.URL.Path)).Table(func(index int, value map[string]string, head []string) { + if mdb.HashSelect(m.Spawn(), kit.Ext(m.R.URL.Path)).Table(func(index int, value map[string]string, head []string) { m.RenderCmd(value[kit.MDB_NAME], p) }).Length() > 0 { return // 插件 diff --git a/core/chat/river.go b/core/chat/river.go index 719146da..3246b253 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -109,7 +109,6 @@ func init() { return // 没有授权 } - m.Debug("what %v-------", arg) switch kit.Select("", arg, 1) { case STORM, OCEAN, NODE: m.Option(ice.MSG_RIVER, arg[0]) @@ -129,6 +128,9 @@ func init() { case cli.START: m.Cmdy(web.DREAM, ctx.ACTION, mdb.INPUTS, arg) return + case "创建空间": + m.Cmdy(web.DREAM, ctx.ACTION, mdb.INPUTS, arg) + return } switch arg[0] { diff --git a/core/code/autogen.go b/core/code/autogen.go index c73594f5..7a5a420a 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -157,11 +157,11 @@ func init() { _defs(m, kit.MDB_KEY, kit.Keys("web.code", m.Option(kit.MDB_ZONE), m.Option(kit.MDB_NAME))) switch m.Option(kit.MDB_TYPE) { case "Zone": - _defs(m, "list", "list zone id auto insert") + _defs(m, "list", m.Option(kit.MDB_NAME)+" zone id auto insert") case "Hash": - _defs(m, "list", "list hash auto create") + _defs(m, "list", m.Option(kit.MDB_NAME)+" hash auto create") case "Data": - _defs(m, "list", "list path auto upload") + _defs(m, "list", m.Option(kit.MDB_NAME)+" path auto upload") } m.Option("tag", kit.Format("`name:\"%s\" help:\"%s\"`", m.Option("list"), m.Option("help"))) diff --git a/core/code/compile.go b/core/code/compile.go index 45af316c..f4b22119 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -36,7 +36,7 @@ func init() { } // 交叉编译 - main := ice.SRC_MAIN_GO + main, file := ice.SRC_MAIN_GO, "" goos := m.Conf(cli.RUNTIME, kit.Keys(tcp.HOST, cli.GOOS)) arch := m.Conf(cli.RUNTIME, kit.Keys(tcp.HOST, cli.GOARCH)) for _, k := range arg { @@ -48,11 +48,15 @@ func init() { default: if kit.Ext(k) == GO { main = k + } else { + file = k } } } - file := path.Join(kit.Select("", m.Config(nfs.PATH), m.Option(cli.CMD_DIR) == ""), - kit.Keys(kit.Select(ice.ICE, kit.TrimExt(main), main != ice.SRC_MAIN_GO), goos, arch)) + if file == "" { + file = path.Join(kit.Select("", m.Config(nfs.PATH), m.Option(cli.CMD_DIR) == ""), + kit.Keys(kit.Select(ice.ICE, kit.TrimExt(main), main != ice.SRC_MAIN_GO), goos, arch)) + } // 执行编译 _autogen_version(m.Spawn()) diff --git a/core/code/vimer.go b/core/code/vimer.go index 2f23f939..d07b9d2e 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -43,9 +43,8 @@ func init() { m.ProcessInner() }}, COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(COMPILE, ice.SRC_MAIN_GO) - m.Cmdy(nfs.LINK, ice.BIN_ICE_BIN, m.Append(nfs.PATH)) - if cli.IsSuccess(m) { + if m.Cmdy(COMPILE, ice.SRC_MAIN_GO); cli.IsSuccess(m) { + m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN) m.Cmd(ice.EXIT, "1") } m.ProcessInner() diff --git a/data.go b/data.go index a8b5a565..48192064 100644 --- a/data.go +++ b/data.go @@ -9,7 +9,7 @@ import ( ) func (m *Message) CommandKey() string { - return strings.TrimSuffix(strings.TrimPrefix(m._key, "/"), "/") + return strings.TrimSuffix(strings.TrimPrefix(m._key, PS), PS) } func (m *Message) PrefixKey(arg ...string) string { return kit.Keys(m.Cap(CTX_FOLLOW), m.CommandKey(), arg)