1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 09:08:06 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-10-13 10:01:20 +08:00
parent 7deacdb671
commit 2f6795a70e
15 changed files with 32 additions and 36 deletions

View File

@ -250,12 +250,8 @@ func init() {
m.Cmdy("web.code.upgrade")
}
}},
RESTART: {Help: "重启", Hand: func(m *ice.Message, arg ...string) {
m.Go(func() { m.Sleep30ms(ice.EXIT, 1) })
}},
"reboot": {Help: "清空", Hand: func(m *ice.Message, arg ...string) {
m.Go(func() { m.Sleep30ms(ice.QUIT, 1) })
}},
RESTART: {Help: "重启", Hand: func(m *ice.Message, arg ...string) { m.Go(func() { m.Sleep30ms(ice.EXIT, 1) }) }},
"reboot": {Help: "清空", Hand: func(m *ice.Message, arg ...string) { m.Go(func() { m.Sleep30ms(ice.QUIT, 1) }) }},
"logs": {Help: "日志", Hand: func(m *ice.Message, arg ...string) {
OpenCmds(m, kit.Format("cd %s", kit.Path("")), "tail -f var/log/bench.log")
}},

View File

@ -100,6 +100,7 @@ func (f *Frame) parse(m *ice.Message, h, line string) string {
if msg.Cmdy(ls); h == STDIO && msg.IsErrNotFound() {
msg.SetResult().Cmdy(cli.SYSTEM, ls)
}
kit.If(m.Option(ice.MSG_STATUS) == "", func() { m.StatusTimeCount() })
f.res = Render(msg, msg.Option(ice.MSG_OUTPUT), kit.List(msg.Optionv(ice.MSG_ARGS))...)
return ""
}

View File

@ -130,9 +130,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
kit.If(strings.TrimPrefix(r.URL.Path, key), func(p string) { m.Optionv(ice.MSG_CMDS, strings.Split(p, nfs.PS)) })
})
m.W.Header().Add(strings.ReplaceAll(ice.LOG_TRACEID, ".", "-"), m.Option(ice.LOG_TRACEID))
defer func() {
Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...)
}()
defer func() { Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...) }()
if cmds, ok := _serve_auth(m, key, kit.Simple(m.Optionv(ice.MSG_CMDS)), w, r); ok {
defer func() {
kit.If(m.Option(ice.MSG_STATUS) == "", func() { m.StatusTimeCount() })

View File

@ -52,6 +52,10 @@ func _spark_tabs(m *ice.Message, arg ...string) {
kit.For(arg[1:], func(k, v string) { m.Cmdy("", arg[0], v) })
}
func _spark_show(m *ice.Message, name, text string, arg ...string) *ice.Message {
if m.IsCliUA() {
kit.For(kit.SplitLine(text), func(text string) { m.Echo(text).Echo("\n") })
return m
}
return _wiki_template(m.Options(mdb.LIST, kit.SplitLine(text)), name, name, text, arg...)
}
@ -68,7 +72,6 @@ func init() {
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
ice.AddRender(ice.RENDER_SCRIPT, func(msg *ice.Message, args ...ice.Any) string {
return msg.Cmdx(SPARK, SHELL, args)
return m.Options(ice.MSG_COUNT, "0").Cmdx(SPARK, SHELL, args)
})
}},
ice.DEMO: {Hand: func(m *ice.Message, arg ...string) {

2
go.mod
View File

@ -5,6 +5,6 @@ go 1.13
require (
shylinux.com/x/go-git/v5 v5.6.7
shylinux.com/x/go-qrcode v0.0.3
shylinux.com/x/toolkits v0.7.11
shylinux.com/x/toolkits v0.7.12
shylinux.com/x/websocket v0.0.3
)

4
go.sum
View File

@ -4,7 +4,7 @@ shylinux.com/x/go-qrcode v0.0.3 h1:RMo+Vidbgq3HatLBj7DDXcTbTLFUwzis5K7TqBkD38U=
shylinux.com/x/go-qrcode v0.0.3/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
shylinux.com/x/toolkits v0.7.10 h1:65d5rkQXQ71MD8FzYnZ9DFxb1XcOYSYfmRc4j8qQsUw=
shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
shylinux.com/x/toolkits v0.7.11 h1:bndm85Bo5hMUxRIHPuzv5PRFtSl4LMbELHcyT7+b6iA=
shylinux.com/x/toolkits v0.7.11/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
shylinux.com/x/toolkits v0.7.12 h1:WszmGGzarTB4h6l8uZ3Q5Q590mA2EITTqLwD0tigZxk=
shylinux.com/x/toolkits v0.7.12/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
shylinux.com/x/websocket v0.0.3 h1:edhLwCp0Mv1ITXqIwbVWdXdX2+vui/jRnS25K89k68I=
shylinux.com/x/websocket v0.0.3/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw=

View File

@ -34,7 +34,7 @@ type alpha struct {
func (s alpha) Load(m *ice.Message, arg ...string) {
if !nfs.Exists(m, path.Dir(m.Option(nfs.FILE))) {
git.ReposClone(m.Message, mdb.Config(m, "repos"))
git.ReposClone(m.Message, mdb.Config(m, nfs.REPOS))
}
lib := kit.Select(path.Base(m.Option(nfs.FILE)), m.Option(mdb.ZONE))
m.Assert(nfs.RemoveAll(m, path.Join(mdb.Config(m, mdb.STORE), lib)))
@ -61,7 +61,7 @@ func (s alpha) List(m *ice.Message, arg ...string) {
m.OptionFields(ice.FIELDS_DETAIL)
arg[1] = "^" + arg[1] + mdb.FS
}
wiki.CSV(m.Message.Spawn(), m.Cmdx(cli.SYSTEM, "grep", "-rih", arg[1], mdb.Config(m, mdb.STORE)), kit.Split(mdb.Config(m, mdb.FIELD))...).Table(func(value ice.Maps) {
wiki.CSV(m.Message.Spawn(), m.Cmdx(cli.SYSTEM, nfs.GREP, "-rih", arg[1], mdb.Config(m, mdb.STORE)), kit.Split(mdb.Config(m, mdb.FIELD))...).Table(func(value ice.Maps) {
kit.If(m.FieldsIsDetail(), func() { m.PushDetail(value, mdb.Config(m, mdb.FIELD)) }, func() { m.PushRecord(value, mdb.Config(m, mdb.FIELD)) })
})
}

View File

@ -94,7 +94,7 @@ func init() {
func Complete(m *ice.Message, detail bool, arg ...string) (res []string) {
echo := func(arg ...string) { res = append(res, arg...) }
if len(arg) < 2 || arg[1] != ctx.ACTION {
list := ctx.CmdList(m.Spawn()).Appendv(ctx.INDEX)
list := m.Cmd(ctx.COMMAND).Appendv(ctx.INDEX)
if len(arg) > 0 {
pre := arg[0][0 : strings.LastIndex(arg[0], nfs.PT)+1]
list = kit.Simple(list, func(cmd string) bool { return strings.HasPrefix(cmd, arg[0]) }, func(cmd string) string { return strings.TrimPrefix(cmd, pre) })

View File

@ -88,7 +88,7 @@ func init() {
} else if len(arg) == 0 {
kit.If(config != nil, func() { m.Option(aaa.EMAIL, kit.Select(mdb.Config(m, aaa.EMAIL), config.User.Email)) })
m.Cmdy(REPOS, STATUS).Action(PULL, PUSH, INSTEADOF, OAUTH, CONFIGS, GITEA)
m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.DEV)
kit.If(!m.IsCliUA(), func() { m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.DEV) })
} else {
_repos_cmd(m, arg[0], DIFF)
}

View File

@ -42,7 +42,7 @@ func (s input) Inputs(m *ice.Message, arg ...string) {
}
}
func (s input) Load(m *ice.Message, arg ...string) {
if f, e := nfs.OpenFile(m, m.Option(nfs.FILE)); !m.Warn(e) {
if f, e := nfs.OpenFile(m.Message, m.Option(nfs.FILE)); !m.Warn(e) {
defer f.Close()
lib := kit.Select(path.Base(m.Option(nfs.FILE)), m.Option(mdb.ZONE))
m.Assert(nfs.RemoveAll(m, path.Join(mdb.Config(m, mdb.STORE), lib)))
@ -92,7 +92,7 @@ func (s input) List(m *ice.Message, arg ...string) {
case WORD:
arg[1] = "^" + arg[1] + mdb.FS
}
res := m.Cmdx(cli.SYSTEM, "grep", "-rn", arg[1], mdb.Config(m, mdb.STORE))
res := m.Cmdx(cli.SYSTEM, nfs.GREP, "-rn", arg[1], mdb.Config(m, mdb.STORE))
bio := csv.NewReader(bytes.NewBufferString(strings.Replace(res, nfs.DF, mdb.FS, -1)))
for i := 0; i < kit.Int(10); i++ {
if line, e := bio.Read(); e != nil {

View File

@ -1,6 +1,8 @@
package misc
import (
_ "shylinux.com/x/icebergs/misc/bash"
_ "shylinux.com/x/icebergs/misc/git"
_ "shylinux.com/x/icebergs/misc/tmux"
_ "shylinux.com/x/icebergs/misc/vim"
)

View File

@ -4,9 +4,9 @@ websocket
webview
qrcode
xterm
ssh
git
ssh
vim
bash
tmux

View File

@ -60,7 +60,7 @@ func init() {
}
func PushText(m *ice.Message, text string) {
m.OptionFields(ice.MSG_DETAIL)
if m.PushScript(nfs.SCRIPT, text); strings.HasPrefix(text, ice.HTTP) {
if m.PushScript(text); strings.HasPrefix(text, ice.HTTP) {
m.PushQRCode(cli.QRCODE, text)
m.PushAnchor(text)
}

View File

@ -26,8 +26,6 @@ func _tmux_key(arg ...string) string {
return "miss"
}
}
func _tmux_cmd(m *ice.Message, arg ...string) *ice.Message { return m.Cmd(cli.SYSTEM, TMUX, arg) }
func _tmux_cmds(m *ice.Message, arg ...string) string { return _tmux_cmd(m, arg...).Results() }
const (
FORMAT = "format"
@ -81,13 +79,6 @@ func init() {
)},
}, Commands: ice.Commands{
SESSION: {Name: "session session window pane cmds auto", Help: "会话", Actions: ice.Actions{
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
m.Go(func() {
nfs.Exists(m.Sleep3s(), path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)), func(p string) {
m.Cmd("", mdb.CREATE)
})
})
}},
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
if m.Option(ctx.ACTION) == SCRIPT {
m.Cmdy(SCRIPT, mdb.INPUTS, arg)
@ -167,6 +158,11 @@ func init() {
})
}).Sleep30ms()
}},
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
m.Go(func() {
nfs.Exists(m.Sleep3s(), path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)), func(p string) { m.Cmd("", mdb.CREATE) })
})
}},
}, Hand: func(m *ice.Message, arg ...string) {
if m.Action(SCRIPT); len(arg) > 3 {
m.Cmd(CMD, _tmux_key(arg[0], arg[1], arg[2]), arg[3:])

View File

@ -3,7 +3,6 @@ package tmux
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web"
@ -11,19 +10,20 @@ import (
kit "shylinux.com/x/toolkits"
)
func _tmux_cmd(m *ice.Message, arg ...string) *ice.Message { return m.Cmd(cli.SYSTEM, TMUX, arg) }
func _tmux_cmds(m *ice.Message, arg ...string) string { return _tmux_cmd(m, arg...).Results() }
const TMUX = "tmux"
var Index = &ice.Context{Name: TMUX, Help: "工作台", Commands: ice.Commands{
TMUX: {Name: "tmux path auto start order build download", Help: "服务", Actions: ice.MergeActions(ice.Actions{
cli.START: {Help: "启动", Hand: func(m *ice.Message, arg ...string) {
TMUX: {Help: "服务", Actions: ice.MergeActions(ice.Actions{
cli.START: {Hand: func(m *ice.Message, arg ...string) {
m.Optionv(code.PREPARE, func(p string) []string {
return []string{"-S", kit.Path(m.Option(cli.CMD_DIR, p), "tmux.socket"), NEW_SESSION, "-d", "-n", "miss"}
})
m.Cmdy(code.INSTALL, cli.START, mdb.Config(m, nfs.SOURCE), "bin/tmux")
}},
}, code.InstallAction(nfs.SOURCE, "http://mirrors.tencent.com/macports/distfiles/tmux/tmux-3.2.tar.gz")), Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(code.INSTALL, ctx.ConfigSimple(m, nfs.SOURCE), arg)
}},
}, code.InstallAction(nfs.SOURCE, "http://mirrors.tencent.com/macports/distfiles/tmux/tmux-3.2.tar.gz"))},
}}
func init() { code.Index.Register(Index, &web.Frame{}) }