mirror of
https://shylinux.com/x/icebergs
synced 2025-06-26 10:27:31 +08:00
add script
This commit is contained in:
parent
6023c1506d
commit
af481aec3b
@ -253,10 +253,12 @@ func init() {
|
|||||||
m.Echo("%v", string(buf))
|
m.Echo("%v", string(buf))
|
||||||
}},
|
}},
|
||||||
"upgrade": {Help: "升级", Hand: func(m *ice.Message, arg ...string) {
|
"upgrade": {Help: "升级", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if nfs.Exists(m, ".git") && SystemFind(m, "go") != "" {
|
if nfs.Exists(m, ice.SRC_MAIN_GO) && nfs.Exists(m, ".git") && SystemFind(m, "go") != "" {
|
||||||
m.Cmdy("web.code.compile")
|
m.Cmdy("web.code.compile")
|
||||||
} else {
|
} else if nfs.Exists(m, ice.BIN_ICE_BIN) {
|
||||||
m.Cmdy("web.code.upgrade")
|
m.Cmdy("web.code.upgrade")
|
||||||
|
} else {
|
||||||
|
m.Cmdy("", "reboot")
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
"reboot": {Help: "重启", Icon: "bi bi-bootstrap-reboot", Hand: func(m *ice.Message, arg ...string) {
|
"reboot": {Help: "重启", Icon: "bi bi-bootstrap-reboot", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -190,10 +190,7 @@ func ZoneAction(arg ...ice.Any) ice.Actions {
|
|||||||
}
|
}
|
||||||
func ExportZoneAction(arg ...ice.Any) ice.Actions {
|
func ExportZoneAction(arg ...ice.Any) ice.Actions {
|
||||||
return ice.MergeActions(ZoneAction(arg...), ice.Actions{
|
return ice.MergeActions(ZoneAction(arg...), ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { Config(m, IMPORTANT, ice.TRUE); ZoneImport(m, arg) }},
|
||||||
Config(m, IMPORTANT, ice.TRUE)
|
|
||||||
ZoneImport(m, arg)
|
|
||||||
}},
|
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.OptionFields(""); ZoneExport(m, arg) }},
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.OptionFields(""); ZoneExport(m, arg) }},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -240,38 +240,53 @@ func init() {
|
|||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
cli.BUILD: {Name: "build name", Hand: func(m *ice.Message, arg ...string) {
|
cli.BUILD: {Name: "build name", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(ice.MSG_TITLE, kit.Keys(m.CommandKey(), m.ActionKey()))
|
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||||
m.Cmd("", FOR_FLOW, m.Option(mdb.NAME), kit.JoinWord(cli.SH, ice.ETC_MISS_SH))
|
compile := cli.SystemFind(m, "go") != ""
|
||||||
m.Sleep3s().Cmdy(ROUTE, cli.BUILD).ProcessInner()
|
m.Cmd("", FOR_FLOW, m.Option(mdb.NAME), kit.JoinWord(cli.SH, ice.ETC_MISS_SH), func(p string) bool {
|
||||||
|
if compile && nfs.Exists(m, path.Join(p, ice.SRC_MAIN_GO)) {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
m.Cmd(SPACE, path.Base(p), cli.RUNTIME, UPGRADE)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// kit.If(m.Option(mdb.NAME) == "", func() { m.Sleep3s().Cmdy(ROUTE, cli.BUILD).ProcessInner() })
|
||||||
}},
|
}},
|
||||||
PUBLISH: {Name: "publish name", Help: "发布", Icon: "bi bi-send-check", Hand: func(m *ice.Message, arg ...string) {
|
PUBLISH: {Name: "publish name", Help: "发布", Icon: "bi bi-send-check", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(ice.MSG_TITLE, kit.Keys(m.CommandKey(), m.ActionKey()))
|
m.Option(ice.MSG_TITLE, kit.Keys(m.CommandKey(), m.ActionKey()))
|
||||||
defer ToastProcess(m)()
|
defer ToastProcess(m)()
|
||||||
list := []string{cli.LINUX, cli.DARWIN, cli.WINDOWS}
|
list := []string{cli.LINUX, cli.DARWIN, cli.WINDOWS}
|
||||||
msg := m.Spawn(ice.Maps{ice.MSG_DAEMON: ""})
|
msg := m.Spawn(ice.Maps{ice.MSG_DAEMON: ""})
|
||||||
m.Cmd(CODE_AUTOGEN, "binpack")
|
m.Cmd(AUTOGEN, BINPACK)
|
||||||
kit.For(list, func(goos string) {
|
kit.For(list, func(goos string) {
|
||||||
PushNoticeRich(m, mdb.NAME, ice.Info.NodeName, msg.Cmd(CODE_COMPILE, goos, cli.AMD64).AppendSimple())
|
PushNoticeRich(m, mdb.NAME, ice.Info.NodeName, msg.Cmd(COMPILE, goos, cli.AMD64).AppendSimple())
|
||||||
})
|
})
|
||||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||||
m.Cmd(SPACE, name, CODE_AUTOGEN, "binpack")
|
m.Cmd(SPACE, name, AUTOGEN, BINPACK)
|
||||||
kit.For(list, func(goos string) {
|
kit.For(list, func(goos string) {
|
||||||
PushNoticeRich(m, mdb.NAME, name, msg.Cmd(SPACE, name, CODE_COMPILE, goos, cli.AMD64, kit.Dict(ice.MSG_USERPOD, name)).AppendSimple())
|
PushNoticeRich(m, mdb.NAME, name, msg.Cmd(SPACE, name, COMPILE, goos, cli.AMD64, kit.Dict(ice.MSG_USERPOD, name)).AppendSimple())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
m.ProcessHold()
|
m.ProcessHold()
|
||||||
}},
|
}},
|
||||||
FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
list := []string{}
|
||||||
|
DreamEach(m.Spawn(ice.Maps{ice.MSG_DAEMON: ""}), m.Option(mdb.NAME), "", func(name string) { list = append(list, name) })
|
||||||
m.Options(ctx.DISPLAY, PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
|
m.Options(ctx.DISPLAY, PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
|
||||||
PushNoticeGrow(m.Options(ice.MSG_COUNT, "0"), strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
|
PushNoticeGrow(m.Options(ice.MSG_COUNT, "0"), strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
|
||||||
return len(buf), nil
|
return len(buf), nil
|
||||||
}, func() error { return nil }))
|
}, func() error { return nil }))
|
||||||
msg := mdb.HashSelects(m.Spawn(), m.Option(mdb.NAME))
|
|
||||||
GoToast(m, "", func(toast func(string, int, int)) []string {
|
GoToast(m, "", func(toast func(string, int, int)) []string {
|
||||||
msg.Table(func(index int, value ice.Maps) {
|
kit.For(list, func(index int, name string) {
|
||||||
toast(value[mdb.NAME], index, msg.Length())
|
toast(name, index, len(list))
|
||||||
p := path.Join(ice.USR_LOCAL_WORK, value[mdb.NAME])
|
p := path.Join(ice.USR_LOCAL_WORK, name)
|
||||||
PushNoticeGrow(m, strings.ReplaceAll(kit.Format("[%s]%s$ %s\n", time.Now().Format(ice.MOD_TIME_ONLY), value[mdb.NAME], m.Option(ice.CMD)), lex.NL, "\r\n"))
|
switch cb := m.OptionCB("").(type) {
|
||||||
|
case func(string) bool:
|
||||||
|
if cb(p) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PushNoticeGrow(m, strings.ReplaceAll(kit.Format("[%s]%s$ %s\n", time.Now().Format(ice.MOD_TIME_ONLY), name, m.Option(ice.CMD)), lex.NL, "\r\n"))
|
||||||
m.Cmd(cli.SYSTEM, kit.Split(m.Option(ice.CMD)), kit.Dict(cli.CMD_DIR, p)).Sleep300ms()
|
m.Cmd(cli.SYSTEM, kit.Split(m.Option(ice.CMD)), kit.Dict(cli.CMD_DIR, p)).Sleep300ms()
|
||||||
PushNoticeGrow(m, "\r\n\r\n\r\n")
|
PushNoticeGrow(m, "\r\n\r\n\r\n")
|
||||||
})
|
})
|
||||||
@ -350,7 +365,7 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
}, StatsAction(), DreamAction(), mdb.ImportantHashAction(
|
}, StatsAction(), DreamAction(), mdb.ImportantHashAction(
|
||||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template,restart", ctx.TOOLS, kit.Simple(CODE_GIT_SEARCH, ROUTE, SPIDE),
|
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template,restart", ctx.TOOLS, kit.Simple(CODE_GIT_SEARCH, ROUTE, SPIDE),
|
||||||
html.BUTTON, kit.JoinWord(PORTAL, ADMIN, DESKTOP, WIKI_WORD, CODE_GIT_STATUS, CODE_VIMER, CODE_XTERM, CODE_COMPILE),
|
html.BUTTON, kit.JoinWord(PORTAL, ADMIN, DESKTOP, WIKI_WORD, STATUS, VIMER, XTERM, COMPILE),
|
||||||
)), Hand: func(m *ice.Message, arg ...string) {
|
)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
_dream_list(m).RewriteAppend(func(value, key string, index int) string {
|
_dream_list(m).RewriteAppend(func(value, key string, index int) string {
|
||||||
|
@ -136,7 +136,7 @@ var Icons = map[string]string{ice.PROCESS: "🕑", ice.FAILURE: "❌", ice.SUCCE
|
|||||||
|
|
||||||
func toastContent(m *ice.Message, state string, arg ...ice.Any) string {
|
func toastContent(m *ice.Message, state string, arg ...ice.Any) string {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
return kit.JoinWord(kit.Simple(Icons[state], m.ActionKey(), state)...)
|
return kit.JoinWord(kit.Simple(Icons[state], kit.Select("", m.ActionKey(), m.ActionKey() != ice.LIST), state)...)
|
||||||
} else {
|
} else {
|
||||||
return kit.JoinWord(kit.Simple(Icons[state], arg)...)
|
return kit.JoinWord(kit.Simple(Icons[state], arg)...)
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ func GoToast(m *ice.Message, title string, cb func(toast func(name string, count
|
|||||||
icon := Icons[ice.PROCESS]
|
icon := Icons[ice.PROCESS]
|
||||||
toast := func(name string, count, total int) {
|
toast := func(name string, count, total int) {
|
||||||
kit.If(total == 0, func() { total = 1 })
|
kit.If(total == 0, func() { total = 1 })
|
||||||
Toast(m, kit.Format("%s %s %s/%s", icon, kit.JoinWord(kit.Select(m.ActionKey(), m.Option(ice.MSG_TITLE)), name), strings.TrimSuffix(kit.FmtSize(int64(count)), "B"), strings.TrimSuffix(kit.FmtSize(int64(total)), "B")),
|
Toast(m, kit.Format("%s %s %s/%s", icon, kit.JoinWord(kit.Select(kit.Select("", m.ActionKey(), m.ActionKey() != ice.LIST), title, m.Option(ice.MSG_TITLE)), name), strings.TrimSuffix(kit.FmtSize(int64(count)), "B"), strings.TrimSuffix(kit.FmtSize(int64(total)), "B")),
|
||||||
"", m.OptionDefault(ice.TOAST_DURATION, "30s"), count*100/total)
|
"", m.OptionDefault(ice.TOAST_DURATION, "30s"), count*100/total)
|
||||||
_total = total
|
_total = total
|
||||||
}
|
}
|
||||||
|
@ -158,9 +158,13 @@ func RenderVersion(m *ice.Message) string {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
CHAT = "chat"
|
CHAT = "chat"
|
||||||
DESKTOP = "desktop"
|
|
||||||
COMPILE = "compile"
|
|
||||||
XTERM = "xterm"
|
XTERM = "xterm"
|
||||||
|
VIMER = "vimer"
|
||||||
|
DESKTOP = "desktop"
|
||||||
|
UPGRADE = "upgrade"
|
||||||
|
COMPILE = "compile"
|
||||||
|
BINPACK = "binpack"
|
||||||
|
AUTOGEN = "autogen"
|
||||||
|
|
||||||
CODE_GIT_SERVICE = "web.code.git.service"
|
CODE_GIT_SERVICE = "web.code.git.service"
|
||||||
CODE_GIT_SEARCH = "web.code.git.search"
|
CODE_GIT_SEARCH = "web.code.git.search"
|
||||||
|
@ -84,19 +84,10 @@ func init() {
|
|||||||
_route_toast(m, m.Option(SPACE), append([]string{m.Option(ctx.INDEX)}, kit.Split(m.Option(ctx.ARGS))...)...)
|
_route_toast(m, m.Option(SPACE), append([]string{m.Option(ctx.INDEX)}, kit.Split(m.Option(ctx.ARGS))...)...)
|
||||||
}},
|
}},
|
||||||
cli.BUILD: {Name: "build space", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
cli.BUILD: {Name: "build space", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_route_toast(m, m.Option(SPACE), m.PrefixKey(), "_build")
|
_route_toast(m, m.Option(SPACE), cli.RUNTIME, UPGRADE)
|
||||||
func() { defer ToastProcess(m)(); m.Sleep3s() }()
|
func() { defer ToastProcess(m)(); m.Sleep3s() }()
|
||||||
m.SetAppend().Cmdy("", "travel")
|
m.SetAppend().Cmdy("", "travel")
|
||||||
}},
|
}},
|
||||||
"_build": {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if _, err := nfs.DiskFile.StatFile(ice.SRC_MAIN_GO); err == nil && nfs.Exists(m, ".git") {
|
|
||||||
m.Cmdy(CODE_VIMER, "compile")
|
|
||||||
} else if ice.Info.NodeType == SERVER {
|
|
||||||
m.Cmdy(CODE_UPGRADE)
|
|
||||||
} else {
|
|
||||||
m.Cmdy(ice.EXIT, "1")
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
"diagram": {Help: "导图", Icon: "bi bi-diagram-3", Hand: func(m *ice.Message, arg ...string) {
|
"diagram": {Help: "导图", Icon: "bi bi-diagram-3", Hand: func(m *ice.Message, arg ...string) {
|
||||||
ctx.DisplayStorySpide(m.Cmdy(""), nfs.DIR_ROOT, ice.Info.NodeName, mdb.FIELD, SPACE, lex.SPLIT, nfs.PT, ctx.ACTION, ice.MAIN)
|
ctx.DisplayStorySpide(m.Cmdy(""), nfs.DIR_ROOT, ice.Info.NodeName, mdb.FIELD, SPACE, lex.SPLIT, nfs.PT, ctx.ACTION, ice.MAIN)
|
||||||
}},
|
}},
|
||||||
|
@ -194,7 +194,9 @@ func _space_exec(m *ice.Message, name string, source, target []string, c *websoc
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.OptionDefault(ice.MSG_COUNT, "0")
|
m.OptionDefault(ice.MSG_COUNT, "0")
|
||||||
m.Option(ice.MSG_DAEMON, kit.Keys(kit.Slice(kit.Reverse(kit.Simple(source)), 0, -1), m.Option(ice.MSG_DAEMON)))
|
kit.If(m.Option(ice.MSG_DAEMON), func(p string) {
|
||||||
|
m.Option(ice.MSG_DAEMON, kit.Keys(kit.Slice(kit.Reverse(kit.Simple(source)), 0, -1), p))
|
||||||
|
})
|
||||||
kit.If(aaa.Right(m, m.Detailv()), func() { m.TryCatch(true, func(_ *ice.Message) { m = m.Cmd() }) })
|
kit.If(aaa.Right(m, m.Detailv()), func() { m.TryCatch(true, func(_ *ice.Message) { m = m.Cmd() }) })
|
||||||
kit.If(m.Optionv(ice.MSG_ARGS) != nil, func() { m.Options(ice.MSG_ARGS, kit.Simple(m.Optionv(ice.MSG_ARGS))) })
|
kit.If(m.Optionv(ice.MSG_ARGS) != nil, func() { m.Options(ice.MSG_ARGS, kit.Simple(m.Optionv(ice.MSG_ARGS))) })
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ const SCRIPT = "script"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SCRIPT: {Name: "script zone id auto", Help: "脚本化", Icon: "script.png", Actions: ice.MergeActions(
|
SCRIPT: {Name: "script zone id auto", Help: "脚本化", Icon: "script.png", Actions: ice.MergeActions(
|
||||||
mdb.ImportantZoneAction(mdb.FIELDS, "time,id,space,index,play,status,style"), mdb.ExportZoneAction(),
|
mdb.ExportZoneAction(mdb.FIELDS, "time,id,space,index,play,status,style"),
|
||||||
), Hand: func(m *ice.Message, arg ...string) {
|
), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if mdb.ZoneSelect(m.Options(mdb.CACHE_LIMIT, "30"), arg...).Display(""); len(arg) == 0 {
|
if mdb.ZoneSelect(m.Options(mdb.CACHE_LIMIT, "30"), arg...).Display(""); len(arg) == 0 {
|
||||||
m.PushAction(cli.RECORD, mdb.REMOVE).Action(mdb.CREATE, cli.STOP)
|
m.PushAction(cli.RECORD, mdb.REMOVE).Action(mdb.CREATE, cli.STOP)
|
||||||
|
@ -44,7 +44,7 @@ func init() {
|
|||||||
uri := "/publish/" + kit.Format(value[nfs.FILE])
|
uri := "/publish/" + kit.Format(value[nfs.FILE])
|
||||||
kit.If(m.Spawn().ParseLink(ice.Info.Domain).Option(ice.MSG_USERPOD), func(p string) { uri = kit.MergeURL(uri, ice.POD, p) })
|
kit.If(m.Spawn().ParseLink(ice.Info.Domain).Option(ice.MSG_USERPOD), func(p string) { uri = kit.MergeURL(uri, ice.POD, p) })
|
||||||
dir := path.Join(kit.Format(value[nfs.PATH]), kit.Format(value[nfs.FILE]))
|
dir := path.Join(kit.Format(value[nfs.PATH]), kit.Format(value[nfs.FILE]))
|
||||||
web.GoToast(m, m.PrefixKey(), func(toast func(name string, count, total int)) []string {
|
web.GoToast(m, web.DOWNLOAD, func(toast func(name string, count, total int)) []string {
|
||||||
switch web.SpideSave(m, dir, uri, func(count, total, value int) {
|
switch web.SpideSave(m, dir, uri, func(count, total, value int) {
|
||||||
toast(dir, count, total)
|
toast(dir, count, total)
|
||||||
}); value[mdb.TYPE] {
|
}); value[mdb.TYPE] {
|
||||||
@ -56,7 +56,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
m.Cmdy(nfs.DIR, dir, "time,size,path,hash")
|
m.Cmdy(nfs.DIR, dir, "time,size,path,hash").Push(web.ORIGIN, kit.MergeURL2(web.SpideOrigin(m, ice.DEV_IP), uri))
|
||||||
})
|
})
|
||||||
if web.ToastSuccess(m); m.Option(ice.EXIT) == ice.TRUE {
|
if web.ToastSuccess(m); m.Option(ice.EXIT) == ice.TRUE {
|
||||||
web.Toast(m, cli.RESTART)
|
web.Toast(m, cli.RESTART)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user