diff --git a/core/code/c.go b/core/code/c.go index 879f86f1..1e22cb16 100644 --- a/core/code/c.go +++ b/core/code/c.go @@ -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())}, }) } diff --git a/core/code/go.go b/core/code/go.go index 8e461f74..86d7d6ac 100644 --- a/core/code/go.go +++ b/core/code/go.go @@ -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())}, }) } diff --git a/core/code/inner.go b/core/code/inner.go index 127d3c6f..1674516e 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -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) }) }) } } diff --git a/core/code/oauth.go b/core/code/oauth.go index 367ab2e6..7e6258d6 100644 --- a/core/code/oauth.go +++ b/core/code/oauth.go @@ -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) diff --git a/core/code/sh.go b/core/code/sh.go index 88cf5788..d5460c95 100644 --- a/core/code/sh.go +++ b/core/code/sh.go @@ -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())}, }) } diff --git a/core/code/vimer.go b/core/code/vimer.go index be93efda..e493d73c 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -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) }) } }