forked from x/icebergs
opt some
This commit is contained in:
parent
83136bc19f
commit
d93e5b56ad
@ -116,12 +116,25 @@ func CmdAction(args ...ice.Any) ice.Actions {
|
||||
}
|
||||
}},
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 3 && arg[1] == ACTION && arg[2] == CONFIG && arg[3] == "reset" {
|
||||
m.Cmd(CONFIG, "reset", arg[0])
|
||||
return
|
||||
}
|
||||
if len(arg) > 3 && arg[1] == ACTION && arg[2] == CONFIG && arg[3] == "select" {
|
||||
m.Cmdy(CONFIG, arg[0])
|
||||
if len(arg) > 3 && arg[1] == ACTION && arg[2] == CONFIG {
|
||||
switch arg[3] {
|
||||
case "select":
|
||||
m.Cmdy(CONFIG, arg[0])
|
||||
case "reset":
|
||||
m.Cmd(CONFIG, "reset", arg[0])
|
||||
case "help":
|
||||
if file := strings.ReplaceAll(GetCmdFile(m, arg[0]), ".go", ".shy"); nfs.ExistsFile(m, file) {
|
||||
m.ProcessStory("web.wiki.word", file)
|
||||
}
|
||||
case "script":
|
||||
if file := strings.ReplaceAll(GetCmdFile(m, arg[0]), ".go", ".js"); nfs.ExistsFile(m, file) {
|
||||
m.ProcessStory("web.code.inner", file)
|
||||
}
|
||||
case "source":
|
||||
if file := GetCmdFile(m, arg[0]); nfs.ExistsFile(m, file) {
|
||||
m.ProcessStory("web.code.inner", file)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if !PodCmd(m, arg) && aaa.Right(m, arg) {
|
||||
@ -173,6 +186,14 @@ func AddFileCmd(dir, key string) {
|
||||
ice.Info.File[FileCmd(dir)] = key
|
||||
}
|
||||
func GetFileCmd(dir string) string {
|
||||
if strings.HasPrefix(dir, "usr/") {
|
||||
p := ice.Pulse.Cmdx("cli.system", "git", "config", "remote.origin.url", kit.Dict("cmd_dir", path.Dir(dir)))
|
||||
p = strings.Replace(strings.TrimSpace(p), "https://", "/require/", 1)
|
||||
dir = path.Join(p, strings.Join(strings.Split(dir, "/")[2:], "/"))
|
||||
}
|
||||
if strings.HasPrefix(dir, ".ish/pluged/") {
|
||||
dir = strings.Replace(dir, ".ish/pluged/", "/require/", 1)
|
||||
}
|
||||
if strings.HasPrefix(dir, "require/") {
|
||||
dir = "/" + dir
|
||||
}
|
||||
@ -192,3 +213,17 @@ func GetFileCmd(dir string) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
func GetCmdFile(m *ice.Message, cmds string) (file string) {
|
||||
m.Search(cmds, func(key string, cmd *ice.Command) {
|
||||
if cmd.RawHand == nil {
|
||||
file = kit.Split(kit.FileLine(cmd.Hand, 100), ":")[0]
|
||||
} else {
|
||||
for k, v := range ice.Info.File {
|
||||
if v == cmds {
|
||||
file = strings.Replace(k, "/require/", ".ish/pluged/", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ func (f *Frame) Close(m *ice.Message, arg ...string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
const DEBUG = "debug"
|
||||
const GDB = "gdb"
|
||||
|
||||
var Index = &ice.Context{Name: GDB, Help: "事件模块", Commands: ice.Commands{
|
||||
|
@ -31,7 +31,11 @@ func _list_insert(m *ice.Message, prefix, chain string, arg ...string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
|
||||
m.Logs(INSERT, KEY, path.Join(prefix, chain), arg[0], arg[1])
|
||||
m.Echo("%d", Grow(m, prefix, chain, kit.Dict(arg)))
|
||||
if m.Optionv(TARGET) != nil && m.Option(TARGET) != "" {
|
||||
m.Echo("%d", Grow(m, prefix, chain, kit.Dict(arg, TARGET, m.Optionv(TARGET))))
|
||||
} else {
|
||||
m.Echo("%d", Grow(m, prefix, chain, kit.Dict(arg)))
|
||||
}
|
||||
}
|
||||
func _list_modify(m *ice.Message, prefix, chain string, field, value string, arg ...string) {
|
||||
defer Lock(m, prefix, chain)()
|
||||
@ -262,7 +266,6 @@ func Grows(m *ice.Message, prefix string, chain Any, match string, value string,
|
||||
m.Option(CACHE_OFFEND, -begin-limit)
|
||||
}
|
||||
}
|
||||
|
||||
return miss.Grows(path.Join(prefix, kit.Keys(chain)), cache,
|
||||
kit.Int(kit.Select("0", strings.TrimPrefix(m.Option(CACHE_OFFEND), "-"))),
|
||||
kit.Int(kit.Select("10", m.Option(CACHE_LIMIT))),
|
||||
|
@ -56,16 +56,18 @@ func init() {
|
||||
m.Cmd(cmd, mdb.CREATE, k, m.PrefixKey())
|
||||
}
|
||||
}
|
||||
LoadPlug(m, C)
|
||||
LoadPlug(m, H, C)
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(cli.CMD_DIR, arg[2])
|
||||
name := strings.TrimSuffix(arg[1], path.Ext(arg[1])) + ".bin"
|
||||
if msg := m.Cmd(cli.SYSTEM, "gcc", arg[1], "-o", name); !cli.IsSuccess(msg) {
|
||||
if msg := m.Cmd(cli.SYSTEM, "gcc", arg[1], "-o", name, kit.Dict(cli.CMD_DIR, arg[2])); !cli.IsSuccess(msg) {
|
||||
m.Copy(msg)
|
||||
return
|
||||
}
|
||||
m.Echo(m.Cmd(cli.SYSTEM, nfs.PWD+name).Append(cli.CMD_OUT))
|
||||
m.Echo(m.Cmd(cli.SYSTEM, path.Join(arg[2], name)).Append(cli.CMD_OUT))
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
TagsList(m, "ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||
}},
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] == mdb.FOREACH {
|
||||
@ -104,6 +106,7 @@ func init() {
|
||||
}, PlugAction())},
|
||||
}, Configs: ice.Configs{
|
||||
C: {Name: C, Help: "系统", Value: kit.Data(PLUG, kit.Dict(
|
||||
mdb.RENDER, kit.Dict(),
|
||||
SPLIT, kit.Dict("space", " ", "operator", "{[(.,:;!|<>)]}"),
|
||||
PREFIX, kit.Dict("//", COMMENT, "/* ", COMMENT, "* ", COMMENT), PREPARE, kit.Dict(
|
||||
KEYWORD, kit.Simple(
|
||||
@ -169,3 +172,21 @@ func init() {
|
||||
))},
|
||||
}}, nil)
|
||||
}
|
||||
|
||||
func TagsList(m *ice.Message, cmds ...string) {
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, cmds), ice.NL) {
|
||||
if strings.HasPrefix(l, "!_") {
|
||||
continue
|
||||
}
|
||||
ls := strings.Split(l, ice.TB)
|
||||
if len(ls) < 2 {
|
||||
continue
|
||||
}
|
||||
switch ls[3] {
|
||||
case "w":
|
||||
continue
|
||||
}
|
||||
m.PushRecord(kit.Dict(mdb.TYPE, ls[3], mdb.NAME, ls[0], nfs.LINE, strings.TrimSuffix(ls[2], ";\"")))
|
||||
}
|
||||
m.Sort(nfs.LINE).StatusTimeCount()
|
||||
}
|
||||
|
@ -162,8 +162,10 @@ func _go_show(m *ice.Message, arg ...string) {
|
||||
} else {
|
||||
if key := ctx.GetFileCmd(path.Join(arg[2], arg[1])); key != "" {
|
||||
ctx.ProcessCommand(m, key, kit.Simple())
|
||||
} else if p := strings.ReplaceAll(path.Join(arg[2], arg[1]), ".go", ".shy"); nfs.ExistsFile(m, p) {
|
||||
ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(p))
|
||||
} else {
|
||||
ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(strings.ReplaceAll(path.Join(arg[2], arg[1]), ".go", ".shy")))
|
||||
TagsList(m, "gotags", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,6 +281,7 @@ func init() {
|
||||
), KEYWORD, kit.Dict(),
|
||||
))},
|
||||
GO: {Name: GO, Help: "后端", Value: kit.Data(PLUG, kit.Dict(
|
||||
mdb.RENDER, kit.Dict(),
|
||||
SPLIT, kit.Dict("space", "\t ", "operator", "{[(&.,:;!|<>)]}"),
|
||||
PREFIX, kit.Dict("// ", COMMENT, "/*", COMMENT, "* ", COMMENT), PREPARE, kit.Dict(
|
||||
KEYWORD, kit.Simple(
|
||||
|
@ -1,6 +1,7 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -58,6 +59,32 @@ func _inner_make(m *ice.Message, msg *ice.Message) {
|
||||
}
|
||||
m.StatusTime()
|
||||
}
|
||||
func _inner_tags(m *ice.Message, path string, value string) {
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, "grep", "^"+value+"\\>", "tags", kit.Dict(cli.CMD_DIR, m.Option(nfs.PATH))), ice.NL) {
|
||||
ls := strings.SplitN(l, ice.TB, 2)
|
||||
if len(ls) < 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
ls = strings.SplitN(ls[1], ice.TB, 2)
|
||||
file := ls[0]
|
||||
ls = strings.SplitN(ls[1], ";\"", 2)
|
||||
text := strings.TrimSuffix(strings.TrimPrefix(ls[0], "/^"), "$/")
|
||||
line := kit.Int(text)
|
||||
|
||||
f, e := nfs.OpenFile(m, kit.Path(path, file))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
|
||||
bio := bufio.NewScanner(f)
|
||||
for i := 1; bio.Scan(); i++ {
|
||||
if i == line || bio.Text() == text {
|
||||
m.PushRecord(kit.Dict(nfs.PATH, path, nfs.FILE, strings.TrimPrefix(file, nfs.PWD), nfs.LINE, kit.Format(i)))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func LoadPlug(m *ice.Message, language ...string) {
|
||||
for _, language := range language {
|
||||
@ -164,7 +191,9 @@ func init() {
|
||||
}
|
||||
}},
|
||||
|
||||
nfs.TAGS: {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) {}},
|
||||
nfs.TAGS: {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) {
|
||||
_inner_tags(m, m.Option(nfs.PATH), arg[0])
|
||||
}},
|
||||
nfs.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.GREP, m.Option(nfs.PATH), arg[0])
|
||||
m.StatusTimeCount(mdb.INDEX, 0)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -203,6 +204,17 @@ func init() {
|
||||
cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
|
||||
_install_stop(m, arg...)
|
||||
}},
|
||||
gdb.DEBUG: {Name: "debug", Help: "调试", Hand: func(m *ice.Message, arg ...string) {
|
||||
if cmd := "web.code.xterm"; len(arg) > 0 && arg[0] == ice.RUN {
|
||||
if len(arg) > 2 && arg[1] == ctx.ACTION && arg[2] == mdb.CREATE {
|
||||
arg = append(arg, mdb.TYPE, "gdb")
|
||||
}
|
||||
m.Cmdy(cmd, arg[1:])
|
||||
} else {
|
||||
m.Cmdy(ctx.COMMAND, cmd)
|
||||
m.ProcessField(m.ActionKey(), ice.RUN)
|
||||
}
|
||||
}},
|
||||
nfs.TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
_install_trash(m, arg...)
|
||||
}},
|
||||
|
@ -118,3 +118,14 @@ func init() {
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
||||
func ProcessXterm(m *ice.Message, bin string, arg ...string) {
|
||||
if cmd := "web.code.xterm"; len(arg) > 0 && arg[0] == ice.RUN {
|
||||
if len(arg) > 2 && arg[1] == ctx.ACTION && arg[2] == mdb.CREATE {
|
||||
arg = append(arg, mdb.TYPE, bin)
|
||||
}
|
||||
m.Cmdy(cmd, arg[1:])
|
||||
} else {
|
||||
m.Cmdy(ctx.COMMAND, cmd).ProcessField(m.ActionKey(), ice.RUN)
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ func init() {
|
||||
if strings.Contains(file, "var/") {
|
||||
return
|
||||
}
|
||||
if strings.Contains(file, "tags") {
|
||||
return
|
||||
}
|
||||
switch kit.Ext(file) {
|
||||
case "sum", "log":
|
||||
return
|
||||
|
@ -23,7 +23,10 @@ import (
|
||||
|
||||
func _server_rewrite(m *ice.Message, p string, r *http.Request) {
|
||||
if ua := r.Header.Get(web.UserAgent); strings.HasPrefix(ua, "Mozilla") {
|
||||
r.URL.Path = strings.Replace(r.URL.Path, "/x/", "/chat/pod/", 1)
|
||||
ls := kit.Split(r.URL.Path, "/")
|
||||
r.URL = kit.ParseURL(kit.MergeURL("/chat/cmd/web.code.inner", "path", "usr/"+ls[1]+"/", "file", path.Join(ls[2:]...)))
|
||||
|
||||
// r.URL.Path = strings.Replace(r.URL.Path, "/x/", "/chat/pod/", 1)
|
||||
m.Info("rewrite %v -> %v", p, r.URL.Path) // 访问服务
|
||||
|
||||
} else {
|
||||
|
@ -9,4 +9,4 @@ field web.code.node.compile
|
||||
shell `
|
||||
wget https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz
|
||||
tar xvf node-v16.15.1-linux-x64.tar.xz && cd node-v16.15.1-linux-x64
|
||||
`
|
||||
`Á
|
||||
|
Loading…
x
Reference in New Issue
Block a user