diff --git a/base/cli/system.go b/base/cli/system.go index 50be2242..652109b6 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -43,6 +43,8 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd { cmd.Path = file } } + if _system_find(m, cmd.Path) == "" { + } m.Debug("cmd: %v", cmd.Path) if len(cmd.Env) > 0 { diff --git a/base/web/dream.go b/base/web/dream.go index 399c2b08..9e3736cf 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -70,7 +70,7 @@ func _dream_show(m *ice.Message, name string) { return // 已经启动 } - defer m.ToastProcess() + defer m.ToastProcess()() m.Optionv(cli.CMD_DIR, p) m.Optionv(cli.CMD_ENV, kit.Simple( @@ -83,8 +83,11 @@ func _dream_show(m *ice.Message, name string) { // 启动任务 bin := kit.Select(os.Args[0], cli.SystemFind(m, ice.ICE_BIN, kit.Path(path.Join(p, ice.BIN)), kit.Path(ice.BIN))) m.Cmd(cli.DAEMON, bin, SPACE, tcp.DIAL, ice.DEV, ice.OPS, m.OptionSimple(mdb.NAME, RIVER)) - defer m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...) + m.Sleep3s() + m.Option(cli.CMD_ENV, "") + m.Option(cli.CMD_OUTPUT, "") + m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...) } const ( diff --git a/core/code/binpack.go b/core/code/binpack.go index a39d1260..eea90c71 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -146,10 +146,14 @@ func init() { } }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - for k, v := range ice.Info.Pack { - m.Push(mdb.NAME, k).Push(nfs.SIZE, len(v)) + if len(arg) == 0 { + for k, v := range ice.Info.Pack { + m.Push(nfs.PATH, k).Push(nfs.SIZE, len(v)) + } + m.Sort(nfs.PATH) + return } - m.Sort(mdb.NAME) + m.Echo(string(ice.Info.Pack[arg[0]])) }}, }}) } diff --git a/core/code/py.go b/core/code/py.go index f2dc70ef..ca46e497 100644 --- a/core/code/py.go +++ b/core/code/py.go @@ -1,6 +1,8 @@ package code import ( + "path" + ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/mdb" @@ -8,11 +10,14 @@ import ( ) const PY = "py" +const ( + PYTHON2 = "python2" +) func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ PY: {Name: "py", Help: "脚本", Value: kit.Data(INSTALL, kit.List(kit.Dict( - cli.OSID, cli.ALPINE, ice.CMD, kit.List("apk", "add", "python2"), + cli.OSID, cli.ALPINE, ice.CMD, kit.List("apk", "add", PYTHON2), )))}, }, Commands: map[string]*ice.Command{ PY: {Name: "py", Help: "脚本", Action: map[string]*ice.Action{ @@ -20,10 +25,16 @@ func init() { m.Cmd(mdb.ENGINE, mdb.CREATE, PY, m.PrefixKey()) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { - if !InstallSoftware(m.Spawn(), "python2", m.Configv(INSTALL)) { + if !InstallSoftware(m.Spawn(), PYTHON2, m.Configv(INSTALL)) { return } - m.Cmdy(cli.SYSTEM, "python2", kit.Path(arg[2], arg[1])) + if kit.FileExists(kit.Path(arg[2], arg[1])) { + m.Cmdy(cli.SYSTEM, PYTHON2, kit.Path(arg[2], arg[1])) + } else if b, ok := ice.Info.Pack[path.Join(arg[2], arg[1])]; ok && len(b) > 0 { + m.Cmdy(cli.SYSTEM, PYTHON2, "-c", string(b)) + } else { + m.Debug("what %v %v", b, ok) + } m.Echo(ice.NL) }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { diff --git a/core/code/sh.go b/core/code/sh.go index fccd6015..3c5edb5b 100644 --- a/core/code/sh.go +++ b/core/code/sh.go @@ -1,12 +1,23 @@ package code import ( + "path" + ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/mdb" kit "shylinux.com/x/toolkits" ) +func _sh_main_script(m *ice.Message, arg ...string) (res []string) { + if kit.FileExists(kit.Path(arg[2], arg[1])) { + res = append(res, kit.Format("source %s", kit.Path(arg[2], arg[1]))) + } else if b, ok := ice.Info.Pack[path.Join(arg[2], arg[1])]; ok && len(b) > 0 { + res = append(res, string(b)) + } + return +} + const SH = "sh" func init() { @@ -19,10 +30,8 @@ func init() { LoadPlug(m, SH) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(cli.SYSTEM, SH, "-c", `#! /bin/sh + m.Cmdy(cli.SYSTEM, SH, "-c", kit.Join(_sh_main_script(m, arg...), ice.NL)).SetAppend() -source `+arg[1]+` -`, kit.Dict(cli.CMD_DIR, arg[2])).SetAppend() }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if arg[0] == mdb.FOREACH { diff --git a/go.sum b/go.sum index 8f4c0cd9..5f02abf9 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE= shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po= shylinux.com/x/toolkits v0.5.1 h1:0o3ELWcjA+aJ1eBH2p1Y4EZd1oJdxXxGRP4sxFkMl/g= shylinux.com/x/toolkits v0.5.1/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA= diff --git a/misc/git/status.go b/misc/git/status.go index 64ee2d22..75f20ad7 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -218,6 +218,9 @@ func init() { } } }}, + CLONE: {Name: "clone repos='https://shylinux.com/x/volcanos' path=usr/volcanos", Help: "克隆", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(REPOS, mdb.CREATE) + }}, PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) { _status_each(m, PULL, cli.SYSTEM, GIT, PULL) m.ProcessHold() diff --git a/misc/tmux/session.go b/misc/tmux/session.go index 6c72084d..462ff2d0 100644 --- a/misc/tmux/session.go +++ b/misc/tmux/session.go @@ -53,7 +53,7 @@ func init() { }, Commands: map[string]*ice.Command{ SESSION: {Name: "session session window pane cmd auto", Help: "会话管理", Action: map[string]*ice.Action{ web.DREAM_CREATE: {Name: "dream.create type name", Help: "梦想", Hand: func(m *ice.Message, arg ...string) { - if m.Cmd(m.PrefixKey(), m.Option(mdb.NAME)).Length() > 0 { + if m.Cmd(m.PrefixKey(), m.Option(mdb.NAME)).Length() == 0 { m.Cmd(m.PrefixKey(), mdb.CREATE) } }}, diff --git a/option.go b/option.go index ddd2f302..ea95960a 100644 --- a/option.go +++ b/option.go @@ -136,7 +136,10 @@ func (m *Message) ToastProcess(arg ...interface{}) func() { arg = append(arg, "-1") } m.Toast(PROCESS, arg...) - return func() { m.Toast(SUCCESS, arg...) } + return func() { + m.Debug("what ----- %v", 123) + m.Toast(SUCCESS, arg...) + } } func (m *Message) ToastRestart(arg ...interface{}) { m.Toast(RESTART, arg...) } func (m *Message) ToastFailure(arg ...interface{}) { m.Toast(SUCCESS, arg...) }