From abf843548f9bf56233ad4d37b26fa9dad8f86300 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sun, 4 Dec 2022 15:38:41 +0800 Subject: [PATCH] opt code --- base/ctx/command.go | 2 +- core/code/c.go | 2 +- core/code/go.go | 172 +++++++++++++++++--------------------------- core/code/inner.go | 102 +++++++++----------------- misc.go | 3 +- 5 files changed, 103 insertions(+), 178 deletions(-) diff --git a/base/ctx/command.go b/base/ctx/command.go index 6b0fec8e..8e32fba1 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -199,7 +199,7 @@ func TravelCmd(m *ice.Message, cb func(key, file, line string)) *ice.Message { if IsOrderCmd(key) { return } - if ls := kit.Split(cmd.GetFileLines(), ice.DF); len(ls) > 0 { + if ls := kit.Split(cmd.GetFileLines(), ice.DF); len(ls) > 0 && cmd.Name != "" { cb(kit.Keys(s.Cap(ice.CTX_FOLLOW), key), strings.TrimPrefix(ls[0], kit.Path("")+ice.PS), kit.Select("1", ls, 1)) } }) diff --git a/core/code/c.go b/core/code/c.go index 78c2665a..83ea6675 100644 --- a/core/code/c.go +++ b/core/code/c.go @@ -45,7 +45,7 @@ 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...) }}, NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }}, - TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { kit.IfElse(arg[0] == C, func() { m.Echo(_c_template) }) }}, + TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { kit.If(arg[0] == C, func() { m.Echo(_c_template) }) }}, }, PlugAction(), LangAction())}, }) } diff --git a/core/code/go.go b/core/code/go.go index 1d021281..3046f8db 100644 --- a/core/code/go.go +++ b/core/code/go.go @@ -16,65 +16,52 @@ func _go_trans(m *ice.Message, key string) string { switch key { case "m", "msg": key = "icebergs.Message" + case "code", "wiki", "chat", "team", "mall": + key = "shylinux.com/x/icebergs/core/" + key + case "aaa", "cli", "ctx", "mdb", "nfs", "web": + key = "shylinux.com/x/icebergs/base/" + key + case "ice": + key = "shylinux.com/x/icebergs" case "kit": key = "shylinux.com/x/toolkits" - case "ice": - key = "shylinux.com/x/ice" - case "mdb", "cli", "nfs": - key = "shylinux.com/x/icebergs/base/" + key } return key } func _go_complete(m *ice.Message, arg ...string) { + const ( + PACKAGE = "package" + IMPORT = "import" + CONST = "const" + TYPE = "type" + FUNC = "func" + VAR = "var" + ) if m.Option(mdb.TEXT) == "" { - m.Push(mdb.TEXT, "package", "import", "const", "type", "func", "var") - return - } - - if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) { - key := kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0] - key = _go_trans(m, key) - - msg := m.Cmd(cli.SYSTEM, GO, "doc", key) + m.Push(mdb.TEXT, PACKAGE, IMPORT, CONST, TYPE, FUNC, VAR) + } else if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) { + msg := m.Cmd(cli.SYSTEM, GO, "doc", _go_trans(m, kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0])) for _, l := range strings.Split(kit.Select(msg.Result(), msg.Append(cli.CMD_OUT)), ice.NL) { - ls := kit.Split(l, "\t *", "()") - if len(ls) < 2 { - continue - } - switch ls[0] { - case "const", "type", "func", "var": - if ls[1] == "(" { - m.Push(mdb.NAME, ls[5]) - } else { - m.Push(mdb.NAME, ls[1]) - } - m.Push(mdb.TEXT, l) + if ls := kit.Split(l, "\t *", "()"); len(ls) > 1 { + kit.Switch(ls[0], []string{CONST, TYPE, FUNC, VAR}, func() { + kit.If(ls[1] == "(", func() { m.Push(mdb.NAME, ls[5]) }, func() { m.Push(mdb.NAME, ls[1]) }) + m.Push(mdb.TEXT, l) + }) } } - return - } - - m.Push(mdb.TEXT, "m", "msg", "arg", "mdb", "cli", "nfs", "ice", "kit") - for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, GO, "list", "std"), ice.NL) { - m.Push(mdb.TEXT, kit.Slice(kit.Split(l, ice.PS), -1)[0]) + } else { + m.Push(mdb.TEXT, "m", "msg", "code", "wiki", "chat", "team", "mall", "arg", "aaa", "cli", "ctx", "mdb", "nfs", "web", "ice", "kit") + for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, GO, "list", "std"), ice.NL) { + m.Push(mdb.TEXT, kit.Slice(kit.Split(l, ice.PS), -1)[0]) + } } } func _go_exec(m *ice.Message, arg ...string) { if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { ctx.ProcessCommand(m, cmd, kit.Simple()) - return } } func _go_show(m *ice.Message, arg ...string) { TagsList(m, "gotags", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))) - return - if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { - ctx.ProcessCommand(m, cmd, kit.Simple()) - } else if p := strings.ReplaceAll(path.Join(arg[2], arg[1]), ".go", ".shy"); arg[1] != "main.go" && nfs.ExistsFile(m, p) { - ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(p)) - } else { - TagsList(m, "gotags", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))) - } } func _mod_show(m *ice.Message, file string) { const ( @@ -83,16 +70,12 @@ func _mod_show(m *ice.Message, file string) { REPLACE = "replace" VERSION = "version" ) - - block := "" - require := ice.Maps{} - replace := ice.Maps{} + require, replace, block := ice.Maps{}, ice.Maps{}, "" m.Cmd(nfs.CAT, file, func(ls []string, line string) { switch { case strings.HasPrefix(line, "//"): case strings.HasPrefix(line, MODULE): - require[ls[1]] = m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags") - replace[ls[1]] = nfs.PWD + require[ls[1]], replace[ls[1]] = m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags"), nfs.PWD case strings.HasPrefix(line, REQUIRE+" ("): block = REQUIRE case strings.HasPrefix(line, REPLACE+" ("): @@ -104,81 +87,56 @@ func _mod_show(m *ice.Message, file string) { case strings.HasPrefix(line, REPLACE): replace[ls[1]] = ls[3] default: - if len(ls) > 1 { - switch block { - case REQUIRE: - require[ls[0]] = ls[1] - case REPLACE: - replace[ls[0]] = ls[2] - } - } + kit.Switch(kit.Select("", block, len(ls) > 1), REQUIRE, func() { require[ls[0]] = ls[1] }, REPLACE, func() { replace[ls[0]] = ls[2] }) } }) - for k, v := range require { - m.Push(REQUIRE, k) - m.Push(VERSION, v) - m.Push(REPLACE, kit.Select("", replace[k])) - } - m.Sort(REPLACE).StatusTimeCount() -} -func _sum_show(m *ice.Message, file string) { - m.Cmd(nfs.CAT, file, func(ls []string, line string) { - m.Push("repos", ls[0]) - m.Push("version", ls[1]) - m.Push("hash", ls[2]) - }) + kit.Fetch(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) { + m.Cmdy(nfs.CAT, file, func(ls []string, line string) { + m.Push(nfs.REPOS, ls[0]).Push(nfs.VERSION, ls[1]).Push(mdb.HASH, ls[2]) + }).StatusTimeCount() +} -const GO = "go" -const GODOC = "godoc" -const MOD = "mod" const SUM = "sum" +const MOD = "mod" +const GODOC = "godoc" +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()) + SUM: {Help: "版本", Actions: ice.MergeActions(ice.Actions{ + mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }}, + }, PlugAction())}, + MOD: {Help: "模块", Actions: ice.MergeActions(ice.Actions{ + mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _mod_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) { _go_show(m, arg...) }}, - mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_exec(m, arg...) }}, - + }, PlugAction())}, + 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) { _go_show(m, arg...) }}, + mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_exec(m, arg...) }}, COMPLETE: {Hand: func(m *ice.Message, arg ...string) { - if len(arg) > 0 && arg[0] == mdb.FOREACH { - return - } - _go_complete(m, arg...) + kit.If(len(arg) == 0 || arg[0] != mdb.FOREACH, func() { _go_complete(m, arg...) }) }}, TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { - switch arg[0] { - case nfs.GO: - m.Echo(`package %s + kit.If(arg[0] == GO, func() { m.Echo(_go_template, path.Base(path.Dir(path.Join(arg[2], arg[1])))) }) + }}, + NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, GODOC, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD) }}, + }, PlugAction(), LangAction())}, + }) +} + +var _go_template = `package %s func init() { } -`, path.Base(path.Dir(path.Join(arg[2], arg[1])))) - } - }}, - NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { - _c_tags(m, GODOC, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD) - }}, - }, PlugAction(), LangAction())}, - GODOC: {Name: "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) - if m.Cmdy(cli.SYSTEM, GO, "doc", strings.TrimSuffix(arg[1], ".godoc"), kit.Dict(cli.CMD_DIR, arg[2])); m.Append(cli.CMD_ERR) != "" { - m.Result(m.Append(cli.CMD_OUT)) - } - }}, - }, PlugAction())}, - MOD: {Name: "mod", Help: "模块", Actions: ice.MergeActions(ice.Actions{ - mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }}, - }, PlugAction())}, - SUM: {Name: "sum", Help: "版本", Actions: ice.MergeActions(ice.Actions{ - 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 65df7485..cd6fcbe8 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -17,24 +17,16 @@ import ( ) func _inner_list(m *ice.Message, ext, file, dir string) { - if aaa.Right(m, dir, file) { - if nfs.IsSourceFile(m, ext) { - m.Cmdy(nfs.CAT, path.Join(dir, file)) - } - if m.IsErrNotFound() { - _inner_show(m.SetResult(), ext, file, dir) - } - } + kit.If(aaa.Right(m, dir, file), func() { + kit.If(nfs.IsSourceFile(m, ext), func() { m.Cmdy(nfs.CAT, path.Join(dir, file)) }) + kit.If(m.IsErrNotFound(), func() { _inner_show(m.RenderResult().SetResult(), ext, file, dir) }) + }) } func _inner_show(m *ice.Message, ext, file, dir string) { - if aaa.Right(m, dir, file) { - m.Cmdy(mdb.RENDER, ext, file, dir) - } + kit.If(aaa.Right(m, dir, file), func() { m.Cmdy(mdb.RENDER, ext, file, dir) }) } func _inner_exec(m *ice.Message, ext, file, dir string) { - if aaa.Right(m, dir, file) { - m.Cmdy(mdb.ENGINE, ext, file, dir) - } + kit.If(aaa.Right(m, dir, file), func() { m.Cmdy(mdb.ENGINE, ext, file, dir) }) } func _inner_tags(m *ice.Message, dir string, value string) { for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, cli.GREP, "^"+value+"\\>", nfs.TAGS, kit.Dict(cli.CMD_DIR, dir)), ice.NL) { @@ -45,7 +37,6 @@ func _inner_tags(m *ice.Message, dir string, value string) { if len(ls) < 3 { continue } - file, ls := ls[1], strings.SplitN(ls[2], ";\"", 2) text := strings.TrimSuffix(strings.TrimPrefix(ls[0], "/^"), "$/") if text, line := _inner_line(m, kit.Path(dir, file), text); dir == "" { @@ -57,11 +48,9 @@ func _inner_tags(m *ice.Message, dir string, value string) { } func _inner_line(m *ice.Message, file, text string) (string, int) { line := kit.Int(text) - f, e := nfs.OpenFile(m, file) m.Assert(e) defer f.Close() - bio := bufio.NewScanner(f) for i := 1; bio.Scan(); i++ { if i == line || bio.Text() == text { @@ -93,22 +82,16 @@ const ( 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", Help: "源代码", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { - switch arg[0] { + switch p := kit.Select(nfs.PWD, arg, 1); arg[0] { case nfs.PATH: - p := kit.Select(nfs.PWD, arg, 1) - m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS).Sort(nfs.PATH).ProcessAgain() - if strings.HasPrefix(p, "usr/icebergs/core/") && len(kit.Split(p, ice.PS)) > 3 { - p = strings.Replace(p, "usr/icebergs/core/", "usr/volcanos/plugin/local/", 1) - m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS).Sort(nfs.PATH) - } else if strings.HasPrefix(p, "usr/volcanos/plugin/local/") && len(kit.Split(p, ice.PS)) > 4 { - p = strings.Replace(p, "usr/volcanos/plugin/local/", "usr/icebergs/core/", 1) - m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS).SortStrR(nfs.PATH) - } + m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS).ProcessAgain() + kit.If(strings.HasPrefix(p, bind[0]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[0], bind[1], 1), nfs.DIR_CLI_FIELDS) }) + kit.If(strings.HasPrefix(p, bind[1]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[1], bind[0], 1), nfs.DIR_CLI_FIELDS) }) case nfs.FILE: - p := kit.Select(nfs.PWD, arg, 1) m.Option(nfs.DIR_ROOT, m.Option(nfs.PATH)) m.Cmdy(nfs.DIR, kit.Select(path.Dir(p), p, strings.HasSuffix(p, ice.PS))+ice.PS, nfs.DIR_CLI_FIELDS).ProcessAgain() default: @@ -118,20 +101,18 @@ func init() { mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.PLUGIN, arg) }}, mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }}, - - cli.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(cli.GREP, arg[0], m.Option(nfs.PATH)).StatusTimeCount(mdb.INDEX, 0) + nfs.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(nfs.GREP, arg[0], m.Option(nfs.PATH)).StatusTimeCount(mdb.INDEX, 0) }}, nfs.TAGS: {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) { if _inner_tags(m, m.Option(nfs.PATH), arg[0]); m.Length() == 0 { _inner_tags(m, "", arg[0]) } }}, - NAVIGATE: {Name: "navigate", Help: "跳转", Hand: func(m *ice.Message, arg ...string) { + NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)) - }}, - FAVOR: {Name: "favor", Help: "收藏"}, - ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { + }}, FAVOR: {}, + ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) { if !ctx.PodCmd(m, ctx.COMMAND, arg) { m.Cmdy(ctx.COMMAND, arg) } @@ -146,42 +127,39 @@ func init() { arg[0] = strings.TrimSuffix(arg[0], arg[1]) ctx.ProcessRewrite(m, nfs.PATH, arg[0], nfs.FILE, arg[1]) return - } - if len(arg) < 2 { + } else if len(arg) < 2 { nfs.Dir(m, nfs.PATH) return } - arg[1] = strings.Split(arg[1], ice.FS)[0] _inner_list(m, kit.Ext(arg[1]), arg[1], arg[0]) - defer m.Cmd(FAVOR, mdb.INSERT, mdb.ZONE, "_recent_file", nfs.PATH, arg[0], nfs.FILE, arg[1]) - m.Option("tabs", m.Config("show.tabs")) - m.Option("plug", m.Config("show.plug")) - m.Option("exts", m.Config("show.exts")) + m.Cmd(FAVOR, mdb.INSERT, mdb.ZONE, "_recent_file", nfs.PATH, arg[0], nfs.FILE, arg[1]) + m.Options("tabs", m.Config("show.tabs"), "plug", m.Config("show.plug"), "exts", m.Config("show.exts")) ctx.DisplayLocal(m, "") }}, }) ctx.AddRunChecker(func(m *ice.Message, cmd, check string, arg ...string) bool { - process := func(m *ice.Message, file string) { + process := func(m *ice.Message, file string) bool { ls, n := kit.Split(file, ice.PS), kit.Int(kit.Select("2", "1", strings.HasPrefix(file, ice.SRC+ice.PS))) ctx.ProcessFloat(m, web.CODE_INNER, kit.Join(kit.Slice(ls, 0, n), ice.PS)+ice.PS, kit.Join(kit.Slice(ls, n), ice.PS)) + return true } switch check { case nfs.SCRIPT: if file := kit.ExtChange(ctx.GetCmdFile(m, cmd), nfs.JS); nfs.ExistsFile(m, file) { - process(m, file) - return true - } else if strings.HasPrefix(file, path.Join(ice.USR_ICEBERGS, ice.CORE)) { - if file := strings.Replace(file, path.Join(ice.USR_ICEBERGS, ice.CORE), path.Join(ice.USR_VOLCANOS, "plugin/local"), 1); nfs.ExistsFile(m, file) { - process(m, file) - return true + return process(m, file) + } else if strings.HasPrefix(file, bind[0]) { + if file := strings.Replace(file, bind[0], bind[1], 1); nfs.ExistsFile(m, file) { + return process(m, file) } } case nfs.SOURCE: + m.Debug("what %v", cmd) if file := ctx.GetCmdFile(m, cmd); nfs.ExistsFile(m, file) { - process(m, file) - return true + m.Debug("what %v", file) + return process(m, file) } + m.Debug("what %v", cmd) } return false }) @@ -189,9 +167,7 @@ func init() { func PlugAction() ice.Actions { return ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - for _, cmd := range []string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE} { - m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) - } + kit.Fetch([]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)) }}, @@ -200,30 +176,22 @@ func PlugAction() ice.Actions { mdb.SELECT: {Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() { m.Cmdy("", mdb.ENGINE, m.CommandKey(), arg[0], ice.SRC) - return + } else { + m.Cmdy(nfs.DIR, arg, kit.Dict(nfs.DIR_ROOT, ice.SRC, nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, kit.ExtReg(m.CommandKey()))) } - m.Option(nfs.DIR_ROOT, ice.SRC) - m.Option(nfs.DIR_DEEP, ice.TRUE) - m.Option(nfs.DIR_REG, kit.Format(`.*\.(%s)$`, m.CommandKey())) - m.Cmdy(nfs.DIR, arg) }}, } } 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(key string, value ice.Any) { - for _, v := range kit.Simple(value) { - m.Conf(lang, kit.Keym(PLUG, KEYWORD, v), key) - } + 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) }) }) } } func TagsList(m *ice.Message, cmds ...string) { - if len(cmds) == 0 { - cmds = []string{"ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))} - } - for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, cmds), ice.NL) { + for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, kit.Default(cmds, "ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))), ice.NL) { if strings.HasPrefix(l, "!_") { continue } diff --git a/misc.go b/misc.go index 28a98677..423b393b 100644 --- a/misc.go +++ b/misc.go @@ -282,8 +282,7 @@ func (c *Context) _command(m *Message, cmd *Command, key string, arg ...string) } func (c *Context) _action(m *Message, cmd *Command, key string, sub string, h *Action, arg ...string) *Message { if h.Hand == nil { - m.Cmdy(kit.Split(h.Name), arg) - return m + return m.Cmdy(kit.Split(kit.Select(sub, h.Name)), arg) } if m._key, m._cmd, m._sub = key, cmd, sub; len(h.List) > 0 && sub != SEARCH { order := false