forked from x/icebergs
add some
This commit is contained in:
parent
e6d0f561b6
commit
1197a56ced
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
@ -146,6 +147,21 @@ func init() {
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
||||
func OpenCmds(m *ice.Message, arg ...string) {
|
||||
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
return
|
||||
}
|
||||
if len(arg) == 0 || arg[0] == "" {
|
||||
return
|
||||
}
|
||||
m.Cmd(SYSTEM, "osascript", "-e", kit.Format(`
|
||||
tell application "Terminal"
|
||||
do script "%s"
|
||||
activate
|
||||
end tell
|
||||
`, strings.Join(arg, "; ")))
|
||||
}
|
||||
func Opens(m *ice.Message, arg ...string) {
|
||||
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
return
|
||||
|
@ -157,7 +157,7 @@ const RUNTIME = "runtime"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
|
||||
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart logs conf", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
aaa.White(m, ice.ETC_PATH)
|
||||
aaa.White(m, ice.LICENSE)
|
||||
@ -251,6 +251,12 @@ func init() {
|
||||
RESTART: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Go(func() { m.Sleep("30ms", ice.EXIT, 1) })
|
||||
}},
|
||||
"logs": {Help: "日志", Hand: func(m *ice.Message, arg ...string) {
|
||||
OpenCmds(m, kit.Format("cd %s", kit.Path("")), "tail -f var/log/bench.log")
|
||||
}},
|
||||
"conf": {Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
||||
OpenCmds(m, kit.Format("cd %s", kit.Path("")), "vim etc/init.shy")
|
||||
}},
|
||||
aaa.ROLE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, func(value ice.Maps) { m.Push(mdb.KEY, kit.Keys(value[aaa.ROLE], value[mdb.ZONE], value[mdb.KEY])) })
|
||||
ctx.DisplayStorySpide(m.Options(nfs.DIR_ROOT, "ice."), mdb.FIELD, mdb.KEY, lex.SPLIT, nfs.PT)
|
||||
@ -261,8 +267,7 @@ func init() {
|
||||
ctx.DisplayStoryJSON(m)
|
||||
m.Status(mdb.TIME, ice.Info.Make.Time,
|
||||
mdb.HASH, kit.Cut(ice.Info.Hash, 6), nfs.SIZE, ice.Info.Size,
|
||||
ice.BIN, _system_find(m, os.Args[0]), mdb.NAME, ice.Info.NodeName,
|
||||
nfs.REMOTE, ice.Info.Make.Remote, nfs.VERSION, ice.Info.Make.Versions(),
|
||||
mdb.NAME, ice.Info.NodeName, nfs.VERSION, ice.Info.Make.Versions(),
|
||||
)
|
||||
}},
|
||||
})
|
||||
|
@ -6,11 +6,13 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
const ADMIN = "admin"
|
||||
Index.MergeCommands(ice.Commands{
|
||||
"admin": {Name: "admin", Help: "管理", Hand: func(m *ice.Message, arg ...string) {
|
||||
ADMIN: {Name: ADMIN, Help: "管理", Hand: func(m *ice.Message, arg ...string) {
|
||||
args := []string{}
|
||||
kit.If(len(arg) == 0, func() { arg = append(arg, SPACE, DOMAIN) })
|
||||
kit.For(arg[1:], func(v string) { args = append(args, ice.ARG, v) })
|
||||
m.Cmdy(SPIDE, ice.OPS, SPIDE_RAW, "/chat/cmd/"+arg[0]+"?debug=true", SPIDE_FORM, args)
|
||||
m.Cmdy(SPIDE, ice.OPS, SPIDE_RAW, CHAT_CMD+arg[0]+"?debug=true", SPIDE_FORM, args)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -162,6 +162,9 @@ const (
|
||||
VIEW = "view"
|
||||
CHAT = "chat"
|
||||
|
||||
CHAT_POD = "/chat/pod/"
|
||||
CHAT_CMD = "/chat/cmd/"
|
||||
|
||||
CODE_GIT_SERVICE = "web.code.git.service"
|
||||
CODE_GIT_STATUS = "web.code.git.status"
|
||||
CODE_GIT_REPOS = "web.code.git.repos"
|
||||
|
@ -212,7 +212,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
nfs.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
|
||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 1000, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) < 2 {
|
||||
defer m.StatusTimeCount()
|
||||
m.Option(ice.MSG_USERWEB, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)))
|
||||
|
@ -43,6 +43,7 @@ fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item.icons
|
||||
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item:last-child { margin-right:120px; }
|
||||
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.wiki.feel>div.status { display:none; }
|
||||
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.vimer>div.status { display:none; }
|
||||
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.vimer>div.action>div.tabs { display:none; }
|
||||
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.xterm>div.status { display:none; }
|
||||
fieldset.web.code.xterm>div.action>div.tabs:only-child { display:none; }
|
||||
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.compile>form.option>div.item:last-child { margin-right:120px; }
|
||||
|
@ -74,7 +74,6 @@ func init() {
|
||||
}},
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
|
||||
}, ctx.ConfAction(cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"))), Hand: func(m *ice.Message, arg ...string) {
|
||||
defer web.ToastProcess(m)()
|
||||
main, file, goos, arch := _compile_target(m, arg...)
|
||||
env := kit.Simple(cli.PATH, cli.BinPath(), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), mdb.Configv(m, cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch)
|
||||
kit.If(runtime.GOOS == cli.WINDOWS, func() { env = append(env, "GOPATH", kit.HomePath(GO), "GOCACHE", kit.HomePath("go/go-build")) })
|
||||
|
@ -134,7 +134,10 @@ func init() {
|
||||
}
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(nfs.Template(m, "demo.go"), path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||
m.Option("name", kit.TrimExt(path.Base(arg[1]), "go"))
|
||||
m.Option("zone", path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||
m.Option("key", kit.Keys("web.code", m.Option("zone"), m.Option("name")))
|
||||
m.Echo(nfs.Template(m, "demo.go"))
|
||||
}},
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { _go_complete(m, arg...) }},
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -86,7 +86,7 @@ const INNER = "inner"
|
||||
func init() {
|
||||
var bind = []string{"usr/icebergs/core/", "usr/volcanos/plugin/local/"}
|
||||
Index.MergeCommands(ice.Commands{
|
||||
INNER: {Name: "inner path=src/@key file=main.go@key line=1 auto exec", Help: "源代码", Actions: ice.MergeActions(ice.Actions{
|
||||
INNER: {Name: "inner path=src/@key file=main.go@key line=1 auto show exec", Help: "源代码", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch p := kit.Select(nfs.PWD, arg, 1); arg[0] {
|
||||
case ice.CMD:
|
||||
@ -112,9 +112,8 @@ func init() {
|
||||
}
|
||||
}},
|
||||
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.PLUGIN, arg)
|
||||
if m.Result() == "" {
|
||||
m.Cmdy(mdb.PLUGIN, m.Option("parse", strings.ToLower(kit.Split(path.Base(arg[1]), ".")[0])), arg[1:])
|
||||
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
||||
m.Cmdy(mdb.PLUGIN, m.Option("parse", strings.ToLower(kit.Split(path.Base(arg[1]), nfs.PT)[0])), arg[1:])
|
||||
}
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }},
|
||||
@ -132,6 +131,11 @@ func init() {
|
||||
} else if len(arg) < 2 {
|
||||
nfs.Dir(m, nfs.PATH)
|
||||
} else {
|
||||
if strings.Contains(arg[1], ":") {
|
||||
ls := strings.Split(arg[1], ":")
|
||||
m.ProcessRewrite(nfs.LINE, ls[0], nfs.FILE, ls[1])
|
||||
return
|
||||
}
|
||||
arg[1] = strings.Split(arg[1], mdb.FS)[0]
|
||||
_inner_list(m, kit.Ext(arg[1]), arg[1], arg[0])
|
||||
ctx.DisplayLocal(m, "").Option(REPOS, kit.Join(m.Cmd(REPOS, ice.OptionFields(nfs.PATH)).Sort(nfs.PATH).Appendv(nfs.PATH)))
|
||||
|
@ -12,6 +12,9 @@ import (
|
||||
func _makefile_xterm(m *ice.Message, arg ...string) {
|
||||
ctx.Process(m, XTERM, func() []string {
|
||||
m.Push(ctx.STYLE, html.OUTPUT)
|
||||
if ls := kit.Simple(kit.UnMarshal(m.Option(ctx.ARGS))); len(ls) > 0 {
|
||||
return ls
|
||||
}
|
||||
return []string{mdb.TYPE, "sh", nfs.PATH, kit.Select("", kit.Dir(arg[2], arg[1]), arg[2] != ice.SRC)}
|
||||
}, arg...)
|
||||
}
|
||||
|
@ -59,7 +59,11 @@ func _publish_contexts(m *ice.Message, arg ...string) {
|
||||
default:
|
||||
// _publish_file(m, ice.ICE_BIN)
|
||||
}
|
||||
m.EchoScript(strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))))
|
||||
if m.Option("format") == "raw" {
|
||||
m.Echo(strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))))
|
||||
} else {
|
||||
m.EchoScript(strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,8 @@ func _vimer_make(m *ice.Message, dir string, msg *ice.Message) {
|
||||
}
|
||||
}
|
||||
}
|
||||
kit.If(m.Length() == 0, func() { m.Echo(msg.Append(cli.CMD_OUT)).Echo(msg.Append(cli.CMD_ERR)) })
|
||||
// kit.If(m.Length() == 0, func() { m.Echo(msg.Append(cli.CMD_OUT)).Echo(msg.Append(cli.CMD_ERR)) })
|
||||
m.Echo(msg.Append(cli.CMD_OUT)).Echo(msg.Append(cli.CMD_ERR))
|
||||
}
|
||||
|
||||
const VIMER = "vimer"
|
||||
@ -58,7 +59,7 @@ func init() {
|
||||
}},
|
||||
})
|
||||
Index.MergeCommands(ice.Commands{
|
||||
VIMER: {Name: "vimer path=src/@key file=main.go line=1 list", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{
|
||||
VIMER: {Name: "vimer path=src/@key file=main.go@key line=1 list", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.IsSearchPreview(m, arg) {
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_SH)
|
||||
|
@ -73,7 +73,7 @@ const XTERM = "xterm"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
XTERM: {Name: "xterm hash auto terminal", Help: "命令行", Actions: ice.MergeActions(ice.Actions{
|
||||
XTERM: {Name: "xterm hash auto install terminal", Help: "命令行", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Cmd("").Length() == 0, func() { m.Cmd("", mdb.CREATE, mdb.TYPE, ISH) })
|
||||
}},
|
||||
@ -133,17 +133,16 @@ func init() {
|
||||
ctx.ProcessField(m, m.PrefixKey(), func() string { return m.Cmdx("", mdb.CREATE, arg) }, arg...)
|
||||
}
|
||||
}},
|
||||
"install": {Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
||||
_xterm_get(m, kit.Select("", arg, 0)).Write([]byte(m.Cmdx(PUBLISH, ice.CONTEXTS, ice.APP, kit.Dict("format", "raw")) + ice.NL))
|
||||
ctx.ProcessHold(m)
|
||||
}},
|
||||
"terminal": {Help: "本机", Hand: func(m *ice.Message, arg ...string) {
|
||||
if h := kit.Select(m.Option(mdb.HASH), arg, 0); h == "" {
|
||||
cli.Opens(m, "Terminal.app")
|
||||
} else {
|
||||
msg := m.Cmd("", h)
|
||||
m.Cmd(cli.SYSTEM, "osascript", "-e", kit.Format(`
|
||||
tell application "Terminal"
|
||||
do script "%s"
|
||||
activate
|
||||
end tell
|
||||
`, msg.Append(mdb.TYPE)))
|
||||
cli.OpenCmds(m, msg.Append(mdb.TYPE))
|
||||
}
|
||||
m.ProcessHold()
|
||||
}},
|
||||
|
13
init.go
13
init.go
@ -80,9 +80,16 @@ var Index = &Context{Name: ICE, Help: "冰山模块", Commands: Commands{
|
||||
})
|
||||
}},
|
||||
}, server: &Frame{}}
|
||||
var Pulse = &Message{time: time.Now(), meta: map[string][]string{}, data: Map{}, source: Index, target: Index}
|
||||
var Pulse = &Message{meta: map[string][]string{}, data: Map{}, source: Index, target: Index}
|
||||
|
||||
func init() { Index.root, Pulse.root = Index, Pulse }
|
||||
func init() {
|
||||
Index.root, Pulse.root = Index, Pulse
|
||||
switch tz := os.Getenv("TZ"); tz {
|
||||
case "", "Asia/Beijing", "Asia/Shanghai":
|
||||
time.Local = time.FixedZone(tz, 28800)
|
||||
}
|
||||
Pulse.time = time.Now()
|
||||
}
|
||||
|
||||
func Run(arg ...string) string {
|
||||
kit.If(len(arg) == 0 && len(os.Args) > 1, func() { arg = kit.Simple(os.Args[1:], kit.Split(kit.Env(CTX_ARG))) })
|
||||
@ -102,8 +109,6 @@ func Run(arg ...string) string {
|
||||
}
|
||||
})
|
||||
kit.If(Pulse._cmd == nil, func() { Pulse._cmd = &Command{RawHand: logs.FileLines(3)} })
|
||||
time.Local = time.FixedZone("Beijing", 28800)
|
||||
Pulse.time = time.Now()
|
||||
switch Index.Merge(Index).Begin(Pulse, arg...); kit.Select("", arg, 0) {
|
||||
case SERVE, SPACE:
|
||||
Pulse.Go(func() { Index.Start(Pulse, arg...) })
|
||||
|
@ -87,7 +87,11 @@ func (m *Message) StatusTimeCountTotal(arg ...Any) *Message {
|
||||
}
|
||||
|
||||
func (m *Message) Process(cmd string, arg ...Any) *Message {
|
||||
return m.Options(MSG_PROCESS, cmd, PROCESS_ARG, kit.Simple(arg...))
|
||||
if len(arg) == 0 {
|
||||
return m.Options(MSG_PROCESS, cmd)
|
||||
} else {
|
||||
return m.Options(MSG_PROCESS, cmd, PROCESS_ARG, kit.Simple(arg...))
|
||||
}
|
||||
}
|
||||
func (m *Message) ProcessLocation(arg ...Any) { m.Process(PROCESS_LOCATION, arg...) }
|
||||
func (m *Message) ProcessReplace(url string, arg ...Any) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user