From fc85438a013ef986e10755fcf44c9c97a6c28355 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sat, 23 Apr 2022 09:16:10 +0800 Subject: [PATCH] opt some --- base/cli/forever.go | 6 ++++++ base/cli/system.go | 2 ++ core/chat/header.go | 7 +++++-- core/code/publish.go | 8 ++++---- misc/tmux/buffer.go | 8 ++++++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/base/cli/forever.go b/base/cli/forever.go index 964b380a..00d8a36d 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -17,8 +17,14 @@ const FOREVER = "forever" func init() { const SERVE = "serve" + const RESTART = "restart" Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ FOREVER: {Name: "forever", Help: "启动", Action: map[string]*ice.Action{ + RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) { + if p := m.Cmdx(nfs.CAT, m.Conf("gdb.signal", kit.Keym(nfs.PATH))); p != "" { + m.Cmd(SYSTEM, "kill", "-s", "INT", p) + } + }}, SERVE: {Name: "serve", Help: "服务", Hand: func(m *ice.Message, arg ...string) { env := []string{PATH, BinPath(), HOME, kit.Select(kit.Path(""), os.Getenv(HOME))} for _, k := range []string{TERM, SHELL, CTX_SHY, CTX_DEV, CTX_OPS, CTX_ARG, CTX_PID, CTX_USER, CTX_SHARE, CTX_RIVER} { diff --git a/base/cli/system.go b/base/cli/system.go index 08dad4c4..885c221f 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -3,6 +3,7 @@ package cli import ( "bytes" "io" + "os" "os/exec" "path" "strings" @@ -58,6 +59,7 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd { if len(cmd.Env) > 0 { m.Log_EXPORT(CMD_ENV, cmd.Env) } + m.Debug("wht%v", os.Getenv(PATH)) return cmd } func _system_out(m *ice.Message, out string) io.Writer { diff --git a/core/chat/header.go b/core/chat/header.go index 1376518a..c831a3b8 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -125,13 +125,16 @@ func init() { _header_users(m, m.ActionKey(), arg...) }}, - "local": {Name: "local", Help: "配置", Hand: func(m *ice.Message, arg ...string) { + "config": {Name: "config", Help: "配置", Hand: func(m *ice.Message, arg ...string) { pod := strings.Split(m.Cmdx(web.SPACE, m.Option(ice.MSG_USERPOD), cli.RUNTIME, "make.domain"), "/chat/pod/")[1] m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), nfs.SAVE, "etc/local.shy", m.Cmdx(web.SPACE, pod, nfs.CAT, "etc/local.shy")) m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), ssh.SOURCE, "etc/local.shy") }}, + "source": {Name: "source", Help: "源码", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), cli.SYSTEM, "git", "push", "-u", m.MergeURL2("/x/")+m.Option(ice.MSG_USERPOD)) + }}, aaa.INVITE: {Name: "invite", Help: "脚本", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.CORE) + m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.CORE, ice.MISC) m.Cmd(code.PUBLISH, mdb.CREATE, nfs.FILE, ice.BIN_ICE_BIN) }}, code.WEBPACK: {Name: "webpack", Help: "打包页面", Hand: func(m *ice.Message, arg ...string) { diff --git a/core/code/publish.go b/core/code/publish.go index 91bbd5b5..741dafb9 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -148,13 +148,13 @@ func init() { } var _contexts = kit.Dict( - ice.MISC, `# 完整版 -export ctx_dev={{.Option "httphost"}}; ctx_temp=$(mktemp); curl -fsSL $ctx_dev -o $ctx_temp; source $ctx_temp dev + ice.MISC, `# 源码下载 +git clone {{.Option "httphost"}}/x/{{.Option "user.pod"}}; cd {{.Option "user.pod"}} && source etc/miss.sh port 9020 `, - ice.CORE, `# 标准版 + ice.CORE, `# 命令下载 export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); wget -O $ctx_temp $ctx_dev; source $ctx_temp app `, - ice.BASE, `# 官方版 + ice.BASE, `# 官方下载 ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL {{.Cmdx "spide" "shy" "url"}}; source $ctx_temp binary ctx_temp=$(mktemp); wget -O $ctx_temp {{.Cmdx "spide" "shy" "url"}}; source $ctx_temp binary `, diff --git a/misc/tmux/buffer.go b/misc/tmux/buffer.go index 7f928339..26bdf785 100644 --- a/misc/tmux/buffer.go +++ b/misc/tmux/buffer.go @@ -87,8 +87,12 @@ func init() { }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { text := m.Cmdx(cli.SYSTEM, TMUX, "show-buffer") - m.EchoQRCode(text) - m.EchoScript(text) + if m.EchoQRCode(text); strings.HasPrefix(text, ice.HTTP) { + m.Echo(ice.NL) + m.EchoAnchor(text) + } else { + m.EchoScript(text) + } }}, }}) }