diff --git a/base/cli/system.go b/base/cli/system.go index b40dd0cd..cd2f3311 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -144,7 +144,7 @@ const SYSTEM = "system" func init() { Index.MergeCommands(ice.Commands{ - SYSTEM: {Name: "system cmd auto", Help: "系统命令", Actions: ice.MergeActions(ice.Actions{ + SYSTEM: {Name: "system cmd", Help: "系统命令", Actions: ice.MergeActions(ice.Actions{ nfs.PUSH: {Hand: func(m *ice.Message, arg ...string) { for _, p := range arg { if !strings.Contains(m.Cmdx(nfs.CAT, ice.ETC_PATH), p) { diff --git a/base/ctx/command.go b/base/ctx/command.go index abd11ef2..078f5049 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -55,7 +55,7 @@ func _command_search(m *ice.Message, kind, name, text string) { if name != "" && !strings.HasPrefix(key, name) && !strings.Contains(s.Name, name) { return } - m.PushSearch(ice.CTX, kit.PathName(1), ice.CMD, kit.FileName(1), kit.SimpleKV("", s.Cap(ice.CTX_FOLLOW), cmd.Name, cmd.Help), + m.PushSearch(ice.CTX, kit.PathName(1), ice.CMD, kit.FileName(1), kit.SimpleKV("", s.Cap(ice.CTX_FOLLOW), kit.Select(key, cmd.Name), kit.Select(key, cmd.Help)), CONTEXT, s.Cap(ice.CTX_FOLLOW), COMMAND, key, INDEX, kit.Keys(s.Cap(ice.CTX_FOLLOW), key), mdb.HELP, cmd.Help, nfs.FILE, FileURI(cmd.GetFileLines()), ) diff --git a/base/mdb/hash.go b/base/mdb/hash.go index 72fe3478..9cc1984b 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -262,6 +262,12 @@ func HashSelectField(m *ice.Message, key string, field string) (value string) { func HashSelectTarget(m *ice.Message, key string, create Any) (target Any) { HashSelectUpdate(m, key, func(value ice.Map) { target = value[TARGET] + if _target, ok := target.([]string); ok && len(_target) == 0 { + target = nil + } + if _target, ok := target.(ice.List); ok && len(_target) == 0 { + target = nil + } if _target, ok := target.(Map); ok && len(_target) == 0 { target = nil } diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index 0cb9594f..3c39c900 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -13,6 +13,7 @@ import ( type Any = interface{} type Map = map[string]Any type Maps = map[string]string +type List = []interface{} func _file_name(m *ice.Message, arg ...string) string { if len(arg) > 3 && strings.Contains(arg[3], ice.PS) { diff --git a/base/web/cache.go b/base/web/cache.go index cecf6491..61418783 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -12,6 +12,7 @@ import ( "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" + "shylinux.com/x/icebergs/base/tcp" kit "shylinux.com/x/toolkits" "shylinux.com/x/toolkits/miss" ) @@ -181,7 +182,7 @@ func RenderCache(m *ice.Message, h string) { func Upload(m *ice.Message) []string { if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(up) == 1 { if m.Cmdy(CACHE, UPLOAD).Optionv(ice.MSG_UPLOAD, kit.Simple(m.Append(mdb.HASH), m.Append(mdb.NAME), m.Append(nfs.SIZE))); m.Option(ice.MSG_USERPOD) != "" { - m.Cmd(SPACE, m.Option(ice.MSG_USERPOD), SPIDE, ice.DEV, SPIDE_CACHE, http.MethodGet, MergeURL2(m, path.Join(SHARE_CACHE, m.Append(mdb.HASH)))) + m.Cmd(SPACE, m.Option(ice.MSG_USERPOD), SPIDE, ice.DEV, SPIDE_CACHE, http.MethodGet, tcp.PublishLocalhost(m, MergeURL2(m, path.Join(SHARE_CACHE, m.Append(mdb.HASH))))) } return kit.Simple(m.Optionv(ice.MSG_UPLOAD)) } else { diff --git a/base/web/option.go b/base/web/option.go index af506301..0d420a3c 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -26,11 +26,7 @@ func PushNotice(m *ice.Message, arg ...ice.Any) { msg.Optionv(ice.MSG_OPTS, msg.Optionv(ice.MSG_OPTION, []string{})) msg.Cmd(SPACE, m.Option(ice.MSG_DAEMON), arg) } else { - opts := kit.Dict(ice.POD, m.Option(ice.MSG_DAEMON), "cmds", kit.Simple(arg...)) - for _, k := range kit.Simple(m.Optionv(ice.MSG_OPTS)) { - opts[k] = m.Option(k) - } - m.Cmd("web.spide", ice.OPS, MergeURL2(m, SHARE_TOAST), kit.Format(opts)) + m.Cmd("web.spide", ice.OPS, MergeURL2(m, SHARE_TOAST+m.Option(ice.MSG_DAEMON)), "arg", kit.Format(arg)) } } func PushNoticeGrow(m *ice.Message, arg ...ice.Any) { @@ -53,9 +49,9 @@ func ToastProcess(m *ice.Message, arg ...ice.Any) func() { Toast(m, ice.PROCESS, arg...) return func() { Toast(m, ice.SUCCESS) } } -func ToastRestart(m *ice.Message, arg ...ice.Any) { Toast(m, gdb.RESTART, arg...) } -func ToastFailure(m *ice.Message, arg ...ice.Any) { Toast(m, ice.FAILURE, arg...) } -func ToastSuccess(m *ice.Message, arg ...ice.Any) { Toast(m, ice.SUCCESS, arg...) } +func ToastRestart(m *ice.Message, arg ...ice.Any) { Toast(m, gdb.RESTART, arg...) } +func ToastFailure(m *ice.Message, arg ...ice.Any) { Toast(m, ice.FAILURE, arg...) } +func ToastSuccess(m *ice.Message, arg ...ice.Any) { Toast(m, ice.SUCCESS, arg...) } func Toast(m *ice.Message, text string, arg ...ice.Any) { // [title [duration [progress]]] if len(arg) > 1 { switch val := arg[1].(type) { @@ -159,9 +155,9 @@ func MergePodWebSite(m Message, pod, web string, arg ...ice.Any) string { func ProcessWebsite(m *ice.Message, pod, cmd string, arg ...ice.Any) { m.ProcessOpen(MergePodCmd(m, pod, cmd, arg...)) } -func ProcessIframe(m *ice.Message, link string, arg ...string) { +func ProcessIframe(m *ice.Message, name, link string, arg ...string) { if len(arg) == 0 || arg[0] != ice.RUN { - arg = []string{m.Cmdx("web.chat.iframe", mdb.CREATE, mdb.TYPE, LINK, mdb.NAME, "", LINK, link)} + arg = []string{m.Cmdx("web.chat.iframe", mdb.CREATE, mdb.TYPE, LINK, mdb.NAME, name, LINK, link)} } ctx.ProcessField(m, "web.chat.iframe", arg, arg...) } diff --git a/base/web/serve.go b/base/web/serve.go index f02e89e7..d81eb765 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -220,7 +220,7 @@ func init() { PP(ice.REQUIRE, ice.NODE_MODULES): {Name: "/require/node_modules/", Help: "依赖库", Hand: func(m *ice.Message, arg ...string) { p := path.Join(ice.SRC, ice.NODE_MODULES, path.Join(arg...)) if !nfs.ExistsFile(m, p) { - m.Cmd(cli.SYSTEM, "npm", "install", arg[0], kit.Dict(cli.CMD_DIR, path.Join(ice.SRC))) + m.Cmd(cli.SYSTEM, "npm", "install", arg[0], kit.Dict(cli.CMD_DIR, ice.SRC)) } m.RenderDownload(p) }}, diff --git a/base/web/share.go b/base/web/share.go index ed60a27b..5161209b 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -157,7 +157,7 @@ func init() { m.RenderDownload(strings.TrimPrefix(m.CmdAppend(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.BACKGROUND), SHARE_LOCAL)) }}, SHARE_PROXY: {Hand: func(m *ice.Message, arg ...string) { _share_proxy(m) }}, - SHARE_TOAST: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, m.Option(ice.POD), m.Optionv("cmds")) }}, + SHARE_TOAST: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, arg[0], kit.UnMarshal(m.Option("arg"))) }}, }) } func IsNotValidShare(m *ice.Message, time string) bool { diff --git a/core/chat/pod.go b/core/chat/pod.go index 768c8fa1..5ab25dc5 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -32,7 +32,7 @@ func init() { web.RenderCmd(m, web.SPACE) } else if len(arg) == 1 { if m.Cmd(web.SPACE, arg[0]).Length() == 0 && !strings.Contains(arg[0], ice.PT) { - m.Cmd(web.DREAM, cli.START, mdb.NAME, arg[0]) + m.Cmd(web.DREAM, cli.START, kit.Dict(mdb.NAME, arg[0])) } web.RenderMain(aaa.UserRoot(m), arg[0], "") } else if arg[1] == CMD { diff --git a/core/code/xterm.go b/core/code/xterm.go index c60cbb63..958ccd9a 100644 --- a/core/code/xterm.go +++ b/core/code/xterm.go @@ -50,8 +50,7 @@ func _xterm_get(m *ice.Message, h string) _xterm { for { if n, e := tty.Read(buf); !m.Warn(e) && e == nil { m.Option(ice.MSG_DAEMON, mdb.HashSelectField(m, h, "view")) - m.Option(mdb.TEXT, string(buf[:n])) - web.PushNoticeGrow(m) + web.PushNoticeGrow(m, string(buf[:n])) } else { break } @@ -94,6 +93,10 @@ func init() { _xterm_get(m, "").Write(string(b)) } }}, + "debug": {Help: "日志", Hand: func(m *ice.Message, arg ...string) { + _xterm_get(m, kit.Select("", arg, 0)).Write("cd ~/contexts; tail -f var/log/bench.log" + ice.NL) + ctx.ProcessHold(m) + }}, INSTALL: {Help: "安装", Hand: func(m *ice.Message, arg ...string) { _xterm_get(m, kit.Select("", arg, 0)).Write(m.Cmdx(PUBLISH, ice.CONTEXTS, INSTALL) + ice.NL) ctx.ProcessHold(m) @@ -104,7 +107,7 @@ func init() { m.PushAction(web.WEBSITE, mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES) } else { ctx.Toolkit(m, FAVOR, "web.chat.iframe") - m.Action(INSTALL, "波浪线", "反引号") + m.Action(INSTALL, "debug", "波浪线", "反引号") ctx.DisplayLocal(m, "") } }}, diff --git a/misc.go b/misc.go index fb6f309a..405ab726 100644 --- a/misc.go +++ b/misc.go @@ -221,6 +221,7 @@ func (m *Message) _command(arg ...Any) *Message { defer func() { m.Table(val) }() case func(Maps): defer func() { m.Tables(val) }() + case nil: default: if reflect.TypeOf(val).Kind() == reflect.Func { cbs = val diff --git a/misc/git/configs.go b/misc/git/configs.go index c18fc703..b39d43d5 100644 --- a/misc/git/configs.go +++ b/misc/git/configs.go @@ -21,7 +21,7 @@ func _configs_read(m *ice.Message, p string) ice.Maps { res, block := ice.Maps{}, "" m.Cmd(nfs.CAT, p, func(text string) { if strings.HasPrefix(text, "[") { - block = kit.Join(kit.Split(text, " []"), ".") + block = kit.Join(kit.Split(text, " []"), ice.PT) return } ls := kit.Split(text, " =") diff --git a/misc/git/server.go b/misc/git/server.go index 3505d119..575410a8 100644 --- a/misc/git/server.go +++ b/misc/git/server.go @@ -13,6 +13,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" + "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -114,7 +115,7 @@ func init() { m.Warn(_server_repos(m, arg...), ice.ErrNotValid) }}}) Index.MergeCommands(ice.Commands{ - SERVER: {Name: "server path commit auto create import", Help: "服务器", Actions: ice.MergeActions(ice.Actions{ + SERVER: {Name: "server repos branch commit path auto create import", Help: "服务器", Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create name*", Hand: func(m *ice.Message, arg ...string) { _repos_init(m, path.Join(ice.USR_LOCAL_REPOS, m.Option(mdb.NAME))) }}, @@ -136,10 +137,33 @@ func init() { m.Cmd("", func(value ice.Maps) { m.Push(nfs.PATH, _git_url(m, value[nfs.PATH])) }) } }}, + "inner": {Help: "编辑器", Hand: func(m *ice.Message, arg ...string) { + if len(arg) == 0 || arg[0] != ice.RUN { + arg = []string{path.Join(ice.USR_LOCAL_REPOS, arg[0]), kit.Select("README.md", arg, 3)} + } else if kit.Select("", arg, 1) != ctx.ACTION { + if dir := path.Join(ice.USR_LOCAL_REPOS, m.Option(REPOS)); len(arg) < 3 { + _repos_dir(m, dir, m.Option(BRANCH), m.Option(COMMIT), kit.Select("", arg, 1), nil) + } else { + _repos_cat(m, dir, m.Option(BRANCH), m.Option(COMMIT), arg[2]) + ctx.DisplayLocal(m, "code/inner.js") + } + return + } + ctx.ProcessField(m, "", arg, arg...) + }}, }, gdb.EventAction(web.DREAM_INPUTS)), Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_REPOS); len(arg) == 0 { - m.Cmdy(nfs.DIR, nfs.PWD, func(value ice.Maps) { m.PushScript("git clone " + _git_url(m, value[nfs.PATH])) }).Cut("time,path,size,script,action") + m.Cmdy(nfs.DIR, nfs.PWD, func(value ice.Maps) { m.PushScript("git clone " + _git_url(m, value[nfs.PATH])) }).Cut("time,path,size,script,action").RenameAppend("path", "repos") + } else if dir := path.Join(m.Option(nfs.DIR_ROOT), arg[0]); len(arg) == 1 { + _repos_branch(m, dir) + } else if len(arg) == 2 { + _repos_commit(m, dir, arg[1], nil) + } else if len(arg) == 3 || arg[3] == "" || strings.HasSuffix(arg[3], ice.PS) { + _repos_dir(m, dir, arg[1], arg[2], kit.Select("", arg, 3), nil) + } else { + m.Cmdy("", "inner", arg) } + m.StatusTimeCount() }}, }) }