1
0
mirror of https://shylinux.com/x/icebergs synced 2025-06-26 18:37:29 +08:00
This commit is contained in:
harveyshao 2022-12-04 15:38:41 +08:00
parent 20e53d3885
commit abf843548f
5 changed files with 103 additions and 178 deletions

View File

@ -199,7 +199,7 @@ func TravelCmd(m *ice.Message, cb func(key, file, line string)) *ice.Message {
if IsOrderCmd(key) { if IsOrderCmd(key) {
return 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)) cb(kit.Keys(s.Cap(ice.CTX_FOLLOW), key), strings.TrimPrefix(ls[0], kit.Path("")+ice.PS), kit.Select("1", ls, 1))
} }
}) })

View File

@ -45,7 +45,7 @@ func init() {
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }}, 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...) }}, 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) }}, 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())}, }, PlugAction(), LangAction())},
}) })
} }

View File

@ -16,65 +16,52 @@ func _go_trans(m *ice.Message, key string) string {
switch key { switch key {
case "m", "msg": case "m", "msg":
key = "icebergs.Message" 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": case "kit":
key = "shylinux.com/x/toolkits" 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 return key
} }
func _go_complete(m *ice.Message, arg ...string) { 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) == "" { if m.Option(mdb.TEXT) == "" {
m.Push(mdb.TEXT, "package", "import", "const", "type", "func", "var") m.Push(mdb.TEXT, PACKAGE, IMPORT, CONST, TYPE, FUNC, VAR)
return } 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]))
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)
for _, l := range strings.Split(kit.Select(msg.Result(), msg.Append(cli.CMD_OUT)), ice.NL) { for _, l := range strings.Split(kit.Select(msg.Result(), msg.Append(cli.CMD_OUT)), ice.NL) {
ls := kit.Split(l, "\t *", "()") if ls := kit.Split(l, "\t *", "()"); len(ls) > 1 {
if len(ls) < 2 { kit.Switch(ls[0], []string{CONST, TYPE, FUNC, VAR}, func() {
continue kit.If(ls[1] == "(", func() { m.Push(mdb.NAME, ls[5]) }, func() { m.Push(mdb.NAME, ls[1]) })
}
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) m.Push(mdb.TEXT, l)
})
} }
} }
return } else {
} m.Push(mdb.TEXT, "m", "msg", "code", "wiki", "chat", "team", "mall", "arg", "aaa", "cli", "ctx", "mdb", "nfs", "web", "ice", "kit")
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) { 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]) m.Push(mdb.TEXT, kit.Slice(kit.Split(l, ice.PS), -1)[0])
} }
} }
}
func _go_exec(m *ice.Message, arg ...string) { func _go_exec(m *ice.Message, arg ...string) {
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
ctx.ProcessCommand(m, cmd, kit.Simple()) ctx.ProcessCommand(m, cmd, kit.Simple())
return
} }
} }
func _go_show(m *ice.Message, arg ...string) { func _go_show(m *ice.Message, arg ...string) {
TagsList(m, "gotags", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))) 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) { func _mod_show(m *ice.Message, file string) {
const ( const (
@ -83,16 +70,12 @@ func _mod_show(m *ice.Message, file string) {
REPLACE = "replace" REPLACE = "replace"
VERSION = "version" VERSION = "version"
) )
require, replace, block := ice.Maps{}, ice.Maps{}, ""
block := ""
require := ice.Maps{}
replace := ice.Maps{}
m.Cmd(nfs.CAT, file, func(ls []string, line string) { m.Cmd(nfs.CAT, file, func(ls []string, line string) {
switch { switch {
case strings.HasPrefix(line, "//"): case strings.HasPrefix(line, "//"):
case strings.HasPrefix(line, MODULE): case strings.HasPrefix(line, MODULE):
require[ls[1]] = m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags") require[ls[1]], replace[ls[1]] = m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags"), nfs.PWD
replace[ls[1]] = nfs.PWD
case strings.HasPrefix(line, REQUIRE+" ("): case strings.HasPrefix(line, REQUIRE+" ("):
block = REQUIRE block = REQUIRE
case strings.HasPrefix(line, REPLACE+" ("): case strings.HasPrefix(line, REPLACE+" ("):
@ -104,81 +87,56 @@ func _mod_show(m *ice.Message, file string) {
case strings.HasPrefix(line, REPLACE): case strings.HasPrefix(line, REPLACE):
replace[ls[1]] = ls[3] replace[ls[1]] = ls[3]
default: default:
if len(ls) > 1 { kit.Switch(kit.Select("", block, len(ls) > 1), REQUIRE, func() { require[ls[0]] = ls[1] }, REPLACE, func() { replace[ls[0]] = ls[2] })
switch block {
case REQUIRE:
require[ls[0]] = ls[1]
case REPLACE:
replace[ls[0]] = ls[2]
}
}
} }
}) })
for k, v := range require { kit.Fetch(require, func(k, v string) { m.Push(REQUIRE, k).Push(VERSION, v).Push(REPLACE, kit.Select("", replace[k])) })
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])
})
m.StatusTimeCount() 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 SUM = "sum"
const MOD = "mod"
const GODOC = "godoc"
const GO = "go"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
GO: {Name: "go path auto", Help: "后端", Actions: ice.MergeActions(ice.Actions{ SUM: {Help: "版本", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }},
m.Cmd(NAVIGATE, mdb.CREATE, GODOC, m.PrefixKey()) }, 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]))
}}, }},
}, 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.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...) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_exec(m, arg...) }},
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 0 && arg[0] == mdb.FOREACH { kit.If(len(arg) == 0 || arg[0] != mdb.FOREACH, func() { _go_complete(m, arg...) })
return
}
_go_complete(m, arg...)
}}, }},
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
switch arg[0] { kit.If(arg[0] == GO, func() { m.Echo(_go_template, path.Base(path.Dir(path.Join(arg[2], arg[1])))) })
case nfs.GO: }},
m.Echo(`package %s 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() { 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())},
})
}

View File

@ -17,24 +17,16 @@ import (
) )
func _inner_list(m *ice.Message, ext, file, dir string) { func _inner_list(m *ice.Message, ext, file, dir string) {
if aaa.Right(m, dir, file) { kit.If(aaa.Right(m, dir, file), func() {
if nfs.IsSourceFile(m, ext) { kit.If(nfs.IsSourceFile(m, ext), func() { m.Cmdy(nfs.CAT, path.Join(dir, file)) })
m.Cmdy(nfs.CAT, path.Join(dir, file)) kit.If(m.IsErrNotFound(), func() { _inner_show(m.RenderResult().SetResult(), ext, file, dir) })
} })
if m.IsErrNotFound() {
_inner_show(m.SetResult(), ext, file, dir)
}
}
} }
func _inner_show(m *ice.Message, ext, file, dir string) { func _inner_show(m *ice.Message, ext, file, dir string) {
if aaa.Right(m, dir, file) { kit.If(aaa.Right(m, dir, file), func() { m.Cmdy(mdb.RENDER, ext, file, dir) })
m.Cmdy(mdb.RENDER, ext, file, dir)
}
} }
func _inner_exec(m *ice.Message, ext, file, dir string) { func _inner_exec(m *ice.Message, ext, file, dir string) {
if aaa.Right(m, dir, file) { kit.If(aaa.Right(m, dir, file), func() { m.Cmdy(mdb.ENGINE, ext, file, dir) })
m.Cmdy(mdb.ENGINE, ext, file, dir)
}
} }
func _inner_tags(m *ice.Message, dir string, value string) { 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) { 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 { if len(ls) < 3 {
continue continue
} }
file, ls := ls[1], strings.SplitN(ls[2], ";\"", 2) file, ls := ls[1], strings.SplitN(ls[2], ";\"", 2)
text := strings.TrimSuffix(strings.TrimPrefix(ls[0], "/^"), "$/") text := strings.TrimSuffix(strings.TrimPrefix(ls[0], "/^"), "$/")
if text, line := _inner_line(m, kit.Path(dir, file), text); dir == "" { 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) { func _inner_line(m *ice.Message, file, text string) (string, int) {
line := kit.Int(text) line := kit.Int(text)
f, e := nfs.OpenFile(m, file) f, e := nfs.OpenFile(m, file)
m.Assert(e) m.Assert(e)
defer f.Close() defer f.Close()
bio := bufio.NewScanner(f) bio := bufio.NewScanner(f)
for i := 1; bio.Scan(); i++ { for i := 1; bio.Scan(); i++ {
if i == line || bio.Text() == text { if i == line || bio.Text() == text {
@ -93,22 +82,16 @@ const (
const INNER = "inner" const INNER = "inner"
func init() { func init() {
var bind = []string{"usr/icebergs/core/", "usr/volcanos/plugin/local/"}
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
INNER: {Name: "inner path=src/@key file=main.go@key line=1 auto", Help: "源代码", Actions: ice.MergeActions(ice.Actions{ 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) { 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: case nfs.PATH:
p := kit.Select(nfs.PWD, arg, 1) m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS).ProcessAgain()
m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS).Sort(nfs.PATH).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) })
if strings.HasPrefix(p, "usr/icebergs/core/") && len(kit.Split(p, ice.PS)) > 3 { kit.If(strings.HasPrefix(p, bind[1]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[1], bind[0], 1), nfs.DIR_CLI_FIELDS) })
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)
}
case nfs.FILE: case nfs.FILE:
p := kit.Select(nfs.PWD, arg, 1)
m.Option(nfs.DIR_ROOT, m.Option(nfs.PATH)) 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() m.Cmdy(nfs.DIR, kit.Select(path.Dir(p), p, strings.HasSuffix(p, ice.PS))+ice.PS, nfs.DIR_CLI_FIELDS).ProcessAgain()
default: default:
@ -118,20 +101,18 @@ func init() {
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.PLUGIN, arg) }}, 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.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]) }}, mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }},
nfs.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
cli.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)
m.Cmdy(cli.GREP, arg[0], m.Option(nfs.PATH)).StatusTimeCount(mdb.INDEX, 0)
}}, }},
nfs.TAGS: {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) { 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 { if _inner_tags(m, m.Option(nfs.PATH), arg[0]); m.Length() == 0 {
_inner_tags(m, "", arg[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)) m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
}}, }}, FAVOR: {},
FAVOR: {Name: "favor", Help: "收藏"}, ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) {
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
if !ctx.PodCmd(m, ctx.COMMAND, arg) { if !ctx.PodCmd(m, ctx.COMMAND, arg) {
m.Cmdy(ctx.COMMAND, arg) m.Cmdy(ctx.COMMAND, arg)
} }
@ -146,42 +127,39 @@ func init() {
arg[0] = strings.TrimSuffix(arg[0], arg[1]) arg[0] = strings.TrimSuffix(arg[0], arg[1])
ctx.ProcessRewrite(m, nfs.PATH, arg[0], nfs.FILE, arg[1]) ctx.ProcessRewrite(m, nfs.PATH, arg[0], nfs.FILE, arg[1])
return return
} } else if len(arg) < 2 {
if len(arg) < 2 {
nfs.Dir(m, nfs.PATH) nfs.Dir(m, nfs.PATH)
return return
} }
arg[1] = strings.Split(arg[1], ice.FS)[0] arg[1] = strings.Split(arg[1], ice.FS)[0]
_inner_list(m, kit.Ext(arg[1]), arg[1], arg[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.Cmd(FAVOR, mdb.INSERT, mdb.ZONE, "_recent_file", nfs.PATH, arg[0], nfs.FILE, arg[1])
m.Option("tabs", m.Config("show.tabs")) m.Options("tabs", m.Config("show.tabs"), "plug", m.Config("show.plug"), "exts", m.Config("show.exts"))
m.Option("plug", m.Config("show.plug"))
m.Option("exts", m.Config("show.exts"))
ctx.DisplayLocal(m, "") ctx.DisplayLocal(m, "")
}}, }},
}) })
ctx.AddRunChecker(func(m *ice.Message, cmd, check string, arg ...string) bool { 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))) 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)) 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 { switch check {
case nfs.SCRIPT: case nfs.SCRIPT:
if file := kit.ExtChange(ctx.GetCmdFile(m, cmd), nfs.JS); nfs.ExistsFile(m, file) { if file := kit.ExtChange(ctx.GetCmdFile(m, cmd), nfs.JS); nfs.ExistsFile(m, file) {
process(m, file) return process(m, file)
return true } else if strings.HasPrefix(file, bind[0]) {
} else if strings.HasPrefix(file, path.Join(ice.USR_ICEBERGS, ice.CORE)) { if file := strings.Replace(file, bind[0], bind[1], 1); nfs.ExistsFile(m, file) {
if file := strings.Replace(file, path.Join(ice.USR_ICEBERGS, ice.CORE), path.Join(ice.USR_VOLCANOS, "plugin/local"), 1); nfs.ExistsFile(m, file) { return process(m, file)
process(m, file)
return true
} }
} }
case nfs.SOURCE: case nfs.SOURCE:
m.Debug("what %v", cmd)
if file := ctx.GetCmdFile(m, cmd); nfs.ExistsFile(m, file) { if file := ctx.GetCmdFile(m, cmd); nfs.ExistsFile(m, file) {
process(m, file) m.Debug("what %v", file)
return true return process(m, file)
} }
m.Debug("what %v", cmd)
} }
return false return false
}) })
@ -189,9 +167,7 @@ func init() {
func PlugAction() ice.Actions { func PlugAction() ice.Actions {
return ice.Actions{ return ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range []string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE} { kit.Fetch([]string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE}, func(cmd string) { m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) })
m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey())
}
LoadPlug(m, m.CommandKey()) LoadPlug(m, m.CommandKey())
}}, }},
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Config(PLUG)) }}, 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) { mdb.SELECT: {Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() { if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() {
m.Cmdy("", mdb.ENGINE, m.CommandKey(), arg[0], ice.SRC) 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) { func LoadPlug(m *ice.Message, lang ...string) {
for _, lang := range lang { for _, lang := range lang {
m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, kit.Ext(lang)), ice.TRUE) 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) { m.Confm(lang, kit.Keym(PLUG, PREPARE), func(k string, v ice.Any) {
for _, v := range kit.Simple(value) { kit.Fetch(kit.Simple(v), func(v string) { m.Conf(lang, kit.Keym(PLUG, KEYWORD, v), k) })
m.Conf(lang, kit.Keym(PLUG, KEYWORD, v), key)
}
}) })
} }
} }
func TagsList(m *ice.Message, cmds ...string) { func TagsList(m *ice.Message, cmds ...string) {
if len(cmds) == 0 { 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) {
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) {
if strings.HasPrefix(l, "!_") { if strings.HasPrefix(l, "!_") {
continue continue
} }

View File

@ -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 { func (c *Context) _action(m *Message, cmd *Command, key string, sub string, h *Action, arg ...string) *Message {
if h.Hand == nil { if h.Hand == nil {
m.Cmdy(kit.Split(h.Name), arg) return m.Cmdy(kit.Split(kit.Select(sub, h.Name)), arg)
return m
} }
if m._key, m._cmd, m._sub = key, cmd, sub; len(h.List) > 0 && sub != SEARCH { if m._key, m._cmd, m._sub = key, cmd, sub; len(h.List) > 0 && sub != SEARCH {
order := false order := false