forked from x/icebergs
opt some
This commit is contained in:
parent
b1d656fa90
commit
47b61c540a
@ -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 {
|
||||
|
@ -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 (
|
||||
|
@ -146,10 +146,14 @@ func init() {
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
for k, v := range ice.Info.Pack {
|
||||
m.Push(mdb.NAME, k).Push(nfs.SIZE, len(v))
|
||||
m.Push(nfs.PATH, k).Push(nfs.SIZE, len(v))
|
||||
}
|
||||
m.Sort(mdb.NAME)
|
||||
m.Sort(nfs.PATH)
|
||||
return
|
||||
}
|
||||
m.Echo(string(ice.Info.Pack[arg[0]]))
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
1
go.sum
1
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=
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
}},
|
||||
|
@ -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...) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user