forked from x/icebergs
opt some
This commit is contained in:
parent
d8310d576b
commit
4c981b2236
@ -71,3 +71,12 @@ func IsCentos(m *ice.Message, arg ...string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func IsUbuntu(m *ice.Message, arg ...string) bool {
|
||||
if strings.Contains(m.Conf(RUNTIME, kit.Keys(HOST, OSID)), UBUNTU) {
|
||||
if len(arg) > 0 {
|
||||
m.Cmd(mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, UBUNTU, CMD, "yum install -y "+kit.Select(arg[0], arg, 1))
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -143,7 +143,9 @@ func _hash_import(m *ice.Message, prefix, chain, file string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
|
||||
f, e := miss.OpenFile(kit.Keys(file, JSON))
|
||||
m.Assert(e)
|
||||
if m.Warn(e) {
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
list := Map{}
|
||||
@ -279,17 +281,20 @@ func HashTarget(m *ice.Message, h string, add Any) (p Any) {
|
||||
if pp, ok := p.(Map); ok && len(pp) == 0 {
|
||||
p = nil
|
||||
}
|
||||
m.Debug("what %v", p)
|
||||
if p == nil && add != nil {
|
||||
switch add := add.(type) {
|
||||
case func(ice.Map) ice.Any:
|
||||
p = add(value)
|
||||
case func() ice.Any:
|
||||
p = add()
|
||||
m.Debug("what %v", p)
|
||||
default:
|
||||
m.ErrorNotImplement(p)
|
||||
return
|
||||
}
|
||||
value[TARGET] = p
|
||||
m.Debug("what %v", p)
|
||||
}
|
||||
})
|
||||
return
|
||||
|
@ -41,7 +41,7 @@ func _cat_list(m *ice.Message, name string) {
|
||||
return // 没有权限
|
||||
}
|
||||
f, e := _cat_find(m, name)
|
||||
if m.Warn(e, ice.ErrNotFound, name) {
|
||||
if m.Warn(e) {
|
||||
return // 没有文件
|
||||
}
|
||||
defer f.Close()
|
||||
|
@ -89,7 +89,7 @@ func (f *Frame) alias(m *ice.Message, ls []string) []string {
|
||||
}
|
||||
return ls
|
||||
}
|
||||
func (f *Frame) parse(m *ice.Message, line string) string {
|
||||
func (f *Frame) parse(m *ice.Message, h, line string) string {
|
||||
msg := m.Spawn(f.target)
|
||||
ls := f.change(msg, f.alias(msg, kit.Split(strings.TrimSpace(line))))
|
||||
if len(ls) == 0 {
|
||||
@ -97,7 +97,7 @@ func (f *Frame) parse(m *ice.Message, line string) string {
|
||||
}
|
||||
|
||||
msg.Render("", kit.List())
|
||||
if msg.Cmdy(ls); msg.IsErrNotFound() {
|
||||
if msg.Cmdy(ls); h == STDIO && msg.IsErrNotFound() {
|
||||
msg.SetResult().Cmdy(cli.SYSTEM, ls)
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
|
||||
|
||||
if m.I, m.O = f.stdin, f.stdout; h == STDIO {
|
||||
gdb.Event(m, SOURCE_STDIO)
|
||||
m.Sleep("2.1s")
|
||||
m.Sleep("3s")
|
||||
}
|
||||
|
||||
bio := bufio.NewScanner(f.stdin)
|
||||
@ -141,7 +141,7 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
|
||||
f.printf(m, "\033[0m") // 清空格式
|
||||
}
|
||||
}
|
||||
line = f.parse(m, line)
|
||||
line = f.parse(m, h, line)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
@ -240,6 +240,12 @@ func init() {
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, k, m.Prefix(k))
|
||||
m.Cmd(mdb.PLUGIN, mdb.CREATE, k, m.Prefix(k))
|
||||
}
|
||||
m.Go(func() {
|
||||
m.Sleep300ms()
|
||||
cli.IsAlpine(m, GO)
|
||||
cli.IsCentos(m, GO)
|
||||
cli.IsUbuntu(m, GO, "golang")
|
||||
})
|
||||
}},
|
||||
GODOC: {Name: "godoc", Help: "文档", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -67,8 +68,8 @@ func init() {
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH)
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey())
|
||||
m.Config(ice.CONTEXTS, _contexts)
|
||||
gdb.Watch(m, web.SERVE_START, m.PrefixKey())
|
||||
m.Config(ice.CONTEXTS, _contexts)
|
||||
}},
|
||||
web.SERVE_START: {Name: "serve.start", Help: "服务启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
_publish_file(m, ice.ICE_BIN)
|
||||
@ -88,8 +89,12 @@ func init() {
|
||||
}},
|
||||
ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
||||
u := web.OptionUserWeb(m)
|
||||
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(u.Host, ice.DF)[0],
|
||||
kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
|
||||
host := strings.Split(u.Host, ice.DF)[0]
|
||||
if host == tcp.LOCALHOST {
|
||||
host = m.Cmd(tcp.HOST).Append(aaa.IP)
|
||||
}
|
||||
m.Option("ctx_env", kit.Select("", " "+kit.JoinKV("=", " ", "ctx_pod", m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
||||
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
|
||||
|
||||
if len(arg) == 0 {
|
||||
arg = append(arg, ice.MISC, ice.CORE, ice.BASE)
|
||||
@ -158,15 +163,15 @@ func init() {
|
||||
}
|
||||
|
||||
var _contexts = kit.Dict(
|
||||
ice.MISC, `# 下载命令
|
||||
export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}
|
||||
export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}
|
||||
ice.MISC, `# 下载命令 curl 或 wget
|
||||
export ctx_dev={{.Option "httphost"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}
|
||||
export ctx_dev={{.Option "httphost"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}
|
||||
`,
|
||||
ice.CORE, `# 克隆源码
|
||||
git clone {{.Option "remote"}}; cd {{.Option "pathname"}} && source etc/miss.sh port 9020
|
||||
`,
|
||||
ice.BASE, `# 下载工具
|
||||
ice.CORE, `# 下载工具 curl 或 wget
|
||||
ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL {{.Cmdx "spide" "shy" "client.url"}}; source $ctx_temp binary
|
||||
ctx_temp=$(mktemp); wget -O $ctx_temp -q {{.Cmdx "spide" "shy" "client.url"}}; source $ctx_temp binary
|
||||
`,
|
||||
ice.BASE, `# 下载源码
|
||||
git clone {{.Option "remote"}}; cd {{.Option "pathname"}} && source etc/miss.sh
|
||||
`,
|
||||
)
|
||||
|
@ -25,7 +25,9 @@ func _xterm_socket(m *ice.Message, h, t string) {
|
||||
}
|
||||
func _xterm_get(m *ice.Message, h string, must bool) *os.File {
|
||||
t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE)
|
||||
m.Debug("what %v", h)
|
||||
if f, ok := mdb.HashTarget(m, h, func() ice.Any {
|
||||
m.Debug("what %v", h)
|
||||
if !must {
|
||||
return nil
|
||||
}
|
||||
|
@ -49,7 +49,12 @@ func init() {
|
||||
m.Conf(REPOS, mdb.HASH, "")
|
||||
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
|
||||
m.Cmd(nfs.DIR, ice.USR, "name,path", func(value ice.Maps) { _repos_insert(m, value[mdb.NAME], value[nfs.PATH]) })
|
||||
m.Go(func() { m.Sleep300ms(); cli.IsAlpine(m, GIT) })
|
||||
m.Go(func() {
|
||||
m.Sleep300ms()
|
||||
cli.IsAlpine(m, GIT)
|
||||
cli.IsCentos(m, GIT)
|
||||
cli.IsUbuntu(m, GIT)
|
||||
})
|
||||
m.Config(REPOS, "https://shylinux.com/x")
|
||||
}},
|
||||
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -34,7 +34,7 @@ type input struct {
|
||||
}
|
||||
|
||||
func (s input) Load(m *ice.Message, arg ...string) {
|
||||
if f, e := nfs.OpenFile(m.Message, m.Option(nfs.FILE)); m.Assert(e) {
|
||||
if f, e := nfs.OpenFile(m.Message, m.Option(nfs.FILE)); !m.Warn(e) {
|
||||
defer f.Close()
|
||||
|
||||
// 清空数据
|
||||
|
@ -14,6 +14,7 @@ type compile struct {
|
||||
ice.Code
|
||||
regexp string `data:".*.js"`
|
||||
linux string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz"`
|
||||
darwin string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-darwin-x64.tar.gz"`
|
||||
list string `name:"list path auto xterm listScript order install" help:"编译器"`
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user