1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-03-19 15:18:40 +08:00
parent 0d62c5cccc
commit 3fda66455c
6 changed files with 15 additions and 25 deletions

View File

@ -26,16 +26,13 @@ func _c_exec(m *ice.Message, arg ...string) {
_vimer_make(m, arg[2], msg)
}
}
func _c_tags(m *ice.Message, man string, cmd ...string) {
func _c_tags(m *ice.Message, cmd ...string) {
if !nfs.ExistsFile(m, path.Join(m.Option(nfs.PATH), nfs.TAGS)) {
m.Cmd(cli.SYSTEM, cmd, kit.Dict(cli.CMD_DIR, m.Option(nfs.PATH)))
}
if _inner_tags(m, m.Option(nfs.PATH), m.Option(mdb.NAME)); !cli.IsSuccess(m) || m.Length() == 0 {
m.Push(nfs.FILE, kit.Keys(m.Option(mdb.NAME), man)).Push(nfs.LINE, "1")
}
_inner_tags(m, m.Option(nfs.PATH), m.Option(mdb.NAME))
}
const MAN = "man"
const H = "h"
const C = "c"
@ -45,10 +42,10 @@ func init() {
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _c_exec(m, arg...) }},
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.c")) }},
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, "ctags", "-a", "-R", nfs.PWD) }},
}, PlugAction())},
H: {Name: "h path auto", Help: "编程", Actions: ice.MergeActions(ice.Actions{
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, "ctags", "-a", "-R", nfs.PWD) }},
}, PlugAction())},
})
}

View File

@ -83,7 +83,7 @@ func _mod_show(m *ice.Message, file string) {
kit.Switch(kit.Select("", block, len(ls) > 1), REQUIRE, func() { require[ls[0]] = ls[1] }, REPLACE, func() { replace[ls[0]] = ls[2] })
}
})
kit.Fetch(require, func(k, v string) { m.Push(REQUIRE, k).Push(VERSION, v).Push(REPLACE, kit.Select("", replace[k])) })
kit.For(require, func(k, v string) { m.Push(REQUIRE, k).Push(VERSION, v).Push(REPLACE, kit.Select("", replace[k])) })
m.StatusTimeCount()
}
func _sum_show(m *ice.Message, file string) {
@ -92,7 +92,6 @@ func _sum_show(m *ice.Message, file string) {
}).StatusTimeCount()
}
const GODOC = "godoc"
const SUM = "sum"
const MOD = "mod"
const GO = "go"
@ -100,7 +99,6 @@ const GO = "go"
func init() {
Index.MergeCommands(ice.Commands{
GO: {Name: "go path auto", Help: "后端编程", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(NAVIGATE, mdb.CREATE, GODOC, m.PrefixKey()) }},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
cmds, text := "ice.bin source stdio", ctx.GetFileCmd(path.Join(arg[2], arg[1]))
if text != "" {
@ -123,20 +121,15 @@ func init() {
m.Echo(nfs.Template(m, "demo.go"), path.Base(path.Dir(path.Join(arg[2], arg[1]))))
}},
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { _go_complete(m, arg...) }},
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, GODOC, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD) }},
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD) }},
}, PlugAction())},
MOD: {Help: "模块", Actions: ice.MergeActions(ice.Actions{
MOD: {Actions: ice.MergeActions(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
}, PlugAction())},
SUM: {Help: "版本", Actions: ice.MergeActions(ice.Actions{
SUM: {Actions: ice.MergeActions(ice.Actions{
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }},
}, PlugAction())},
GODOC: {Help: "文档", Actions: ice.MergeActions(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
arg[1] = strings.Replace(arg[1], "kit.", "shylinux.com/x/toolkits.", 1)
arg[1] = strings.Replace(arg[1], "m.", "shylinux.com/x/ice.Message.", 1)
m.Cmdy(cli.SYSTEM, GO, "doc", kit.TrimExt(arg[1], GODOC), kit.Dict(cli.CMD_DIR, arg[2]))
}},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }},
}, PlugAction())},
})
}

View File

@ -145,7 +145,7 @@ func InnerPath(arg ...string) (dir, file string) {
func PlugAction() ice.Actions {
return ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
kit.Fetch([]string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE}, func(cmd string) { m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) })
kit.For([]string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE}, func(cmd string) { m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) })
LoadPlug(m, m.CommandKey())
}},
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Config(PLUG)) }},
@ -164,7 +164,7 @@ func LoadPlug(m *ice.Message, lang ...string) {
for _, lang := range lang {
m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, kit.Ext(lang)), ice.TRUE)
m.Confm(lang, kit.Keym(PLUG, PREPARE), func(k string, v ice.Any) {
kit.Fetch(kit.Simple(v), func(v string) { m.Conf(lang, kit.Keym(PLUG, KEYWORD, v), k) })
kit.For(kit.Simple(v), func(v string) { m.Conf(lang, kit.Keym(PLUG, KEYWORD, v), k) })
})
}
}

View File

@ -55,7 +55,7 @@ func init() {
}},
"keys": {Name: "keys", Help: "用户密钥", Hand: func(m *ice.Message, arg ...string) {
_oauth_header(m).SetAppend()
kit.Fetch(web.SpideGet(m, API_GITHUB+"user/keys"), func(index int, value ice.Map) {
kit.For(web.SpideGet(m, API_GITHUB+"user/keys"), func(index int, value ice.Map) {
m.PushRecord(value, "created_at,title,id,key")
})
m.PushAction(mdb.DELETE)

View File

@ -46,7 +46,7 @@ func init() {
m.Cmdy(cli.SYSTEM, cmds, "-c", text).Status(ssh.SHELL, strings.ReplaceAll(text, ice.NL, "; "))
}},
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.sh")) }},
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, "ctags", "-a", "-R", nfs.PWD) }},
}, PlugAction())},
})
}

View File

@ -196,6 +196,6 @@ func Complete(m *ice.Message, text string, data ice.Map) {
m.Push(mdb.TEXT, kit.Simple(data[kit.Slice(kit.Split(text, " ."), -1)[0]]))
} else {
m.Push(mdb.TEXT, data[""])
kit.Fetch(data, func(k string, v ice.Any) { m.Push(mdb.TEXT, k) })
kit.For(data, func(k string, v ice.Any) { m.Push(mdb.TEXT, k) })
}
}