forked from x/icebergs
opt code
This commit is contained in:
parent
58c1c86504
commit
a91766548a
@ -104,9 +104,10 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
m.Push(CMD_OUT, out.String())
|
m.Push(CMD_OUT, out.String())
|
||||||
m.Push(CMD_ERR, err.String())
|
m.Push(CMD_ERR, err.String())
|
||||||
if m.Echo(strings.TrimRight(kit.Select(out.String(), err.String()), ice.NL)); IsSuccess(m) && out.String() == "" {
|
if IsSuccess(m) && err.String() == "" {
|
||||||
m.SetAppend()
|
m.SetAppend()
|
||||||
}
|
}
|
||||||
|
m.Echo(strings.TrimRight(out.String(), ice.NL))
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ const (
|
|||||||
DIR_REG = "dir_reg"
|
DIR_REG = "dir_reg"
|
||||||
|
|
||||||
DIR_DEF_FIELDS = "time,path,size,action"
|
DIR_DEF_FIELDS = "time,path,size,action"
|
||||||
DIR_WEB_FIELDS = "time,size,path,action,link"
|
DIR_WEB_FIELDS = "time,size,path,link,action"
|
||||||
DIR_CLI_FIELDS = "path,size,time"
|
DIR_CLI_FIELDS = "path,size,time"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
|
@ -14,25 +14,24 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
KEYBOARD: {Name: "keyboard hash@keyboard auto", Help: "键盘", Actions: ice.MergeActions(ice.Actions{
|
KEYBOARD: {Name: "keyboard hash@keyboard auto", Help: "键盘", Actions: ice.MergeActions(ice.Actions{
|
||||||
"_refresh": {Name: "refresh", Help: "刷新", Hand: func(m *ice.Message, arg ...string) {
|
"_refresh": {Name: "refresh", Help: "刷新", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(web.SPACE, m.Option("space"), "refresh")
|
m.Cmd(web.SPACE, m.Option(web.SPACE), "refresh")
|
||||||
}},
|
|
||||||
"inputs": {Name: "refresh", Help: "刷新", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
}},
|
}},
|
||||||
|
"inputs": {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {}},
|
||||||
"input": {Name: "input", Help: "刷新", Hand: func(m *ice.Message, arg ...string) {
|
"input": {Name: "input", Help: "刷新", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(web.SPACE, m.Option("space"), "input", arg)
|
m.Cmd(web.SPACE, m.Option(web.SPACE), "input", arg)
|
||||||
ctx.ProcessHold(m)
|
ctx.ProcessHold(m)
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, "", mdb.FIELD, "time,hash,space,index,input")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, "", mdb.FIELD, "time,hash,space,index,input")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
||||||
m.Cmd(web.SPACE, m.Option("space"), arg)
|
m.Cmd(web.SPACE, m.Option(web.SPACE), arg)
|
||||||
ctx.ProcessHold(m)
|
ctx.ProcessHold(m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mdb.HashSelect(m, arg...)
|
|
||||||
if len(arg) > 0 && arg[0] != "" {
|
if mdb.HashSelect(m, arg...); len(arg) > 0 && arg[0] != "" {
|
||||||
msg := m.Cmd(ctx.COMMAND, m.Append("index"))
|
msg := m.Cmd(ctx.COMMAND, m.Append(ctx.INDEX))
|
||||||
meta := kit.UnMarshal(msg.Append("meta"))
|
meta := kit.UnMarshal(msg.Append(mdb.META))
|
||||||
list := kit.UnMarshal(msg.Append("list"))
|
list := kit.UnMarshal(msg.Append(mdb.LIST))
|
||||||
keys := []string{}
|
keys := []string{}
|
||||||
kit.Fetch(list, func(index int, value ice.Any) {
|
kit.Fetch(list, func(index int, value ice.Any) {
|
||||||
if kit.Format(kit.Value(value, mdb.TYPE)) == "button" {
|
if kit.Format(kit.Value(value, mdb.TYPE)) == "button" {
|
||||||
@ -47,7 +46,7 @@ func init() {
|
|||||||
keys = append(keys, key)
|
keys = append(keys, key)
|
||||||
})
|
})
|
||||||
m.PushAction(kit.Join(keys))
|
m.PushAction(kit.Join(keys))
|
||||||
m.Option("meta", kit.Format(meta))
|
m.Option(mdb.META, kit.Format(meta))
|
||||||
ctx.DisplayLocal(m, "")
|
ctx.DisplayLocal(m, "")
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
215
core/code/c.go
215
core/code/c.go
@ -11,198 +11,51 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _c_tags(m *ice.Message, key string) {
|
func _c_show(m *ice.Message, arg ...string) {
|
||||||
if !nfs.ExistsFile(m, path.Join(m.Option(cli.CMD_DIR), TAGS)) {
|
TagsList(m, "ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||||
m.Cmd(cli.SYSTEM, "ctags", "-R", "-f", TAGS, nfs.PWD)
|
|
||||||
}
|
|
||||||
_go_tags(m, key)
|
|
||||||
}
|
}
|
||||||
func _c_help(m *ice.Message, section, key string) string {
|
func _c_exec(m *ice.Message, arg ...string) {
|
||||||
p := m.Cmd(cli.SYSTEM, MAN, section, key).Append(cli.CMD_OUT)
|
name := strings.TrimSuffix(arg[1], path.Ext(arg[1])) + ".bin"
|
||||||
if p == "" {
|
if msg := m.Cmd(cli.SYSTEM, "gcc", arg[1], "-o", name, kit.Dict(cli.CMD_DIR, arg[2])); !cli.IsSuccess(msg) {
|
||||||
return ""
|
_vimer_make(m, arg[2], msg)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if m.Cmdy(cli.SYSTEM, path.Join(arg[2], name)); m.Append(cli.CMD_ERR) == "" {
|
||||||
p = strings.Replace(p, "_\x08", "", -1)
|
m.Result(m.Append(cli.CMD_OUT))
|
||||||
res := make([]byte, 0, len(p))
|
m.SetAppend()
|
||||||
for i := 0; i < len(p); i++ {
|
}
|
||||||
switch p[i] {
|
m.StatusTime()
|
||||||
case '\x08':
|
}
|
||||||
i++
|
func _c_tags(m *ice.Message, man string, cmd ...string) {
|
||||||
default:
|
if !nfs.ExistsFile(m, path.Join(m.Option(nfs.PATH), nfs.TAGS)) {
|
||||||
res = append(res, p[i])
|
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))
|
||||||
|
m.Push(nfs.LINE, "1")
|
||||||
}
|
}
|
||||||
return string(res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const H = "h"
|
||||||
H = "h"
|
|
||||||
CC = "cc"
|
|
||||||
MAN = "man"
|
|
||||||
MAN1 = "man1"
|
|
||||||
MAN2 = "man2"
|
|
||||||
MAN3 = "man3"
|
|
||||||
MAN8 = "man8"
|
|
||||||
)
|
|
||||||
const C = "c"
|
const C = "c"
|
||||||
|
const MAN = "man"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Register(&ice.Context{Name: C, Help: "系统", Commands: ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
C: {Name: C, Help: "系统", Actions: ice.MergeActions(ice.Actions{
|
C: {Name: "c path auto", Help: "系统", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }},
|
||||||
for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN, NAVIGATE} {
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _c_exec(m, arg...) }},
|
||||||
for _, k := range []string{H, C, CC} {
|
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
||||||
m.Cmd(cmd, mdb.CREATE, k, m.PrefixKey())
|
}, PlugAction(), LangAction())},
|
||||||
}
|
|
||||||
}
|
|
||||||
LoadPlug(m, H, C)
|
|
||||||
}},
|
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
name := strings.TrimSuffix(arg[1], path.Ext(arg[1])) + ".bin"
|
|
||||||
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, 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 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Option(cli.CMD_DIR, kit.Select(ice.SRC, arg, 2))
|
|
||||||
m.Cmdy(mdb.SEARCH, MAN2, arg[1:])
|
|
||||||
m.Cmdy(mdb.SEARCH, MAN3, arg[1:])
|
|
||||||
_c_tags(m, kit.Select(cli.MAIN, arg, 1))
|
|
||||||
// _go_find(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
// _go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
}},
|
|
||||||
NAVIGATE: {Name: "navigate", Help: "跳转", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if !nfs.ExistsFile(m, path.Join(m.Option(nfs.PATH), nfs.TAGS)) {
|
|
||||||
m.Cmd(cli.SYSTEM, "ctags", "-a", "-R", nfs.PWD, kit.Dict(cli.CMD_DIR, m.Option(nfs.PATH)))
|
|
||||||
}
|
|
||||||
_inner_tags(m, m.Option(nfs.PATH), m.Option(mdb.NAME))
|
|
||||||
}},
|
|
||||||
}, PlugAction())},
|
|
||||||
MAN: {Name: MAN, Help: "手册", Actions: ice.MergeActions(ice.Actions{
|
MAN: {Name: MAN, Help: "手册", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
for _, cmd := range []string{mdb.SEARCH, mdb.RENDER, mdb.PLUGIN} {
|
|
||||||
for _, k := range []string{MAN1, MAN2, MAN3, MAN8} {
|
|
||||||
m.Cmd(cmd, mdb.CREATE, k, m.PrefixKey())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LoadPlug(m, MAN)
|
|
||||||
}},
|
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(_c_help(m, strings.TrimPrefix(arg[0], MAN), strings.TrimSuffix(arg[1], ice.PT+arg[0])))
|
if len(arg) == 1 {
|
||||||
}},
|
arg = append(arg, "")
|
||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if arg[0] == mdb.FOREACH {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, i := range []string{"1", "2", "3", "8"} {
|
|
||||||
if text := _c_help(m, i, kit.Select(cli.MAIN, arg, 1)); text != "" {
|
|
||||||
m.PushSearch(ice.CMD, MAN, nfs.FILE, kit.Keys(arg[1], MAN+i), nfs.LINE, 1, mdb.TEXT, text)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
key := kit.TrimExt(arg[1], arg[0])
|
||||||
|
m.Option(cli.CMD_ENV, "COLUMNS", kit.Int(kit.Select("1920", m.Option("width")))/12)
|
||||||
|
m.Cmdy(cli.SYSTEM, "sh", "-c", kit.Format("man %s %s|col -b", "", key))
|
||||||
}},
|
}},
|
||||||
}, PlugAction())},
|
}, 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(
|
|
||||||
"#include",
|
|
||||||
"#define",
|
|
||||||
"#ifndef",
|
|
||||||
"#ifdef",
|
|
||||||
"#if",
|
|
||||||
"#elif",
|
|
||||||
"#else",
|
|
||||||
"#endif",
|
|
||||||
|
|
||||||
"if",
|
|
||||||
"else",
|
|
||||||
"for",
|
|
||||||
"while",
|
|
||||||
"do",
|
|
||||||
"break",
|
|
||||||
"continue",
|
|
||||||
"switch",
|
|
||||||
"case",
|
|
||||||
"default",
|
|
||||||
"return",
|
|
||||||
"goto",
|
|
||||||
),
|
|
||||||
DATATYPE, kit.Simple(
|
|
||||||
"struct",
|
|
||||||
"union",
|
|
||||||
"enum",
|
|
||||||
|
|
||||||
"void",
|
|
||||||
"char",
|
|
||||||
"float",
|
|
||||||
"double",
|
|
||||||
"unsigned",
|
|
||||||
"signed",
|
|
||||||
"short",
|
|
||||||
"long",
|
|
||||||
"int",
|
|
||||||
|
|
||||||
"register",
|
|
||||||
"volatile",
|
|
||||||
"extern",
|
|
||||||
"static",
|
|
||||||
"const",
|
|
||||||
),
|
|
||||||
FUNCTION, kit.Simple(
|
|
||||||
"typedef",
|
|
||||||
"sizeof",
|
|
||||||
|
|
||||||
"assert",
|
|
||||||
"zmalloc",
|
|
||||||
"free",
|
|
||||||
),
|
|
||||||
CONSTANT, kit.Simple(
|
|
||||||
"NULL", "-1", "0", "1", "2",
|
|
||||||
),
|
|
||||||
), KEYWORD, kit.Dict(),
|
|
||||||
))},
|
|
||||||
MAN: {Name: MAN, Help: "手册", Value: kit.Data(PLUG, kit.Dict(
|
|
||||||
PREPARE, kit.Dict(
|
|
||||||
COMMENT, kit.Simple(
|
|
||||||
"NAME",
|
|
||||||
"LIBRARY",
|
|
||||||
"SYNOPSIS",
|
|
||||||
"DESCRIPTION",
|
|
||||||
"STANDARDS",
|
|
||||||
"SEE ALSO",
|
|
||||||
"HISTORY",
|
|
||||||
"BUGS",
|
|
||||||
),
|
|
||||||
), KEYWORD, kit.Dict(),
|
|
||||||
))},
|
|
||||||
}}, 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", "m":
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
m.PushRecord(kit.Dict(mdb.TYPE, ls[3], mdb.NAME, ls[0], nfs.LINE, strings.TrimSuffix(ls[2], ";\"")))
|
|
||||||
}
|
|
||||||
m.Sort(nfs.LINE).StatusTimeCount()
|
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,27 @@ package code
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
const CODE = "code"
|
const CODE = "code"
|
||||||
|
|
||||||
var Index = &ice.Context{Name: CODE, Help: "编程中心"}
|
var Index = &ice.Context{Name: CODE, Help: "编程中心", Commands: ice.Commands{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Conf(TEMPLATE, kit.Keym(mdb.SHORT), mdb.TYPE)
|
||||||
|
m.Conf(COMPLETE, kit.Keym(mdb.SHORT), mdb.TYPE)
|
||||||
|
m.Conf(NAVIGATE, kit.Keym(mdb.SHORT), mdb.TYPE)
|
||||||
|
ctx.Load(m)
|
||||||
|
}},
|
||||||
|
}}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
web.Index.Register(Index, &web.Frame{},
|
web.Index.Register(Index, &web.Frame{},
|
||||||
INSTALL, WEBPACK, BINPACK, AUTOGEN, COMPILE, PUBLISH, UPGRADE,
|
INSTALL, WEBPACK, BINPACK, AUTOGEN, COMPILE, PUBLISH, UPGRADE,
|
||||||
XTERM, VIMER, INNER, FAVOR, BENCH, PPROF,
|
FAVOR, XTERM, INNER, VIMER, BENCH, PPROF,
|
||||||
C, SH, SHY, GO, JS,
|
C, SH, SHY, GO, JS,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
354
core/code/go.go
354
core/code/go.go
@ -1,12 +1,8 @@
|
|||||||
package code
|
package code
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
@ -16,170 +12,69 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _go_tags(m *ice.Message, key string) {
|
func _go_complete(m *ice.Message, arg ...string) {
|
||||||
if s, e := nfs.StatFile(m, path.Join(m.Option(cli.CMD_DIR), TAGS)); os.IsNotExist(e) || s.ModTime().Before(time.Now().Add(kit.Duration("-72h"))) {
|
if m.Option(mdb.TEXT) == "" {
|
||||||
m.Cmd(cli.SYSTEM, "gotags", "-R", "-f", TAGS, nfs.PWD)
|
m.Push(mdb.TEXT, "package", "import", "const", "type", "func", "var")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ls := strings.Split(key, ice.PT)
|
if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) {
|
||||||
key = ls[len(ls)-1]
|
key := kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0]
|
||||||
|
switch key {
|
||||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, nfs.GREP, "^"+key+"\\>", TAGS), ice.NL) {
|
case "m", "msg":
|
||||||
ls := strings.SplitN(l, ice.TB, 2)
|
key = "icebergs.Message"
|
||||||
if len(ls) < 2 {
|
case "kit":
|
||||||
continue
|
key = "shylinux.com/x/toolkits"
|
||||||
|
case "ice":
|
||||||
|
key = "shylinux.com/x/ice"
|
||||||
|
case "mdb", "cli", "nfs":
|
||||||
|
key = "shylinux.com/x/icebergs/base/" + key
|
||||||
}
|
}
|
||||||
|
|
||||||
ls = strings.SplitN(ls[1], ice.TB, 2)
|
msg := m.Cmd(cli.SYSTEM, GO, "doc", key)
|
||||||
file := ls[0]
|
for _, l := range strings.Split(kit.Select(msg.Result(), msg.Append(cli.CMD_OUT)), ice.NL) {
|
||||||
ls = strings.SplitN(ls[1], ";\"", 2)
|
ls := kit.Split(l, "\t *", "()")
|
||||||
text := strings.TrimSuffix(strings.TrimPrefix(ls[0], "/^"), "$/")
|
if len(ls) < 2 {
|
||||||
line := kit.Int(text)
|
continue
|
||||||
|
}
|
||||||
f, e := nfs.OpenFile(m, path.Join(m.Option(cli.CMD_DIR), file))
|
switch ls[0] {
|
||||||
m.Assert(e)
|
case "const", "type", "func", "var":
|
||||||
defer f.Close()
|
if ls[1] == "(" {
|
||||||
|
m.Push(mdb.NAME, ls[5])
|
||||||
bio := bufio.NewScanner(f)
|
} else {
|
||||||
for i := 1; bio.Scan(); i++ {
|
m.Push(mdb.NAME, ls[1])
|
||||||
if i == line || bio.Text() == text {
|
}
|
||||||
m.PushSearch(nfs.FILE, strings.TrimPrefix(file, nfs.PWD), nfs.LINE, kit.Format(i), mdb.TEXT, bio.Text())
|
m.Push(mdb.TEXT, l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return
|
||||||
}
|
|
||||||
func _go_help(m *ice.Message, key string) {
|
|
||||||
if p := m.Cmd(cli.SYSTEM, GO, "doc", key).Append(cli.CMD_OUT); strings.TrimSpace(p) != "" {
|
|
||||||
m.PushSearch(nfs.FILE, key+".godoc", nfs.LINE, 1, mdb.TEXT, p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func _go_find(m *ice.Message, key string, dir string) {
|
|
||||||
m.Cmd(nfs.FIND, dir, key, func(value ice.Maps) { m.PushSearch(nfs.LINE, 1, value) })
|
|
||||||
}
|
|
||||||
func _go_grep(m *ice.Message, key string, dir string) {
|
|
||||||
m.Cmd(nfs.GREP, dir, key, func(value ice.Maps) { m.PushSearch(value) })
|
|
||||||
}
|
|
||||||
|
|
||||||
var _cache_mods = ice.Messages{}
|
|
||||||
var _cache_lock = sync.Mutex{}
|
|
||||||
|
|
||||||
func _go_doc(m *ice.Message, mod string, pkg string) *ice.Message {
|
|
||||||
_cache_lock.Lock()
|
|
||||||
defer _cache_lock.Unlock()
|
|
||||||
|
|
||||||
key := kit.Keys(mod, pkg)
|
|
||||||
if msg, ok := _cache_mods[key]; ok && kit.Time(msg.Time("24h")) > kit.Time(m.Time()) {
|
|
||||||
return msg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if mod != "" {
|
m.Push(mdb.TEXT, "m", "msg", "arg", "mdb", "cli", "nfs", "ice", "kit")
|
||||||
m.Cmd(cli.SYSTEM, "go", "get", mod)
|
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])
|
||||||
}
|
}
|
||||||
// if msg := _vimer_go_complete(m.Spawn(), key); msg.Length() > 0 {
|
|
||||||
// _cache_mods[key] = msg
|
|
||||||
// return msg
|
|
||||||
// }
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func _go_exec(m *ice.Message, arg ...string) {
|
func _go_exec(m *ice.Message, arg ...string) {
|
||||||
if m.Option("some") == "run" {
|
args := []string{"./bin/ice.bin"}
|
||||||
args := []string{"./bin/ice.bin"}
|
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||||
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
args = append(args, cmd)
|
||||||
args = append(args, cmd)
|
|
||||||
}
|
|
||||||
m.Cmdy(cli.SYSTEM, args)
|
|
||||||
m.StatusTime("args", kit.Join(args, " "))
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if m.Option(mdb.TEXT) == "" {
|
if m.Cmdy(cli.SYSTEM, args); cli.IsSuccess(m) {
|
||||||
if m.Option(nfs.LINE) == "1" {
|
m.Result(m.Append(cli.CMD_ERR), m.Append(cli.CMD_OUT))
|
||||||
m.Push(mdb.NAME, "package")
|
m.SetAppend()
|
||||||
} else {
|
|
||||||
m.Push(mdb.NAME, "import")
|
|
||||||
m.Push(mdb.NAME, "const")
|
|
||||||
m.Push(mdb.NAME, "type")
|
|
||||||
m.Push(mdb.NAME, "func")
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.Option(mdb.NAME) == ice.PT {
|
|
||||||
switch m.Option(mdb.TYPE) {
|
|
||||||
case "msg", "m":
|
|
||||||
m.Copy(_go_doc(m, "shylinux.com/x/ice", "Message"))
|
|
||||||
m.Copy(_go_doc(m, "shylinux.com/x/icebergs", "Message"))
|
|
||||||
|
|
||||||
case "ice", "*ice":
|
|
||||||
m.Copy(_go_doc(m, "shylinux.com/x/ice", ""))
|
|
||||||
|
|
||||||
case "kit":
|
|
||||||
m.Copy(_go_doc(m, "shylinux.com/x/toolkits", ""))
|
|
||||||
|
|
||||||
default:
|
|
||||||
m.Copy(_go_doc(m, "", m.Option(mdb.TYPE)))
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
m.Push(mdb.NAME, "msg")
|
|
||||||
m.Push(mdb.NAME, "ice")
|
|
||||||
}
|
}
|
||||||
|
m.StatusTime(ctx.ARGS, kit.Join(args, ice.SP))
|
||||||
}
|
}
|
||||||
func _go_show(m *ice.Message, arg ...string) {
|
func _go_show(m *ice.Message, arg ...string) {
|
||||||
if arg[1] == "main.go" {
|
if key := ctx.GetFileCmd(path.Join(arg[2], arg[1])); key != "" {
|
||||||
const (
|
ctx.ProcessCommand(m, key, kit.Simple())
|
||||||
PACKAGE = "package"
|
} else if p := strings.ReplaceAll(path.Join(arg[2], arg[1]), ".go", ".shy"); arg[1] != "main.go" && nfs.ExistsFile(m, p) {
|
||||||
IMPORT = "import"
|
ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(p))
|
||||||
)
|
|
||||||
index := 0
|
|
||||||
push := func(repos string) {
|
|
||||||
index++
|
|
||||||
m.Push("index", index)
|
|
||||||
m.Push("repos", repos)
|
|
||||||
}
|
|
||||||
block := ""
|
|
||||||
m.Cmd(nfs.CAT, path.Join(arg[2], arg[1]), func(ls []string, line string) {
|
|
||||||
switch {
|
|
||||||
case strings.HasPrefix(line, IMPORT+" ("):
|
|
||||||
block = IMPORT
|
|
||||||
case strings.HasPrefix(line, ")"):
|
|
||||||
block = ""
|
|
||||||
case strings.HasPrefix(line, IMPORT):
|
|
||||||
if len(ls) == 2 {
|
|
||||||
push(ls[1])
|
|
||||||
} else if len(ls) == 3 {
|
|
||||||
push(ls[2])
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
if block == IMPORT {
|
|
||||||
if len(ls) == 0 {
|
|
||||||
push("")
|
|
||||||
} else if len(ls) == 1 {
|
|
||||||
push(ls[0])
|
|
||||||
} else if len(ls) == 2 {
|
|
||||||
push(ls[1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
if key := ctx.GetFileCmd(path.Join(arg[2], arg[1])); key != "" {
|
TagsList(m, "gotags", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||||
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 {
|
|
||||||
TagsList(m, "gotags", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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()
|
|
||||||
}
|
|
||||||
func _mod_show(m *ice.Message, file string) {
|
func _mod_show(m *ice.Message, file string) {
|
||||||
const (
|
const (
|
||||||
MODULE = "module"
|
MODULE = "module"
|
||||||
@ -222,149 +117,56 @@ func _mod_show(m *ice.Message, file string) {
|
|||||||
m.Push(VERSION, v)
|
m.Push(VERSION, v)
|
||||||
m.Push(REPLACE, kit.Select("", replace[k]))
|
m.Push(REPLACE, kit.Select("", replace[k]))
|
||||||
}
|
}
|
||||||
m.Sort(REPLACE)
|
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
TAGS = ".tags"
|
|
||||||
)
|
|
||||||
const GO = "go"
|
const GO = "go"
|
||||||
|
const GODOC = "godoc"
|
||||||
const MOD = "mod"
|
const MOD = "mod"
|
||||||
const SUM = "sum"
|
const SUM = "sum"
|
||||||
const GODOC = "godoc"
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Register(&ice.Context{Name: GO, Help: "后端", Commands: ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, GODOC, m.Prefix(GO))
|
|
||||||
m.Cmd(mdb.ENGINE, mdb.CREATE, GO, m.Prefix(GO))
|
|
||||||
|
|
||||||
m.Cmd(TEMPLATE, mdb.CREATE, GO, m.Prefix(GO))
|
|
||||||
m.Cmd(COMPLETE, mdb.CREATE, GO, m.Prefix(GO))
|
|
||||||
m.Cmd(NAVIGATE, mdb.CREATE, GO, m.Prefix(GO))
|
|
||||||
|
|
||||||
LoadPlug(m, GO, MOD, SUM)
|
|
||||||
for _, k := range []string{GO, MOD, SUM, GODOC} {
|
|
||||||
m.Cmd(mdb.RENDER, mdb.CREATE, k, m.Prefix(k))
|
|
||||||
m.Cmd(mdb.PLUGIN, mdb.CREATE, k, m.Prefix(k))
|
|
||||||
}
|
|
||||||
m.Go(func() {
|
|
||||||
m.Sleep300ms()
|
|
||||||
cli.IsAlpine(m, GO)
|
|
||||||
cli.IsCentos(m, GO)
|
|
||||||
cli.IsUbuntu(m, GO, "golang")
|
|
||||||
})
|
|
||||||
}},
|
|
||||||
GODOC: {Name: "godoc", Help: "文档", Actions: ice.MergeActions(ice.Actions{
|
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy(cli.SYSTEM, GO, "doc", strings.TrimSuffix(arg[1], ice.PT+arg[0]), kit.Dict(cli.CMD_DIR, arg[2])).SetAppend()
|
|
||||||
}},
|
|
||||||
}, 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])) }},
|
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }},
|
|
||||||
}, 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])) }},
|
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
|
|
||||||
}, PlugAction())},
|
|
||||||
GO: {Name: "go", Help: "后端", Actions: ice.MergeActions(ice.Actions{
|
GO: {Name: "go", Help: "后端", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] == GO {
|
m.Cmd(NAVIGATE, mdb.CREATE, GODOC, m.PrefixKey())
|
||||||
_go_tags(m, kit.Select(cli.MAIN, arg, 1))
|
|
||||||
_go_help(m, kit.Select(cli.MAIN, arg, 1))
|
|
||||||
// _go_find(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
// _go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_exec(m, arg...) }},
|
|
||||||
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...) }},
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_exec(m, arg...) }},
|
||||||
if kit.Ext(m.Option(mdb.FILE)) != m.CommandKey() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == mdb.FOREACH {
|
if len(arg) > 0 && arg[0] == mdb.FOREACH {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
_go_complete(m, arg...)
|
||||||
if m.Option("text") == "" {
|
|
||||||
m.Push(mdb.TEXT, kit.List("package", "import", "const", "type", "func", "var"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if strings.HasSuffix(m.Option("text"), ".") {
|
|
||||||
key := kit.Slice(kit.Split(m.Option("text"), "\t ."), -1)[0]
|
|
||||||
switch key {
|
|
||||||
case "m", "msg":
|
|
||||||
key = "icebergs.Message"
|
|
||||||
case "kit":
|
|
||||||
key = "toolkits"
|
|
||||||
case "ice":
|
|
||||||
key = "icebergs"
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, l := range strings.Split(m.Cmdx("cli.system", "go", "doc", key), ice.NL) {
|
|
||||||
ls := kit.Split(l)
|
|
||||||
if len(ls) < 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
switch ls[0] {
|
|
||||||
case "const", "var", "func":
|
|
||||||
m.Push(mdb.NAME, ls[1])
|
|
||||||
m.Push(mdb.TEXT, l)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
m.Push(mdb.TEXT, "m")
|
|
||||||
m.Push(mdb.TEXT, "msg")
|
|
||||||
m.Push(mdb.TEXT, "ice")
|
|
||||||
m.Push(mdb.TEXT, "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])
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {
|
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option("text", kit.Slice(kit.Split(m.Option("text"), "."), -1)[0])
|
_c_tags(m, GODOC, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD)
|
||||||
_inner_tags(m, "", m.Option("text"))
|
}},
|
||||||
|
}, 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], "m.", "shylinux.com/x/ice.Message.", 1)
|
||||||
|
arg[1] = strings.Replace(arg[1], "kit.", "shylinux.com/x/toolkits.", 1)
|
||||||
|
m.Cmdy(cli.SYSTEM, GO, "doc", strings.TrimSuffix(arg[1], ".godoc"), kit.Dict(cli.CMD_DIR, arg[2]))
|
||||||
|
if m.Append(cli.CMD_ERR) != "" {
|
||||||
|
m.Result(m.Append(cli.CMD_OUT))
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
}, PlugAction())},
|
}, PlugAction())},
|
||||||
}, Configs: ice.Configs{
|
MOD: {Name: "mod", Help: "模块", Actions: ice.MergeActions(ice.Actions{
|
||||||
MOD: {Name: MOD, Help: "模块", Value: kit.Data(PLUG, kit.Dict(
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
|
||||||
PREFIX, kit.Dict("//", COMMENT), PREPARE, kit.Dict(
|
}, PlugAction())},
|
||||||
KEYWORD, kit.Simple("go", "module", "require", "replace", "=>"),
|
SUM: {Name: "sum", Help: "版本", Actions: ice.MergeActions(ice.Actions{
|
||||||
), KEYWORD, kit.Dict(),
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }},
|
||||||
))},
|
}, PlugAction())},
|
||||||
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(
|
|
||||||
"package", "import", "type", "struct", "interface", "const", "var", "func",
|
|
||||||
"if", "else", "for", "range", "break", "continue",
|
|
||||||
"switch", "case", "default", "fallthrough",
|
|
||||||
"go", "select", "defer", "return",
|
|
||||||
),
|
|
||||||
CONSTANT, kit.Simple(
|
|
||||||
"false", "true", "nil", "iota", "-1", "0", "1", "2", "3",
|
|
||||||
),
|
|
||||||
DATATYPE, kit.Simple(
|
|
||||||
"int", "int8", "int16", "int32", "int64",
|
|
||||||
"uint", "uint8", "uint16", "uint32", "uint64",
|
|
||||||
"float32", "float64", "complex64", "complex128",
|
|
||||||
"rune", "string", "byte", "uintptr",
|
|
||||||
"bool", "error", "chan", "map",
|
|
||||||
),
|
|
||||||
FUNCTION, kit.Simple(
|
|
||||||
"msg", "m",
|
|
||||||
"init", "main", "print", "println", "panic", "recover",
|
|
||||||
"new", "make", "len", "cap", "copy", "append", "delete", "close",
|
|
||||||
"complex", "real", "imag",
|
|
||||||
),
|
|
||||||
), KEYWORD, kit.Dict(),
|
|
||||||
))},
|
|
||||||
}}, nil)
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/aaa"
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
@ -18,7 +19,9 @@ func _inner_list(m *ice.Message, ext, file, dir string) {
|
|||||||
if aaa.Right(m, dir, file) {
|
if aaa.Right(m, dir, file) {
|
||||||
if nfs.IsSourceFile(m, ext) {
|
if nfs.IsSourceFile(m, ext) {
|
||||||
m.Cmdy(nfs.CAT, path.Join(dir, file))
|
m.Cmdy(nfs.CAT, path.Join(dir, file))
|
||||||
} else {
|
}
|
||||||
|
if m.IsErrNotFound() {
|
||||||
|
m.SetResult()
|
||||||
_inner_show(m, ext, file, dir)
|
_inner_show(m, ext, file, dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,23 +36,6 @@ func _inner_exec(m *ice.Message, ext, file, dir string) {
|
|||||||
m.Cmdy(mdb.ENGINE, ext, file, dir)
|
m.Cmdy(mdb.ENGINE, ext, file, dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _inner_make(m *ice.Message, dir string, msg *ice.Message) {
|
|
||||||
for _, line := range strings.Split(msg.Append(cli.CMD_ERR), ice.NL) {
|
|
||||||
if strings.Contains(line, ice.DF) {
|
|
||||||
if ls := strings.SplitN(line, ice.DF, 4); len(ls) > 3 {
|
|
||||||
m.Push(nfs.PATH, dir)
|
|
||||||
m.Push(nfs.FILE, strings.TrimPrefix(ls[0], dir))
|
|
||||||
m.Push(nfs.LINE, ls[1])
|
|
||||||
m.Push(mdb.TEXT, ls[3])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if m.Length() == 0 {
|
|
||||||
m.Echo(msg.Append(cli.CMD_OUT))
|
|
||||||
m.Echo(msg.Append(cli.CMD_ERR))
|
|
||||||
}
|
|
||||||
m.StatusTime()
|
|
||||||
}
|
|
||||||
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, nfs.GREP, "^"+value+"\\>", nfs.TAGS, kit.Dict(cli.CMD_DIR, dir)), ice.NL) {
|
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, nfs.GREP, "^"+value+"\\>", nfs.TAGS, kit.Dict(cli.CMD_DIR, dir)), ice.NL) {
|
||||||
ls := strings.SplitN(l, ice.TB, 3)
|
ls := strings.SplitN(l, ice.TB, 3)
|
||||||
@ -87,11 +73,11 @@ const (
|
|||||||
FUNCTION = "function"
|
FUNCTION = "function"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
SPLIT = "split"
|
SPLIT = lex.SPLIT
|
||||||
SPACE = "space"
|
SPACE = "space"
|
||||||
OPERATE = "operate"
|
OPERATE = "operate"
|
||||||
PREFIX = "prefix"
|
PREFIX = lex.PREFIX
|
||||||
SUFFIX = "suffix"
|
SUFFIX = lex.SUFFIX
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
PLUG = "plug"
|
PLUG = "plug"
|
||||||
@ -130,11 +116,6 @@ func init() {
|
|||||||
mdb.ENGINE: {Name: "engine", Help: "引擎", Hand: func(m *ice.Message, arg ...string) {
|
mdb.ENGINE: {Name: "engine", Help: "引擎", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_inner_exec(m, arg[0], arg[1], arg[2])
|
_inner_exec(m, arg[0], arg[1], arg[2])
|
||||||
}},
|
}},
|
||||||
mdb.SEARCH: {Name: "search", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if _inner_tags(m, m.Option(nfs.PATH), arg[1]); m.Length() == 0 {
|
|
||||||
_inner_tags(m, "", arg[1])
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
|
|
||||||
nfs.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
nfs.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.GREP, m.Option(nfs.PATH), arg[0]).StatusTimeCount(mdb.INDEX, 0)
|
m.Cmdy(nfs.GREP, m.Option(nfs.PATH), arg[0]).StatusTimeCount(mdb.INDEX, 0)
|
||||||
@ -144,13 +125,6 @@ func init() {
|
|||||||
_inner_tags(m, "", arg[0])
|
_inner_tags(m, "", arg[0])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
cli.MAKE: {Name: "make", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_inner_make(m, m.Option(nfs.PATH), m.Cmd(cli.SYSTEM, cli.MAKE, arg))
|
|
||||||
}},
|
|
||||||
|
|
||||||
"listTags": {Name: "listTags", Help: "索引", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy("web.code.vim.tags", "listTags", arg)
|
|
||||||
}},
|
|
||||||
NAVIGATE: {Name: "navigate", Help: "跳转", Hand: func(m *ice.Message, arg ...string) {
|
NAVIGATE: {Name: "navigate", Help: "跳转", 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))
|
||||||
}},
|
}},
|
||||||
@ -169,7 +143,6 @@ func init() {
|
|||||||
|
|
||||||
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])
|
||||||
|
|
||||||
m.Option("tabs", m.Config("show.tabs"))
|
m.Option("tabs", m.Config("show.tabs"))
|
||||||
m.Option("plug", m.Config("show.plug"))
|
m.Option("plug", m.Config("show.plug"))
|
||||||
m.Option("exts", m.Config("show.exts"))
|
m.Option("exts", m.Config("show.exts"))
|
||||||
@ -179,18 +152,51 @@ 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) {
|
||||||
|
for _, cmd := range []string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE} {
|
||||||
|
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)) }},
|
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Config(PLUG)) }},
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }},
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }},
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }},
|
||||||
|
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
|
||||||
|
}
|
||||||
|
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, language ...string) {
|
func LoadPlug(m *ice.Message, language ...string) {
|
||||||
for _, language := range language {
|
for _, language := range language {
|
||||||
m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, kit.Ext(language)), ice.TRUE)
|
m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, kit.Ext(language)), ice.TRUE)
|
||||||
m.Confm(language, kit.Keym(PLUG, PREPARE), func(key string, value interface{}) {
|
m.Confm(language, kit.Keym(PLUG, PREPARE), func(key string, value ice.Any) {
|
||||||
for _, v := range kit.Simple(value) {
|
for _, v := range kit.Simple(value) {
|
||||||
m.Conf(language, kit.Keym(PLUG, KEYWORD, v), key)
|
m.Conf(language, kit.Keym(PLUG, KEYWORD, v), key)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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) < 3 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch ls[3] {
|
||||||
|
case "w", "m":
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
m.PushRecord(kit.Dict(mdb.TYPE, ls[3], mdb.NAME, ls[0], nfs.LINE, strings.TrimSuffix(ls[2], ";\"")))
|
||||||
|
}
|
||||||
|
m.Sort(nfs.LINE).StatusTimeCount()
|
||||||
|
}
|
||||||
|
151
core/code/js.go
151
core/code/js.go
@ -10,7 +10,6 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,52 +35,36 @@ func _js_main_script(m *ice.Message, arg ...string) (res []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func _js_exec(m *ice.Message, arg ...string) {
|
func _js_show(m *ice.Message, arg ...string) {
|
||||||
if m.Option("some") == "run" {
|
key := ctx.GetFileCmd(kit.Replace(path.Join(arg[2], arg[1]), ".js", ".go"))
|
||||||
args := kit.Simple("node", "-e", kit.Join(_js_main_script(m, arg...), ice.NL))
|
if key == "" {
|
||||||
m.Cmdy(cli.SYSTEM, args)
|
for p, k := range ice.Info.File {
|
||||||
m.StatusTime("args", kit.Join([]string{"./bin/ice.bin", "web.code.js.js", "exec", path.Join(arg[2], arg[1])}, " "))
|
if strings.HasPrefix(p, path.Dir(path.Join(arg[2], arg[1]))) {
|
||||||
return
|
key = k
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Option(mdb.NAME) == ice.PT {
|
|
||||||
switch m.Option(mdb.TYPE) {
|
|
||||||
case "msg":
|
|
||||||
m.Cmdy("web.code.vim.tags", "msg").Cut("name,text")
|
|
||||||
case "can":
|
|
||||||
m.Cmdy("web.code.vim.tags").Cut(mdb.ZONE)
|
|
||||||
default:
|
|
||||||
m.Cmdy("web.code.vim.tags", strings.TrimPrefix(m.Option(mdb.TYPE), "can.")).Cut("name,text")
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
m.Push(mdb.NAME, "msg")
|
|
||||||
m.Push(mdb.NAME, "can")
|
|
||||||
}
|
}
|
||||||
|
m.Display(path.Join("/require", path.Join(arg[2], arg[1])))
|
||||||
|
ctx.ProcessCommand(m, kit.Select("can.code.inner._plugin", key), kit.Simple())
|
||||||
|
}
|
||||||
|
func _js_exec(m *ice.Message, arg ...string) {
|
||||||
|
args := kit.Simple("node", "-e", kit.Join(_js_main_script(m, arg...), ice.NL))
|
||||||
|
m.Cmdy(cli.SYSTEM, args)
|
||||||
|
m.StatusTime(ctx.ARGS, kit.Join([]string{"./bin/ice.bin", "web.code.js.js", "exec", path.Join(arg[2], arg[1])}, ice.SP))
|
||||||
}
|
}
|
||||||
|
|
||||||
const JS = "js"
|
const JS = "js"
|
||||||
const CSS = "css"
|
const CSS = "css"
|
||||||
const HTML = "html"
|
const HTML = "html"
|
||||||
const JSON = "json"
|
const JSON = "json"
|
||||||
const NODE = "node"
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Register(&ice.Context{Name: JS, Help: "前端", Commands: ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
JS: {Name: "js", Help: "前端", Actions: ice.MergeActions(ice.Actions{
|
JS: {Name: "js path auto", Help: "前端", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _js_show(m, arg...) }},
|
||||||
for _, cmd := range []string{
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _js_exec(m, arg...) }},
|
||||||
TEMPLATE, COMPLETE, NAVIGATE,
|
|
||||||
mdb.PLUGIN, mdb.RENDER, mdb.ENGINE, mdb.SEARCH,
|
|
||||||
} {
|
|
||||||
m.Cmd(cmd, mdb.CREATE, JSON, m.PrefixKey())
|
|
||||||
m.Cmd(cmd, mdb.CREATE, JS, m.PrefixKey())
|
|
||||||
}
|
|
||||||
LoadPlug(m, JS)
|
|
||||||
}},
|
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if kit.Ext(m.Option(mdb.FILE)) != m.CommandKey() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Echo(`
|
m.Echo(`
|
||||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) {
|
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) {
|
||||||
msg.Echo("hello world")
|
msg.Echo("hello world")
|
||||||
@ -94,92 +77,24 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) {
|
|||||||
switch m.Option(ctx.ACTION) {
|
switch m.Option(ctx.ACTION) {
|
||||||
case nfs.SCRIPT:
|
case nfs.SCRIPT:
|
||||||
m.Push(nfs.PATH, strings.ReplaceAll(arg[1], ice.PT+kit.Ext(arg[1]), ice.PT+JS))
|
m.Push(nfs.PATH, strings.ReplaceAll(arg[1], ice.PT+kit.Ext(arg[1]), ice.PT+JS))
|
||||||
m.Cmdy(nfs.DIR, nfs.PWD, kit.Dict(nfs.DIR_ROOT, "src/", nfs.DIR_REG, `.*.(sh|py|shy|js)`, nfs.DIR_DEEP, ice.TRUE), nfs.PATH)
|
m.Cmdy(nfs.DIR, nfs.PWD, kit.Dict(nfs.DIR_ROOT, "src/", nfs.DIR_REG, `.*\.(sh|shy|py|js)$`, nfs.DIR_DEEP, ice.TRUE), nfs.PATH)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Complete(m, m.Option("text"), kit.Dict(
|
if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) {
|
||||||
"", kit.List("function", "if"),
|
key := kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0]
|
||||||
"msg", kit.List("Push", "Echo"),
|
switch key {
|
||||||
))
|
case "msg":
|
||||||
}},
|
m.Cmdy("web.code.vim.tags", "msg").Cut("name,text")
|
||||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {
|
case "can":
|
||||||
}},
|
m.Cmdy("web.code.vim.tags").Cut(mdb.ZONE)
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
default:
|
||||||
key := ctx.GetFileCmd(kit.Replace(path.Join(arg[2], arg[1]), ".js", ".go"))
|
m.Cmdy("web.code.vim.tags", strings.TrimPrefix(m.Option(mdb.TYPE), "can.")).Cut("name,text")
|
||||||
if key == "" {
|
|
||||||
for p, k := range ice.Info.File {
|
|
||||||
if strings.HasPrefix(p, path.Dir(path.Join(arg[2], arg[1]))) {
|
|
||||||
key = k
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
m.Cmdy("web.code.vim.tags").Cut(mdb.ZONE)
|
||||||
}
|
}
|
||||||
m.Display(path.Join("/require", path.Join(arg[2], arg[1])))
|
|
||||||
ctx.ProcessCommand(m, kit.Select("can.code.inner._plugin", key), kit.Simple())
|
|
||||||
}},
|
}},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
}, PlugAction(), LangAction())},
|
||||||
_js_exec(m, arg...)
|
})
|
||||||
}},
|
|
||||||
"exec": {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Option("some", "run")
|
|
||||||
_js_exec(m, "", arg[0], "")
|
|
||||||
}},
|
|
||||||
|
|
||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if arg[0] == mdb.FOREACH {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_go_find(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
_go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
}},
|
|
||||||
}, PlugAction())},
|
|
||||||
NODE: {Name: "node auto download", Help: "前端", Actions: ice.Actions{
|
|
||||||
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy(INSTALL, m.Config(nfs.SOURCE))
|
|
||||||
}},
|
|
||||||
}},
|
|
||||||
}, Configs: ice.Configs{
|
|
||||||
NODE: {Name: NODE, Help: "前端", Value: kit.Data(
|
|
||||||
nfs.SOURCE, "https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz",
|
|
||||||
)},
|
|
||||||
JS: {Name: JS, Help: "js", Value: kit.Data(INSTALL, kit.List(kit.Dict(
|
|
||||||
cli.OSID, cli.ALPINE, ice.CMD, kit.List("apk", "add", "nodejs"),
|
|
||||||
)), PLUG, kit.Dict(PREFIX, kit.Dict("// ", COMMENT, "/* ", COMMENT, "* ", COMMENT), PREPARE, kit.Dict(
|
|
||||||
KEYWORD, kit.Simple(
|
|
||||||
"import", "from", "export",
|
|
||||||
|
|
||||||
"var", "new", "instanceof", "typeof", "let", "const",
|
|
||||||
"delete",
|
|
||||||
|
|
||||||
"if", "else", "for", "in", "do", "while", "break", "continue", "switch", "case", "default",
|
|
||||||
"try", "throw", "catch", "finally",
|
|
||||||
"return",
|
|
||||||
|
|
||||||
"can", "sub", "msg", "res",
|
|
||||||
|
|
||||||
"event", "target", "debugger", "alert",
|
|
||||||
"window", "screen", "console", "navigator",
|
|
||||||
"location", "history",
|
|
||||||
"document",
|
|
||||||
),
|
|
||||||
CONSTANT, kit.Simple(
|
|
||||||
"true", "false",
|
|
||||||
"-1", "0", "1", "2", "10",
|
|
||||||
"undefined", "null", "NaN",
|
|
||||||
),
|
|
||||||
FUNCTION, kit.Simple(
|
|
||||||
"function", "arguments", "this",
|
|
||||||
"shy", "Volcanos", "cb", "cbs",
|
|
||||||
|
|
||||||
"parseInt", "parseFloat",
|
|
||||||
"Number", "String", "Boolean",
|
|
||||||
"Object", "Array",
|
|
||||||
"RegExp", "XMLHttpRequest",
|
|
||||||
"Promise",
|
|
||||||
"Math", "Date", "JSON",
|
|
||||||
"setTimeout",
|
|
||||||
),
|
|
||||||
), KEYWORD, kit.Dict(),
|
|
||||||
))},
|
|
||||||
}}, nil)
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ func init() {
|
|||||||
PPROF: {Name: "pprof zone id auto", Help: "性能分析", Actions: ice.MergeActions(ice.Actions{
|
PPROF: {Name: "pprof zone id auto", Help: "性能分析", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
||||||
if p := r.URL.Path; strings.HasPrefix(p, "/debug") {
|
if p := r.URL.Path; strings.HasPrefix(p, "/debug/") {
|
||||||
r.URL.Path = strings.Replace(r.URL.Path, "/debug", "/code", -1)
|
r.URL.Path = strings.Replace(r.URL.Path, "/debug/", "/code/", -1)
|
||||||
m.Debug("rewrite %v -> %v", p, r.URL.Path)
|
m.Debug("rewrite %v -> %v", p, r.URL.Path)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -57,7 +57,7 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
web.SERVE: {Name: "serve", Help: "展示", Hand: func(m *ice.Message, arg ...string) {
|
web.SERVE: {Name: "serve", Help: "展示", Hand: func(m *ice.Message, arg ...string) {
|
||||||
u := web.OptionUserWeb(m)
|
u := web.OptionUserWeb(m)
|
||||||
p := u.Hostname() + ":" + m.Cmdx(tcp.PORT, aaa.RIGHT)
|
p := u.Hostname() + ice.DF + m.Cmdx(tcp.PORT, aaa.RIGHT)
|
||||||
m.Cmd(cli.DAEMON, m.Configv(PPROF), "-http="+p, m.Option(BINNARY), m.Option(nfs.FILE))
|
m.Cmd(cli.DAEMON, m.Configv(PPROF), "-http="+p, m.Option(BINNARY), m.Option(nfs.FILE))
|
||||||
m.Echo("http://%s/ui/top", p).ProcessInner()
|
m.Echo("http://%s/ui/top", p).ProcessInner()
|
||||||
}},
|
}},
|
||||||
@ -67,15 +67,14 @@ func init() {
|
|||||||
m.EchoAnchor(web.MergeLink(m, "/code/pprof/"))
|
m.EchoAnchor(web.MergeLink(m, "/code/pprof/"))
|
||||||
m.PushAction(ice.RUN, mdb.REMOVE)
|
m.PushAction(ice.RUN, mdb.REMOVE)
|
||||||
m.Action(mdb.CREATE)
|
m.Action(mdb.CREATE)
|
||||||
return
|
} else {
|
||||||
|
m.Tables(func(value ice.Maps) {
|
||||||
|
m.PushDownload(mdb.LINK, "pprof.pd.gz", value[nfs.FILE])
|
||||||
|
m.PushButton(web.SERVE)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Tables(func(value ice.Maps) {
|
|
||||||
m.PushDownload(mdb.LINK, "pprof.pd.gz", value[nfs.FILE])
|
|
||||||
m.PushButton(web.SERVE)
|
|
||||||
})
|
|
||||||
}},
|
}},
|
||||||
"/pprof/": {Name: "/pprof/", Help: "性能分析", Hand: func(m *ice.Message, arg ...string) {
|
web.PP(PPROF): {Name: "/pprof/", Help: "性能分析", Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer m.Render(ice.RENDER_VOID)
|
defer m.Render(ice.RENDER_VOID)
|
||||||
m.R.URL.Path = "/debug" + m.R.URL.Path
|
m.R.URL.Path = "/debug" + m.R.URL.Path
|
||||||
http.DefaultServeMux.ServeHTTP(m.W, m.R)
|
http.DefaultServeMux.ServeHTTP(m.W, m.R)
|
||||||
|
109
core/code/sh.go
109
core/code/sh.go
@ -11,7 +11,7 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _sh_main_script(m *ice.Message, arg ...string) (res []string) {
|
func _sh_exec(m *ice.Message, arg ...string) (res []string) {
|
||||||
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||||
res = append(res, kit.Format(`#! /bin/sh
|
res = append(res, kit.Format(`#! /bin/sh
|
||||||
export ctx_dev=%s; ctx_pod=%s ctx_temp=$(mktemp); curl -fsSL $ctx_dev -o $ctx_temp; source $ctx_temp &>/dev/null
|
export ctx_dev=%s; ctx_pod=%s ctx_temp=$(mktemp); curl -fsSL $ctx_dev -o $ctx_temp; source $ctx_temp &>/dev/null
|
||||||
@ -36,111 +36,18 @@ _action() {
|
|||||||
res = append(res, string(b))
|
res = append(res, string(b))
|
||||||
}
|
}
|
||||||
m.Cmdy(cli.SYSTEM, SH, "-c", kit.Join(res, ice.NL))
|
m.Cmdy(cli.SYSTEM, SH, "-c", kit.Join(res, ice.NL))
|
||||||
if m.StatusTime(); cli.IsSuccess(m) {
|
m.StatusTime()
|
||||||
m.SetAppend()
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func _sh_exec(m *ice.Message, arg ...string) {
|
|
||||||
if m.Option(mdb.TEXT) == "" {
|
|
||||||
// if _cache_bin != nil {
|
|
||||||
// m.Copy(_cache_bin)
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// _cache_bin = m
|
|
||||||
|
|
||||||
// m.Push(mdb.NAME, "_list")
|
|
||||||
// _vimer_list(m, "/bin")
|
|
||||||
// _vimer_list(m, "/sbin")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const SH = nfs.SH
|
const SH = nfs.SH
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Register(&ice.Context{Name: SH, Help: "命令", Commands: ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{
|
SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }},
|
||||||
for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} {
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _sh_exec(m, arg...) }},
|
||||||
m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey())
|
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
||||||
}
|
}, PlugAction(), LangAction())},
|
||||||
LoadPlug(m, m.CommandKey())
|
})
|
||||||
m.Cmd(TEMPLATE, mdb.CREATE, m.CommandKey(), m.PrefixKey())
|
|
||||||
}},
|
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if kit.Ext(m.Option(mdb.FILE)) != m.CommandKey() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Echo(`
|
|
||||||
_list
|
|
||||||
`)
|
|
||||||
}},
|
|
||||||
mdb.SEARCH: {Name: "search", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if arg[0] == mdb.FOREACH {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Option(cli.CMD_DIR, kit.Select(ice.SRC, arg, 2))
|
|
||||||
m.Cmdy(mdb.SEARCH, MAN1, arg[1:])
|
|
||||||
m.Cmdy(mdb.SEARCH, MAN8, arg[1:])
|
|
||||||
_go_find(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
_go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
}},
|
|
||||||
mdb.ENGINE: {Name: "engine", Help: "引擎", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_sh_exec(m, arg...)
|
|
||||||
}},
|
|
||||||
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_sh_main_script(m, arg...)
|
|
||||||
}},
|
|
||||||
}, PlugAction()), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if len(arg) > 0 && kit.Ext(arg[0]) == SH {
|
|
||||||
_sh_main_script(m, SH, arg[0], ice.SRC)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Option(nfs.DIR_ROOT, ice.SRC)
|
|
||||||
m.Option(nfs.DIR_DEEP, ice.TRUE)
|
|
||||||
m.Option(nfs.DIR_REG, ".*.(sh)$")
|
|
||||||
m.Cmdy(nfs.DIR, arg)
|
|
||||||
}},
|
|
||||||
}, Configs: ice.Configs{
|
|
||||||
SH: {Name: SH, Help: "命令", Value: kit.Data(PLUG, kit.Dict(
|
|
||||||
SPLIT, kit.Dict(OPERATE, "="),
|
|
||||||
PREFIX, kit.Dict("#", COMMENT), SUFFIX, kit.Dict(" {", COMMENT),
|
|
||||||
"regexp", kit.Dict(
|
|
||||||
"[A-Z0-9_]+", CONSTANT,
|
|
||||||
),
|
|
||||||
PREPARE, kit.Dict(
|
|
||||||
KEYWORD, kit.Simple(
|
|
||||||
"local", "export", "require", "source", "return", "exit",
|
|
||||||
|
|
||||||
"if", "then", "else", "elif", "fi",
|
|
||||||
"for", "while", "do", "done",
|
|
||||||
"esac", "case", "in",
|
|
||||||
|
|
||||||
"shift",
|
|
||||||
"read",
|
|
||||||
"kill",
|
|
||||||
"let",
|
|
||||||
"cd",
|
|
||||||
),
|
|
||||||
FUNCTION, kit.Simple(
|
|
||||||
"eval",
|
|
||||||
"test",
|
|
||||||
"echo",
|
|
||||||
"mkdir",
|
|
||||||
"cat",
|
|
||||||
"rm",
|
|
||||||
|
|
||||||
"env",
|
|
||||||
"xargs", "_list",
|
|
||||||
"date", "uptime", "uname", "whoami",
|
|
||||||
"find", "grep", "sed", "awk",
|
|
||||||
"pwd",
|
|
||||||
"ls",
|
|
||||||
"ps",
|
|
||||||
"go",
|
|
||||||
),
|
|
||||||
), KEYWORD, kit.Dict(),
|
|
||||||
))},
|
|
||||||
}}, nil)
|
|
||||||
}
|
}
|
||||||
|
@ -5,82 +5,31 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _shy_exec(m *ice.Message, arg ...string) {
|
|
||||||
switch left := kit.Select("", kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t \n`"), -1), 0); strings.TrimSpace(left) {
|
|
||||||
case cli.FG, cli.BG:
|
|
||||||
m.Push(mdb.NAME, cli.RED)
|
|
||||||
m.Push(mdb.NAME, cli.BLUE)
|
|
||||||
m.Push(mdb.NAME, cli.GREEN)
|
|
||||||
|
|
||||||
default:
|
|
||||||
switch kit.Select("", kit.Split(m.Option(mdb.TEXT)), 0) {
|
|
||||||
case "field":
|
|
||||||
m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, "", "", ice.OptionFields("index,name,text"))
|
|
||||||
|
|
||||||
case "chain":
|
|
||||||
m.Push(mdb.NAME, cli.FG)
|
|
||||||
m.Push(mdb.NAME, cli.BG)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const SHY = "shy"
|
const SHY = "shy"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Register(&ice.Context{Name: SHY, Help: "脚本", Commands: ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SHY: {Name: "shy path auto", Help: "脚本", Actions: ice.MergeActions(ice.Actions{
|
SHY: {Name: "shy path auto", Help: "脚本", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} {
|
|
||||||
m.Cmd(cmd, mdb.CREATE, SHY, m.PrefixKey())
|
|
||||||
}
|
|
||||||
LoadPlug(m, SHY)
|
|
||||||
m.Cmd(TEMPLATE, mdb.CREATE, m.CommandKey(), m.PrefixKey())
|
|
||||||
}},
|
|
||||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if kit.Ext(m.Option(mdb.FILE)) != m.CommandKey() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Echo(`
|
|
||||||
chapter "hi"
|
|
||||||
`)
|
|
||||||
}},
|
|
||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(path.Join(arg[2], arg[1])))
|
ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(path.Join(arg[2], arg[1])))
|
||||||
}},
|
}},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
_shy_exec(m, arg...)
|
m.Cmdy("source", path.Join(arg[2], arg[1]))
|
||||||
}},
|
}},
|
||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] == SHY {
|
m.Echo(`chapter "hi"`)
|
||||||
_go_find(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
_go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2])
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
}, PlugAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, PlugAction(), LangAction()), 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("web.wiki.word", path.Join(ice.SRC, arg[0]))
|
m.Cmdy("web.wiki.word", path.Join(ice.SRC, strings.TrimPrefix(arg[0], "src/")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Cmdy("web.wiki.word", arg)
|
m.Cmdy("web.wiki.word", arg)
|
||||||
}},
|
}},
|
||||||
}, Configs: ice.Configs{
|
})
|
||||||
SHY: {Name: SHY, Help: "脚本", Value: kit.Data(PLUG, kit.Dict(
|
|
||||||
mdb.RENDER, kit.Dict(),
|
|
||||||
PREFIX, kit.Dict("# ", COMMENT), PREPARE, kit.Dict(
|
|
||||||
KEYWORD, kit.Simple(
|
|
||||||
"source", "return",
|
|
||||||
"title", "premenu", "chapter", "section",
|
|
||||||
"refer", "spark", "field",
|
|
||||||
"chart", "label", "chain", "sequence",
|
|
||||||
"image",
|
|
||||||
),
|
|
||||||
), KEYWORD, kit.Dict(),
|
|
||||||
))},
|
|
||||||
}}, nil)
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,24 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func _vimer_make(m *ice.Message, dir string, msg *ice.Message) {
|
||||||
|
for _, line := range strings.Split(msg.Append(cli.CMD_ERR), ice.NL) {
|
||||||
|
if strings.Contains(line, ice.DF) {
|
||||||
|
if ls := strings.SplitN(line, ice.DF, 4); len(ls) > 3 {
|
||||||
|
m.Push(nfs.PATH, dir)
|
||||||
|
m.Push(nfs.FILE, strings.TrimPrefix(ls[0], dir))
|
||||||
|
m.Push(nfs.LINE, ls[1])
|
||||||
|
m.Push(mdb.TEXT, ls[3])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m.Length() == 0 {
|
||||||
|
m.Echo(msg.Append(cli.CMD_OUT))
|
||||||
|
m.Echo(msg.Append(cli.CMD_ERR))
|
||||||
|
}
|
||||||
|
m.StatusTime()
|
||||||
|
}
|
||||||
|
|
||||||
const VIMER = "vimer"
|
const VIMER = "vimer"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -36,19 +54,19 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(nfs.CONTENT) == "" {
|
if m.Option(nfs.CONTENT) == "" {
|
||||||
m.Option(nfs.CONTENT, m.Cmdx(TEMPLATE, m.Option(mdb.TYPE), m.Option(nfs.FILE), m.Option(nfs.PATH)))
|
m.Option(nfs.CONTENT, m.Cmdx("", TEMPLATE))
|
||||||
}
|
}
|
||||||
m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||||
}},
|
}},
|
||||||
nfs.TRASH: {Name: "trash path", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Name: "trash path", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.TRASH, arg[0])
|
m.Cmd(nfs.TRASH, arg[0])
|
||||||
}},
|
}},
|
||||||
nfs.SCRIPT: {Name: "script file=hi/hi.js", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
nfs.SCRIPT: {Name: "script file=hi/hi.js", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.DEFS, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)), m.Cmdx(TEMPLATE, kit.Ext(m.Option(nfs.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)))
|
m.Cmdy(nfs.DEFS, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)), m.Cmdx("", TEMPLATE))
|
||||||
}},
|
}},
|
||||||
web.WEBSITE: {Name: "website file=hi.zml", Help: "网页", Hand: func(m *ice.Message, arg ...string) {
|
web.WEBSITE: {Name: "website file=hi.zml", Help: "网页", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(nfs.PATH, "src/website/")
|
m.Option(nfs.PATH, "src/website/")
|
||||||
m.Cmdy(nfs.DEFS, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)), m.Cmdx(TEMPLATE, kit.Ext(m.Option(nfs.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)))
|
m.Cmdy(nfs.DEFS, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)), m.Cmdx("", TEMPLATE))
|
||||||
}},
|
}},
|
||||||
web.DREAM: {Name: "dream name=hi repos", Help: "空间", Hand: func(m *ice.Message, arg ...string) {
|
web.DREAM: {Name: "dream name=hi repos", Help: "空间", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(web.DREAM, cli.START, arg)
|
m.Cmdy(web.DREAM, cli.START, arg)
|
||||||
@ -57,6 +75,19 @@ func init() {
|
|||||||
m.Cmdy(XTERM, mdb.CREATE, arg)
|
m.Cmdy(XTERM, mdb.CREATE, arg)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
"keyboard": {Name: "keyboard", Help: "远程控制", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
hash := m.Cmdx("web.chat.keyboard", mdb.CREATE, web.SPACE, m.Option(ice.MSG_DAEMON), ctx.INDEX, m.Option(ctx.INDEX), "input", "")
|
||||||
|
link := tcp.ReplaceLocalhost(m, web.MergePodCmd(m, "", "web.chat.keyboard", mdb.HASH, hash))
|
||||||
|
m.PushQRCode(mdb.TEXT, link)
|
||||||
|
m.Push(mdb.NAME, link)
|
||||||
|
}},
|
||||||
|
"listTags": {Name: "listTags", Help: "索引", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy("web.code.vim.tags", "listTags", arg)
|
||||||
|
}},
|
||||||
|
cli.MAKE: {Name: "make", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
_vimer_make(m, m.Option(nfs.PATH), m.Cmd(cli.SYSTEM, cli.MAKE, arg))
|
||||||
|
}},
|
||||||
|
|
||||||
TEMPLATE: {Name: "template", Help: "模板", Hand: func(m *ice.Message, arg ...string) {
|
TEMPLATE: {Name: "template", Help: "模板", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||||
}},
|
}},
|
||||||
@ -64,14 +95,6 @@ func init() {
|
|||||||
m.Cmdy(COMPLETE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
m.Cmdy(COMPLETE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"keyboard": {Name: "keyboard", Help: "远程控制", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
hash := m.Cmdx("web.chat.keyboard", mdb.CREATE, "space", m.Option(ice.MSG_DAEMON), "index", m.Option("index"), "input", "")
|
|
||||||
link := web.MergePodCmd(m, "", "web.chat.keyboard", mdb.HASH, hash)
|
|
||||||
link = tcp.ReplaceLocalhost(m, link)
|
|
||||||
m.PushQRCode(mdb.TEXT, link)
|
|
||||||
m.Push(mdb.NAME, link)
|
|
||||||
}},
|
|
||||||
|
|
||||||
DEVPACK: {Name: "devpack", Help: "开发模式", Hand: func(m *ice.Message, arg ...string) {
|
DEVPACK: {Name: "devpack", Help: "开发模式", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_DEBUG, ice.GO_SUM))
|
m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_DEBUG, ice.GO_SUM))
|
||||||
m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_DEBUG, ice.GO_MOD))
|
m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_DEBUG, ice.GO_MOD))
|
||||||
@ -93,7 +116,7 @@ func init() {
|
|||||||
if msg := m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN); cli.IsSuccess(msg) {
|
if msg := m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN); cli.IsSuccess(msg) {
|
||||||
m.Cmd(UPGRADE, cli.RESTART)
|
m.Cmd(UPGRADE, cli.RESTART)
|
||||||
} else {
|
} else {
|
||||||
_inner_make(m, nfs.PWD, msg)
|
_vimer_make(m, nfs.PWD, msg)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
PUBLISH: {Name: "publish", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
|
PUBLISH: {Name: "publish", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -120,6 +143,18 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{COMPLETE: {Name: "complete type name text auto", Help: "补全", Actions: mdb.RenderAction()}})
|
Index.MergeCommands(ice.Commands{COMPLETE: {Name: "complete type name text auto", Help: "补全", Actions: mdb.RenderAction()}})
|
||||||
Index.MergeCommands(ice.Commands{NAVIGATE: {Name: "navigate type name text auto", Help: "跳转", Actions: mdb.RenderAction()}})
|
Index.MergeCommands(ice.Commands{NAVIGATE: {Name: "navigate type name text auto", Help: "跳转", Actions: mdb.RenderAction()}})
|
||||||
}
|
}
|
||||||
|
func LangAction() ice.Actions {
|
||||||
|
return ice.Actions{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
for _, cmd := range []string{TEMPLATE, COMPLETE, NAVIGATE} {
|
||||||
|
m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey())
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||||
|
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||||
|
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||||
|
}
|
||||||
|
}
|
||||||
func Complete(m *ice.Message, text string, data ice.Map) {
|
func Complete(m *ice.Message, text string, data ice.Map) {
|
||||||
if strings.HasSuffix(text, ".") {
|
if strings.HasSuffix(text, ".") {
|
||||||
key := kit.Slice(kit.Split(text, " ."), -1)[0]
|
key := kit.Slice(kit.Split(text, " ."), -1)[0]
|
||||||
|
@ -89,7 +89,7 @@ func init() {
|
|||||||
ctx.ProcessRefresh(m)
|
ctx.ProcessRefresh(m)
|
||||||
}},
|
}},
|
||||||
"resize": {Name: "resize", Help: "大小", Hand: func(m *ice.Message, arg ...string) {
|
"resize": {Name: "resize", Help: "大小", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_xterm_get(m, "").Setsize(m.Option("rows"), m.Option("cols"))
|
_xterm_get(m, "").Setsize(m.OptionDefault("rows", "24"), m.OptionDefault("cols", "80"))
|
||||||
}},
|
}},
|
||||||
"input": {Name: "input", Help: "输入", Hand: func(m *ice.Message, arg ...string) {
|
"input": {Name: "input", Help: "输入", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if b, e := base64.StdEncoding.DecodeString(strings.Join(arg, "")); !m.Warn(e) {
|
if b, e := base64.StdEncoding.DecodeString(strings.Join(arg, "")); !m.Warn(e) {
|
||||||
|
9
init.go
9
init.go
@ -70,15 +70,6 @@ var Index = &Context{Name: ICE, Help: "冰山模块", Configs: Configs{
|
|||||||
QUIT: {Name: "quit", Help: "结束", Hand: func(m *Message, arg ...string) {
|
QUIT: {Name: "quit", Help: "结束", Hand: func(m *Message, arg ...string) {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}},
|
}},
|
||||||
"some": {Name: "quit", Help: "结束", Hand: func(m *Message, arg ...string) {
|
|
||||||
m.OptionFields("detail")
|
|
||||||
m.Push("modpath", kit.ModPath(m.root.Travel))
|
|
||||||
m.Push("modname", kit.ModName(m.root.Travel))
|
|
||||||
m.Push("pathname", kit.PathName(m.root.Travel))
|
|
||||||
m.Push("filename", kit.FileName(m.root.Travel))
|
|
||||||
m.Push("funcname", kit.FuncName(m.root.Travel))
|
|
||||||
m.Push("fileline", kit.FileLine(m.root.Travel, 100))
|
|
||||||
}},
|
|
||||||
EXIT: {Name: "exit", Help: "退出", Hand: func(m *Message, arg ...string) {
|
EXIT: {Name: "exit", Help: "退出", Hand: func(m *Message, arg ...string) {
|
||||||
defer m.Target().Close(m.root.Spawn(), arg...)
|
defer m.Target().Close(m.root.Spawn(), arg...)
|
||||||
m.root.Option(EXIT, kit.Select("0", arg, 0))
|
m.root.Option(EXIT, kit.Select("0", arg, 0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user