forked from x/icebergs
opt code
This commit is contained in:
parent
16889fefc9
commit
70f50b91c1
@ -100,6 +100,7 @@ const (
|
||||
SPLIT_QUOTE = "split.quote"
|
||||
SPLIT_TRANS = "split.trans"
|
||||
)
|
||||
const PARSE = "parse"
|
||||
const SPLIT = "split"
|
||||
|
||||
func init() {
|
||||
|
@ -154,7 +154,11 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
|
||||
LIST, func() { _list_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
|
||||
)
|
||||
for _, inputs := range ice.Info.Inputs {
|
||||
inputs(m, arg[3])
|
||||
if arg[2] == ZONE {
|
||||
inputs(m, arg[4])
|
||||
} else {
|
||||
inputs(m, arg[3])
|
||||
}
|
||||
}
|
||||
}},
|
||||
INSERT: {Name: "insert key sub type arg...", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -265,9 +265,10 @@ func ZoneSelectCB(m *ice.Message, zone string, cb Any) *ice.Message {
|
||||
}
|
||||
func PageZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
OptionPages(m, kit.Slice(arg, 2)...)
|
||||
if ZoneSelect(m, arg...); len(kit.Slice(arg, 0, 2)) == 0 {
|
||||
arg = kit.Slice(arg, 0, 2)
|
||||
if ZoneSelect(m, arg...); len(arg) == 0 {
|
||||
m.Action(CREATE)
|
||||
} else {
|
||||
} else if len(arg) == 1 {
|
||||
m.Action(INSERT, "page")
|
||||
}
|
||||
return m
|
||||
|
@ -97,8 +97,9 @@ func PushNotice(m *ice.Message, arg ...ice.Any) {
|
||||
}
|
||||
func PushNoticeToast(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("toast", arg)...) }
|
||||
func PushNoticeGrow(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("grow", arg)...) }
|
||||
func PushStream(m *ice.Message) {
|
||||
func PushStream(m *ice.Message) *ice.Message {
|
||||
m.Options(cli.CMD_OUTPUT, file.NewWriteCloser(func(buf []byte) { PushNoticeGrow(m, string(buf)) }, nil)).ProcessHold(toastContent(m, ice.SUCCESS))
|
||||
return m
|
||||
}
|
||||
func init() { ice.Info.PushStream = PushStream }
|
||||
func init() { ice.Info.PushNotice = PushNotice }
|
||||
|
@ -13,8 +13,8 @@ func init() {
|
||||
FLOWS: {Name: "flows zone hash auto", Icon: "Automator.png", Help: "工作流", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.IsSearchPreview(m, arg) {
|
||||
mdb.HashSelects(m).Table(func(value ice.Maps) {
|
||||
m.PushSearch(mdb.TYPE, "", mdb.NAME, value[mdb.ZONE], mdb.TEXT, value[mdb.ZONE], value)
|
||||
mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) {
|
||||
m.PushSearch(mdb.NAME, value[mdb.ZONE], value)
|
||||
})
|
||||
}
|
||||
}},
|
||||
|
@ -38,13 +38,13 @@ const C = "c"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
C: {Name: "c path auto", Help: "编程", Actions: ice.MergeActions(ice.Actions{
|
||||
C: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _c_exec(m, arg...) }},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.c")) }},
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, "ctags", "-a", "-R", nfs.PWD) }},
|
||||
}, PlugAction())},
|
||||
H: {Name: "h path auto", Help: "编程", Actions: ice.MergeActions(ice.Actions{
|
||||
H: {Actions: ice.MergeActions(ice.Actions{
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, "ctags", "-a", "-R", nfs.PWD) }},
|
||||
}, PlugAction())},
|
||||
})
|
||||
|
@ -1,60 +0,0 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const CASE = "case"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
CASE: {Name: "case dev zone id auto insert", Help: "用例", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INSERT: {Name: "insert zone*=demo name=hi cmd=GET,POST api*=/chat/cmd/web.chat.favor arg:textarea res:textarea"},
|
||||
cli.CHECK: {Help: "检查", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.ProcessInner(); len(arg) > 1 {
|
||||
success := 0
|
||||
m.Cmd("", arg[0], arg[1], func(value ice.Maps) {
|
||||
m.Push(mdb.TIME, m.Time()).Push(mdb.ID, value[mdb.ID])
|
||||
if err := m.Cmdx("", cli.CHECK, value); err == ice.OK {
|
||||
m.Push(ice.ERR, cli.Color(m, cli.GREEN, err))
|
||||
success++
|
||||
} else {
|
||||
m.Push(ice.ERR, cli.Color(m, cli.RED, err))
|
||||
}
|
||||
m.Push(cli.API, value[cli.API])
|
||||
m.Push(ice.ARG, value[ice.ARG])
|
||||
m.Push(ice.RES, value[ice.RES])
|
||||
})
|
||||
m.StatusTimeCount(ice.SUCCESS, success)
|
||||
return
|
||||
}
|
||||
if res := kit.UnMarshal(m.Cmdx("", ctx.RUN)); m.Option(ice.RES) != "" {
|
||||
for k, v := range kit.KeyValue(nil, "", kit.UnMarshal(m.Option(ice.RES))) {
|
||||
if v != kit.Value(res, k) {
|
||||
m.Echo(kit.Formats(res))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
m.Echo(ice.OK)
|
||||
}},
|
||||
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(web.SPIDE_HEADER, web.ContentType, web.ApplicationJSON, web.UserAgent, "Mozilla/5.0")
|
||||
m.Cmdy(web.SPIDE, m.Option(ice.DEV), web.SPIDE_RAW, m.Option(ice.CMD), m.Option(cli.API), web.SPIDE_DATA, m.Option(ice.ARG)).ProcessInner()
|
||||
m.StatusTime(nfs.SCRIPT, `curl "`+kit.MergeURL2(m.Cmd(web.SPIDE, m.Option(ice.DEV)).Append(web.CLIENT_ORIGIN), m.Option(cli.API))+`" -H "Content-Type: application/json"`+` -d '`+m.Option(ice.ARG)+`'`)
|
||||
}},
|
||||
}, mdb.ZoneAction(mdb.FIELDS, "time,id,name,cmd,api,arg,res")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy(web.SPIDE).RenameAppend(web.CLIENT_NAME, ice.DEV, web.CLIENT_URL, "address")
|
||||
} else if mdb.ZoneSelect(m, arg[1:]...); len(arg) > 1 {
|
||||
m.PushAction(ctx.RUN, cli.CHECK).Action(cli.CHECK)
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
@ -17,7 +17,6 @@ repos.go
|
||||
favor.go
|
||||
bench.go
|
||||
pprof.go
|
||||
case.go
|
||||
|
||||
c.go
|
||||
sh.go
|
||||
|
@ -67,7 +67,7 @@ const CSS = "css"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
CSS: {Name: "css path auto", Help: "样式表", Actions: ice.MergeActions(ice.Actions{
|
||||
CSS: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _css_show(m, arg...) }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _css_exec(m, arg...) }},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -57,6 +58,29 @@ func _go_complete(m *ice.Message, arg ...string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
func _go_navigate(m *ice.Message, arg ...string) {
|
||||
for _, cmd := range []string{"guru", "gopls"} {
|
||||
if ls := kit.Split(m.Cmdx(cli.SYSTEM, cmd, "definition", m.Option(nfs.PATH)+m.Option(nfs.FILE)+nfs.DF+"#"+m.Option("offset")), nfs.DF); len(ls) > 0 {
|
||||
if strings.HasPrefix(ls[0], kit.Path("")) {
|
||||
_ls := nfs.SplitPath(m, strings.TrimPrefix(ls[0], kit.Path("")+nfs.PS))
|
||||
m.Push(nfs.PATH, _ls[0]).Push(nfs.FILE, _ls[1]).Push(nfs.LINE, ls[1])
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
_c_tags(m, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD)
|
||||
}
|
||||
func _go_show(m *ice.Message, arg ...string) {
|
||||
if arg[1] == "main.go" {
|
||||
ProcessXterm(m, "ish", "", arg[1])
|
||||
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
ctx.ProcessField(m, cmd, kit.Simple())
|
||||
} else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
|
||||
ctx.ProcessField(m, msg.Option("__index"), kit.Simple())
|
||||
} else {
|
||||
ctx.ProcessField(m, yac.STACK, kit.Simple(path.Join(arg[2], arg[1])))
|
||||
}
|
||||
}
|
||||
func _mod_show(m *ice.Message, file string) {
|
||||
const (
|
||||
MODULE = "module"
|
||||
@ -99,60 +123,26 @@ const GO = "go"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
"godoc": {Name: "godoc key auto", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy(cli.SYSTEM, "go", "list", "std")
|
||||
} else {
|
||||
m.Cmdy(cli.SYSTEM, "go", "doc", arg)
|
||||
}
|
||||
}},
|
||||
GO: {Name: "go path auto", Help: "后端编程", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[1] == "main.go" {
|
||||
ProcessXterm(m, "ish", "", arg[1])
|
||||
} else if arg[1] == "misc/xterm/iterm.go" {
|
||||
ProcessXterm(m, "ish", "", arg[1])
|
||||
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
ctx.ProcessField(m, cmd, kit.Simple())
|
||||
} else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
|
||||
ctx.ProcessField(m, msg.Option("__index"), kit.Simple())
|
||||
} else {
|
||||
ctx.ProcessField(m, yac.STACK, kit.Simple(path.Join(arg[2], arg[1])))
|
||||
}
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[1] == "main.go" {
|
||||
ProcessXterm(m, "ish", "", arg[1])
|
||||
} else if arg[1] == "misc/xterm/iterm.go" {
|
||||
ProcessXterm(m, "ish", "", arg[1])
|
||||
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
ctx.ProcessField(m, cmd, kit.Simple())
|
||||
} else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
|
||||
ctx.ProcessField(m, msg.Option("__index"), kit.Simple())
|
||||
} else {
|
||||
ctx.ProcessField(m, yac.STACK, kit.Simple(path.Join(arg[2], arg[1])))
|
||||
}
|
||||
}},
|
||||
GO: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _go_show(m, arg...) }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_show(m, arg...) }},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option("name", kit.TrimExt(path.Base(arg[1]), "go"))
|
||||
m.Option("zone", path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||
m.Option("key", kit.Keys("web.code", m.Option("zone"), m.Option("name")))
|
||||
m.Option(mdb.NAME, kit.TrimExt(path.Base(arg[1]), GO))
|
||||
m.Option(mdb.ZONE, path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||
m.Option(mdb.KEY, kit.Keys("web.code", m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
||||
m.Echo(nfs.Template(m, "demo.go"))
|
||||
}},
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { _go_complete(m, arg...) }},
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
for _, cmd := range []string{"guru", "gopls"} {
|
||||
if ls := kit.Split(m.Cmdx(cli.SYSTEM, cmd, "definition", m.Option(nfs.PATH)+m.Option(nfs.FILE)+nfs.DF+"#"+m.Option("offset")), nfs.DF); len(ls) > 0 {
|
||||
if strings.HasPrefix(ls[0], kit.Path("")) {
|
||||
_ls := nfs.SplitPath(m, strings.TrimPrefix(ls[0], kit.Path("")+nfs.PS))
|
||||
m.Push(nfs.PATH, _ls[0]).Push(nfs.FILE, _ls[1]).Push(nfs.LINE, ls[1])
|
||||
return
|
||||
}
|
||||
}
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _go_navigate(m, arg...) }},
|
||||
VIMER_SAVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch p := path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)); kit.Ext(m.Option(nfs.FILE)) {
|
||||
case nfs.GO:
|
||||
defer m.Cmdy(nfs.CAT, p)
|
||||
m.Cmd(cli.SYSTEM, "gofmt", "-w", p)
|
||||
m.Cmd(cli.SYSTEM, "goimports", "-w", p)
|
||||
}
|
||||
_c_tags(m, "gotags", "-f", nfs.TAGS, "-R", nfs.PWD)
|
||||
}},
|
||||
}, PlugAction())},
|
||||
}, gdb.EventsAction(VIMER_SAVE), PlugAction())},
|
||||
MOD: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -16,7 +15,7 @@ const HTML = "html"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
HTML: {Name: "html path auto", Help: "网页", Actions: ice.MergeActions(ice.Actions{
|
||||
HTML: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.EchoIFrame(kit.MergeURL(require(arg[2], arg[1]), "_v", kit.Hashs(mdb.UNIQ)))
|
||||
}},
|
||||
@ -24,7 +23,7 @@ func init() {
|
||||
m.EchoIFrame(kit.MergeURL(require(arg[2], arg[1]), "_v", kit.Hashs(mdb.UNIQ)))
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(kit.Renders(nfs.TemplateText(m, "demo.html"), ice.Maps{ice.LIST: kit.Format(kit.List(kit.Dict(ctx.INDEX, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO)))))})).RenderResult()
|
||||
m.Echo(nfs.Template(m, "demo.html"))
|
||||
}},
|
||||
}, PlugAction())},
|
||||
})
|
||||
|
@ -2,6 +2,7 @@ package code
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -84,70 +85,40 @@ const (
|
||||
const INNER = "inner"
|
||||
|
||||
func init() {
|
||||
var bind = []string{"usr/icebergs/core/", "usr/volcanos/plugin/local/"}
|
||||
Index.MergeCommands(ice.Commands{
|
||||
INNER: {Name: "inner path=src/@key file=main.go@key line=1 auto show exec", Help: "源代码", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch p := kit.Select(nfs.PWD, arg, 1); arg[0] {
|
||||
case ice.CMD:
|
||||
m.Cmd(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX), func(value ice.Maps) {
|
||||
if strings.HasPrefix(value[ctx.INDEX], kit.Select("", arg, 1)) {
|
||||
ls := kit.Split(strings.TrimPrefix(value[ctx.INDEX], kit.Select("", arg, 1)), nfs.PT)
|
||||
m.Push(arg[0], ls[0]+kit.Select("", nfs.PT, len(ls) > 1))
|
||||
}
|
||||
})
|
||||
case ctx.INDEX:
|
||||
m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX))
|
||||
case ctx.ARGS:
|
||||
m.Cmdy(ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX))
|
||||
case nfs.PATH:
|
||||
m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS)
|
||||
kit.If(strings.HasPrefix(p, bind[0]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[0], bind[1], 1), nfs.DIR_CLI_FIELDS) })
|
||||
kit.If(strings.HasPrefix(p, bind[1]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[1], bind[0], 1), nfs.DIR_CLI_FIELDS) })
|
||||
case nfs.FILE:
|
||||
m.Option(nfs.DIR_DEEP, ice.TRUE)
|
||||
m.Cmdy(nfs.DIR, path.Join(m.Option(nfs.PATH), kit.Select(path.Dir(p), p, strings.HasSuffix(p, nfs.PS))+nfs.PS), nfs.PATH)
|
||||
default:
|
||||
m.Cmdy(FAVOR, mdb.INPUTS, arg)
|
||||
}
|
||||
}},
|
||||
INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(FAVOR, mdb.INPUTS, arg) }},
|
||||
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
||||
m.Cmdy(mdb.PLUGIN, m.Option("parse", strings.ToLower(kit.Split(path.Base(arg[1]), nfs.PT)[0])), arg[1:])
|
||||
m.Cmdy(mdb.PLUGIN, m.Option(lex.PARSE, strings.ToLower(kit.Split(path.Base(arg[1]), nfs.PT)[0])), arg[1:])
|
||||
}
|
||||
}},
|
||||
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]) }},
|
||||
nfs.GREP: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.GREP, arg) }},
|
||||
nfs.TAGS: {Hand: func(m *ice.Message, arg ...string) { _inner_tags(m, m.Option(nfs.PATH), arg[0]) }},
|
||||
nfs.GREP: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.GREP, arg) }},
|
||||
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))
|
||||
}},
|
||||
}, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.HasPrefix(arg[0], "/volcanos/", "/require/", "http") {
|
||||
m.Echo(m.Cmdx(web.SPIDE, ice.DEV, web.SPIDE_RAW, arg[0]))
|
||||
if kit.HasPrefix(arg[0], "/volcanos/", "/require/", ice.HTTP) {
|
||||
m.Echo(m.Cmdx(web.SPIDE, ice.DEV, web.SPIDE_RAW, http.MethodGet, arg[0]))
|
||||
m.Options("mode", "simple", lex.PARSE, kit.Ext(kit.ParseURL(arg[0]).Path))
|
||||
ctx.DisplayLocal(m, "")
|
||||
u := kit.ParseURL(arg[0])
|
||||
m.Options("mode", "simple", "parse", kit.Ext(u.Path))
|
||||
// ctx.ProcessRewrite(m, nfs.PATH, path.Dir(u.Path)+nfs.PS, nfs.FILE, path.Base(u.Path))
|
||||
return
|
||||
}
|
||||
if arg[0] = strings.Split(arg[0], mdb.FS)[0]; !strings.HasSuffix(arg[0], nfs.PS) && len(arg) == 1 {
|
||||
} else if arg[0] = strings.Split(arg[0], mdb.FS)[0]; !strings.HasSuffix(arg[0], nfs.PS) && len(arg) == 1 {
|
||||
arg[1] = kit.Slice(strings.Split(arg[0], nfs.PS), -1)[0]
|
||||
arg[0] = strings.TrimSuffix(arg[0], arg[1])
|
||||
m.ProcessRewrite(nfs.PATH, arg[0], nfs.FILE, arg[1])
|
||||
} else if len(arg) < 2 {
|
||||
nfs.Dir(m, nfs.PATH)
|
||||
} else if strings.Contains(arg[1], nfs.DF) {
|
||||
ls := strings.Split(arg[1], nfs.DF)
|
||||
m.ProcessRewrite(nfs.LINE, ls[0], nfs.FILE, ls[1])
|
||||
} else {
|
||||
if strings.Contains(arg[1], ":") {
|
||||
ls := strings.Split(arg[1], ":")
|
||||
m.ProcessRewrite(nfs.LINE, ls[0], nfs.FILE, ls[1])
|
||||
return
|
||||
}
|
||||
arg[1] = strings.Split(arg[1], mdb.FS)[0]
|
||||
_inner_list(m, kit.Ext(arg[1]), arg[1], arg[0])
|
||||
ctx.DisplayLocal(m, "").Option(REPOS, kit.Join(m.Cmd(REPOS, ice.OptionFields(nfs.PATH)).Sort(nfs.PATH).Appendv(nfs.PATH)))
|
||||
m.Status(mdb.TIME, ice.Info.Make.Time, "file", arg[1], "line", kit.Select("1", arg, 2), "back", "0")
|
||||
m.Status(mdb.TIME, ice.Info.Make.Time, nfs.FILE, arg[1], nfs.LINE, kit.Select("1", arg, 2), cli.BACK, "0")
|
||||
}
|
||||
}},
|
||||
})
|
||||
@ -155,7 +126,15 @@ func init() {
|
||||
func PlugAction() ice.Actions {
|
||||
return ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.For([]string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE, TEMPLATE, COMPLETE}, func(cmd string) { m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey()) })
|
||||
if cmd := m.Target().Commands[m.CommandKey()]; cmd != nil {
|
||||
if cmd.Name == "" {
|
||||
cmd.Name = kit.Format("%s path auto", m.CommandKey())
|
||||
cmd.List = ice.SplitCmd(cmd.Name, cmd.Actions)
|
||||
}
|
||||
}
|
||||
kit.For([]string{mdb.PLUGIN, mdb.RENDER, mdb.ENGINE}, func(cmd string) {
|
||||
m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey())
|
||||
})
|
||||
LoadPlug(m, m.CommandKey())
|
||||
}},
|
||||
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(mdb.Config(m, PLUG)) }},
|
||||
|
@ -13,7 +13,9 @@ import (
|
||||
)
|
||||
|
||||
func _js_show(m *ice.Message, arg ...string) {
|
||||
if arg[2] == ice.USR_VOLCANOS {
|
||||
if arg[1] == "main.js" {
|
||||
ctx.ProcessField(m, web.CHAT_IFRAME, kit.Simple(web.UserHost(m)))
|
||||
} else if arg[2] == ice.USR_VOLCANOS {
|
||||
if strings.HasPrefix(arg[1], "plugin/local/") {
|
||||
ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), nfs.PT+JS), nfs.PS, nfs.PT, -1)), kit.Simple())
|
||||
}
|
||||
@ -21,27 +23,16 @@ func _js_show(m *ice.Message, arg ...string) {
|
||||
ctx.DisplayBase(m, require(arg[2], arg[1]))
|
||||
ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const JS = "js"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
JS: {Name: "js path auto", Help: "前端", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[1] == "main.js" {
|
||||
ctx.ProcessField(m, "web.chat.iframe", kit.Simple(web.UserHost(m)))
|
||||
} else {
|
||||
_js_show(m, arg...)
|
||||
}
|
||||
return
|
||||
ProcessXterm(m, "node", kit.Format(`require("./usr/volcanos/proto.js"), require("./usr/volcanos/publish/client/nodejs/proto.js"), Volcanos.meta._main("%s")`, path.Join(nfs.PS, arg[2], arg[1])))
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
_js_show(m, arg...)
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.js")) }},
|
||||
JS: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _js_show(m, arg...) }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _js_show(m, arg...) }},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.js")) }},
|
||||
}, PlugAction())},
|
||||
})
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
@ -26,12 +27,12 @@ const MAKEFILE = "makefile"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
MAKEFILE: {Name: "makefile path auto", Help: "构建", Actions: ice.MergeActions(ice.Actions{
|
||||
MAKEFILE: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Options(lex.SPLIT_BLOCK, ":")
|
||||
m.Options(lex.SPLIT_BLOCK, nfs.DF)
|
||||
m.Cmd(lex.SPLIT, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)), func(indent int, text string, ls []string) {
|
||||
if indent == 1 && ls[1] == ":" {
|
||||
m.Push("target", ls[0]).Push("source", kit.Join(ls[2:])).PushButton("make")
|
||||
if indent == 1 && ls[1] == nfs.DF {
|
||||
m.Push(nfs.TARGET, ls[0]).Push(nfs.SOURCE, kit.Join(ls[2:], lex.SP)).PushButton(cli.MAKE)
|
||||
}
|
||||
})
|
||||
}},
|
||||
|
@ -59,8 +59,8 @@ func init() {
|
||||
}},
|
||||
}, mdb.ZoneAction(mdb.FIELD, "time,zone,count,binnary,service,seconds", mdb.FIELDS, "time,id,text,file", PPROF, kit.List(GO, "tool", PPROF))), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.ZoneSelect(m, arg...); len(arg) == 0 {
|
||||
m.EchoAnchor(web.MergeLink(m, "/debug/pprof/"))
|
||||
m.PushAction(cli.START, mdb.REMOVE).Action(mdb.CREATE)
|
||||
m.StatusTimeCount(web.LINK, web.MergeLink(m, "/debug/pprof/"))
|
||||
} else {
|
||||
m.Table(func(value ice.Maps) { m.PushDownload(mdb.LINK, "pprof.pd.gz", value[nfs.FILE]).PushButton(web.SERVE) })
|
||||
m.Action(cli.START)
|
||||
|
@ -10,28 +10,26 @@ import (
|
||||
)
|
||||
|
||||
func _py_exec(m *ice.Message, p string) {
|
||||
const PYTHON2 = "python2"
|
||||
if _, e := nfs.DiskFile.StatFile(p); e == nil {
|
||||
m.Cmdy(cli.SYSTEM, PYTHON2, p)
|
||||
m.Cmdy(cli.SYSTEM, PYTHON, p)
|
||||
} else if b, e := nfs.ReadFile(m, p); e == nil {
|
||||
m.Cmdy(cli.SYSTEM, PYTHON2, "-c", string(b))
|
||||
m.Cmdy(cli.SYSTEM, PYTHON, "-c", string(b))
|
||||
}
|
||||
m.StatusTime()
|
||||
}
|
||||
|
||||
const (
|
||||
PYTHON = "python"
|
||||
)
|
||||
const PY = nfs.PY
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
PY: {Name: "py path auto", Help: "脚本", Actions: ice.MergeActions(ice.Actions{
|
||||
PY: {Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
cli.IsAlpine(m, "python", "python3")
|
||||
cli.IsAlpine(m, "python3")
|
||||
cli.IsCentos(m, "python", "python2")
|
||||
cli.IsCentos(m, "python2")
|
||||
cli.IsCentos(m, "python3")
|
||||
cli.IsAlpine(m, PYTHON, "python3")
|
||||
cli.IsCentos(m, PYTHON, "python2")
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { ProcessXterm(m, "python -i "+path.Join(arg[2], arg[1]), "") }},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { ProcessXterm(m, PYTHON+" -i "+path.Join(arg[2], arg[1]), "") }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _py_exec(m, path.Join(arg[2], arg[1])) }},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.py")) }},
|
||||
}, PlugAction())},
|
||||
|
@ -32,7 +32,7 @@ const SH = nfs.SH
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{
|
||||
SH: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
cmds, text := _sh_cmds(m, path.Join(arg[2], arg[1]))
|
||||
ProcessXterm(m, cmds, text, path.Join(arg[2], arg[1]))
|
||||
|
@ -17,7 +17,7 @@ const SHY = "shy"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SHY: {Name: "shy path auto", Help: "笔记", Actions: ice.MergeActions(ice.Actions{
|
||||
SHY: {Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, web.WIKI_WORD, kit.Simple(path.Join(arg[2], arg[1])))
|
||||
return
|
||||
@ -36,10 +36,10 @@ func init() {
|
||||
m.Option(mdb.NAME, path.Base(path.Dir(path.Join(arg[2], arg[1]))))
|
||||
m.Echo(nfs.Template(m, "demo.shy"))
|
||||
}},
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("web.wiki.word", COMPLETE, arg) }},
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.WIKI_WORD, COMPLETE, arg) }},
|
||||
}, PlugAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() {
|
||||
m.Cmdy(web.WIKI_WORD, path.Join(ice.SRC, strings.TrimPrefix(arg[0], nfs.SRC)))
|
||||
m.Cmdy(web.WIKI_WORD, path.Join(nfs.SRC, strings.TrimPrefix(arg[0], nfs.SRC)))
|
||||
} else {
|
||||
m.Cmdy(web.WIKI_WORD, arg)
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"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/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -24,29 +25,24 @@ func _vimer_make(m *ice.Message, dir string, msg *ice.Message) {
|
||||
for _, line := range strings.Split(msg.Append(cli.CMD_ERR), lex.NL) {
|
||||
if !strings.Contains(line, nfs.DF) {
|
||||
continue
|
||||
}
|
||||
if ls := strings.SplitN(line, nfs.DF, 4); len(ls) > 3 {
|
||||
} else if ls := strings.SplitN(line, nfs.DF, 4); len(ls) > 3 {
|
||||
for i, p := range kit.Split(dir) {
|
||||
if strings.HasPrefix(ls[0], p) {
|
||||
m.Push(nfs.PATH, p)
|
||||
m.Push(nfs.FILE, strings.TrimPrefix(ls[0], p))
|
||||
m.Push(nfs.LINE, ls[1])
|
||||
m.Push(mdb.TEXT, ls[3])
|
||||
m.Push(nfs.PATH, p).Push(nfs.FILE, strings.TrimPrefix(ls[0], p)).Push(nfs.LINE, ls[1]).Push(mdb.TEXT, ls[3])
|
||||
break
|
||||
} else if i == strings.Count(dir, mdb.FS) {
|
||||
ps := nfs.SplitPath(m, ls[0])
|
||||
m.Push(nfs.PATH, ps[0])
|
||||
m.Push(nfs.FILE, ps[1])
|
||||
m.Push(nfs.LINE, ls[1])
|
||||
m.Push(mdb.TEXT, ls[3])
|
||||
m.Push(nfs.PATH, ps[0]).Push(nfs.FILE, ps[1]).Push(nfs.LINE, ls[1]).Push(mdb.TEXT, ls[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// kit.If(m.Length() == 0, func() { m.Echo(msg.Append(cli.CMD_OUT)).Echo(msg.Append(cli.CMD_ERR)) })
|
||||
m.Echo(msg.Append(cli.CMD_OUT)).Echo(msg.Append(cli.CMD_ERR))
|
||||
}
|
||||
|
||||
const (
|
||||
VIMER_SAVE = "vimer.save"
|
||||
)
|
||||
const VIMER = "vimer"
|
||||
|
||||
func init() {
|
||||
@ -55,47 +51,46 @@ func init() {
|
||||
ice.REQUIRE_USR: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR, path.Join(arg...)) }},
|
||||
ice.REQUIRE_MODULES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
p := path.Join(ice.USR_MODULES, path.Join(arg...))
|
||||
kit.If(!nfs.Exists(m, p), func() { m.Cmd(cli.SYSTEM, "npm", "install", arg[0], kit.Dict(cli.CMD_DIR, ice.USR)) })
|
||||
kit.If(!nfs.Exists(m, p), func() { m.Cmd(cli.SYSTEM, "npm", INSTALL, arg[0], kit.Dict(cli.CMD_DIR, ice.USR)) })
|
||||
m.RenderDownload(p)
|
||||
}},
|
||||
})
|
||||
Index.MergeCommands(ice.Commands{
|
||||
VIMER: {Name: "vimer path=src/@key file=main.go@key line=1 list", Icon: "vimer.png", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{
|
||||
VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Icon: "vimer.png", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.IsSearchPreview(m, arg) {
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_SH)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_SHY)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_GO)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_JS)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_SH)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_SHY)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_GO)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_JS)
|
||||
}
|
||||
}},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(ctx.ACTION) {
|
||||
case nfs.MODULE:
|
||||
m.Cmdy(AUTOGEN, mdb.INPUTS, arg)
|
||||
case nfs.SCRIPT:
|
||||
for _, ext := range []string{SH, SHY, PY, JS, CSS, HTML} {
|
||||
case nfs.SCRIPT, mdb.CREATE:
|
||||
kit.For([]string{SH, SHY, PY, JS, CSS, HTML}, func(ext string) {
|
||||
m.Push(nfs.PATH, kit.ExtChange(m.Option(nfs.FILE), ext))
|
||||
}
|
||||
})
|
||||
m.Option(nfs.DIR_REG, kit.ExtReg(SH, SHY, PY, JS, CSS, HTML))
|
||||
nfs.DirDeepAll(m, nfs.SRC, nfs.PWD, nil, nfs.PATH)
|
||||
case web.DREAM, XTERM, AUTOGEN:
|
||||
m.Cmdy(m.Option(ctx.ACTION), mdb.INPUTS, arg)
|
||||
default:
|
||||
switch arg[0] {
|
||||
case web.SPACE:
|
||||
m.Cmdy(web.SPACE, mdb.INPUTS, arg)
|
||||
case ctx.INDEX:
|
||||
m.Cmdy(web.Space(m, m.Option(web.SPACE)), ctx.COMMAND)
|
||||
case ctx.ARGS:
|
||||
m.Cmdy(web.Space(m, m.Option(web.SPACE)), ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX))
|
||||
case nfs.PATH:
|
||||
p := kit.Select(nfs.PWD, arg, 1)
|
||||
m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS)
|
||||
var bind = []string{"usr/icebergs/core/", "usr/volcanos/plugin/local/"}
|
||||
kit.If(strings.HasPrefix(p, bind[0]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[0], bind[1], 1), nfs.DIR_CLI_FIELDS) })
|
||||
kit.If(strings.HasPrefix(p, bind[1]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[1], bind[0], 1), nfs.DIR_CLI_FIELDS) })
|
||||
case nfs.FILE:
|
||||
list := ice.Map{}
|
||||
push := func(k, p string) {
|
||||
kit.IfNoKey(list, kit.Select(k, k+nfs.DF, k != "")+p, func(p string) { m.Push(nfs.PATH, p) })
|
||||
}
|
||||
mdb.HashSelect(m.Spawn()).TablesLimit(30, func(value ice.Maps) { push("", value[nfs.PATH]) })
|
||||
m.Cmd(mdb.SEARCH, mdb.FOREACH, "", ice.OptionFields("type,name,text")).Sort("type,name,text").Table(func(value ice.Maps) {
|
||||
m.Cmd(mdb.SEARCH, mdb.FOREACH, "", "").Sort("").Table(func(value ice.Maps) {
|
||||
switch value[mdb.TYPE] {
|
||||
case nfs.FILE:
|
||||
push("", value[mdb.TEXT])
|
||||
@ -103,10 +98,10 @@ func init() {
|
||||
push(web.SPACE, value[mdb.TEXT])
|
||||
case web.LINK:
|
||||
push(web.SPACE, value[mdb.TEXT])
|
||||
case web.SERVER:
|
||||
push(web.SPACE, value[mdb.TEXT])
|
||||
case web.WORKER:
|
||||
push(web.SPACE, value[mdb.NAME])
|
||||
case web.SERVER:
|
||||
push(web.SPACE, value[mdb.TEXT])
|
||||
case ctx.INDEX:
|
||||
push(ctx.INDEX, value[mdb.TEXT])
|
||||
case ssh.SHELL:
|
||||
@ -118,38 +113,16 @@ func init() {
|
||||
for _, p := range kit.Split(kit.Select(m.Option(nfs.PATH), m.Option("paths"))) {
|
||||
nfs.DirDeepAll(m.Spawn(), nfs.PWD, p, func(value ice.Maps) { push("", value[nfs.PATH]) }, nfs.PATH)
|
||||
}
|
||||
m.Cmd(XTERM).Table(func(value ice.Maps) {
|
||||
push(ctx.INDEX, kit.Join([]string{web.CODE_XTERM, value[mdb.HASH], kit.Select(value[mdb.TYPE], value[mdb.NAME])}))
|
||||
})
|
||||
m.Cmd(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX)).Table(func(value ice.Maps) { push(ctx.INDEX, value[ctx.INDEX]) })
|
||||
m.Cmd(mdb.SEARCH, cli.SYSTEM, cli.OPENS, ice.OptionFields("type,name,text")).Sort("type,name,text").Table(func(value ice.Maps) { push(cli.OPENS, value[nfs.NAME]) })
|
||||
m.Cmd(ctx.COMMAND).Table(func(value ice.Maps) { push(ctx.INDEX, value[ctx.INDEX]) })
|
||||
default:
|
||||
m.Cmdy(INNER, mdb.INPUTS, arg)
|
||||
}
|
||||
}
|
||||
}},
|
||||
nfs.SAVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(nfs.CONTENT) == "" {
|
||||
m.Option(nfs.CONTENT, m.Cmdx("", TEMPLATE))
|
||||
}
|
||||
p := path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))
|
||||
switch m.Cmd(nfs.SAVE, p); m.Option(nfs.FILE) {
|
||||
case ice.INDEX_CSS, ice.PROTO_JS:
|
||||
m.Cmd("", DEVPACK)
|
||||
}
|
||||
switch arg[0] {
|
||||
case nfs.GO:
|
||||
defer m.Cmdy(nfs.CAT, p)
|
||||
m.Cmd(cli.SYSTEM, "gofmt", "-w", p)
|
||||
m.Cmd(cli.SYSTEM, "goimports", "-w", p)
|
||||
}
|
||||
}},
|
||||
cli.MAKE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
web.PushStream(m)
|
||||
defer web.ToastProcess(m)()
|
||||
m.Cmd(cli.SYSTEM, "echo")
|
||||
m.Cmd(cli.SYSTEM, "date")
|
||||
m.Cmd(cli.SYSTEM, cli.MAKE, m.Option("target"), kit.Dict(cli.CMD_DIR, m.Option(nfs.PATH)))
|
||||
kit.If(m.Option(nfs.CONTENT) == "", func() { m.Option(nfs.CONTENT, m.Cmdx("", TEMPLATE)) })
|
||||
m.Cmd(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||
gdb.Event(m, VIMER_SAVE)
|
||||
}},
|
||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, arg[0]) }},
|
||||
nfs.MODULE: {Name: "create name*=h2 help=示例 type*=Hash,Zone,Data,Code main*=main.go zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -158,19 +131,18 @@ func init() {
|
||||
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))
|
||||
}},
|
||||
nfs.REPOS: {Help: "仓库"}, web.SPACE: {Help: "空间"}, web.DREAM: {Help: "空间"}, FAVOR: {Help: "收藏"},
|
||||
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }},
|
||||
"listTags": {Help: "生成索引", Hand: func(m *ice.Message, arg ...string) { m.Cmd("web.code.vim.tags", nfs.LOAD) }},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||
}},
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(COMPLETE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||
nfs.REPOS: {Help: "仓库"}, web.SPACE: {Help: "空间"}, web.DREAM: {Help: "空间"},
|
||||
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }},
|
||||
cli.MAKE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
defer web.ToastProcess(m)()
|
||||
web.PushStream(m)
|
||||
m.Cmd(cli.SYSTEM, "echo")
|
||||
m.Cmd(cli.SYSTEM, "date")
|
||||
m.Cmd(cli.SYSTEM, cli.MAKE, m.Option("target"), kit.Dict(cli.CMD_DIR, m.Option(nfs.PATH)))
|
||||
}},
|
||||
COMPILE: {Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(nfs.PATH) != "" && nfs.ExistsFile(m, path.Join(m.Option(nfs.PATH), "Makefile")) {
|
||||
web.PushStream(m)
|
||||
m.Cmdy(cli.SYSTEM, cli.MAKE, kit.Dict(cli.CMD_DIR, m.Option(nfs.PATH)))
|
||||
if m.Option(nfs.PATH) != "" && nfs.ExistsFile(m, path.Join(m.Option(nfs.PATH), ice.MAKEFILE)) {
|
||||
web.PushStream(m).Cmdy(cli.SYSTEM, cli.MAKE, kit.Dict(cli.CMD_DIR, m.Option(nfs.PATH)))
|
||||
return
|
||||
}
|
||||
const app, _app = "usr/publish/Contexts.app", "Contents/MacOS/Contexts"
|
||||
@ -181,43 +153,39 @@ func init() {
|
||||
cmds = []string{COMPILE, ice.SRC_WEBVIEW_GO, path.Join(app, _app)}
|
||||
}
|
||||
if msg := m.Cmd(cmds); cli.IsSuccess(msg) {
|
||||
if isWebview() {
|
||||
m.Go(func() { m.Cmd(cli.SYSTEM, "./bin/ice.bin", cli.FOREVER, cli.DELAY, "300ms", cli.SYSTEM, cli.OPEN, app) })
|
||||
if m.Go(func() { m.Sleep30ms().Cmd(UPGRADE, cli.RESTART) }); isWebview() {
|
||||
m.Cmd(cli.DAEMON, "./bin/ice.bin", cli.FOREVER, cli.DELAY, "300ms", cli.SYSTEM, cli.OPEN, app)
|
||||
}
|
||||
m.Go(func() { m.Sleep30ms().Cmd(UPGRADE, cli.RESTART) })
|
||||
} else {
|
||||
_vimer_make(m, nfs.PWD, msg)
|
||||
}
|
||||
}},
|
||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.WORKER, web.SERVER), func() {
|
||||
m.PushButton(kit.Dict(m.CommandKey(), "编程"))
|
||||
})
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||
}},
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(COMPLETE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||
}},
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
|
||||
chat.FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case mdb.TYPE:
|
||||
m.Push(arg[0], nfs.FILE)
|
||||
case mdb.TEXT:
|
||||
if m.Option(mdb.TYPE) == nfs.FILE {
|
||||
m.Push(arg[0], "src/main.go", "src/main.shy")
|
||||
}
|
||||
kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { m.Push(arg[0], ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO, ice.SRC_MAIN_JS) })
|
||||
}
|
||||
}},
|
||||
chat.FAVOR_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() {
|
||||
m.PushButton(kit.Dict(m.CommandKey(), "源码"))
|
||||
})
|
||||
kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { m.PushButton(kit.Dict(m.CommandKey(), "源码")) })
|
||||
}},
|
||||
chat.FAVOR_ACTION: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(mdb.TYPE) == nfs.FILE {
|
||||
ctx.ProcessField(m, m.PrefixKey(), nfs.SplitPath(m, m.Option(mdb.TEXT)))
|
||||
}
|
||||
kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { ctx.ProcessField(m, m.PrefixKey(), nfs.SplitPath(m, m.Option(mdb.TEXT))) })
|
||||
}},
|
||||
}, chat.FavorAction(), aaa.RoleAction(), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path", ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) {
|
||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.WORKER, web.SERVER), func() { m.PushButton(kit.Dict(m.CommandKey(), "编程")) })
|
||||
}},
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
|
||||
}, aaa.RoleAction(), chat.FavorAction(), ctx.ConfAction(ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(INNER, arg); arg[0] != ctx.ACTION {
|
||||
kit.If(len(arg) > 1, func() { mdb.HashCreate(m.Spawn(), nfs.PATH, path.Join(kit.Slice(arg, 0, 2)...)) })
|
||||
m.Action(nfs.SAVE, COMPILE, "show", "exec")
|
||||
ctx.DisplayLocal(m, "")
|
||||
ctx.Toolkit(m)
|
||||
@ -231,15 +199,18 @@ const COMPLETE = "complete"
|
||||
const NAVIGATE = "navigate"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{TEMPLATE: {Name: "template 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{
|
||||
TEMPLATE: {Name: "template type name text auto", Help: "模板", Actions: mdb.RenderAction()},
|
||||
COMPLETE: {Name: "complete type name text auto", Help: "补全", Actions: mdb.RenderAction()},
|
||||
NAVIGATE: {Name: "navigate type name text auto", Help: "跳转", Actions: mdb.RenderAction()},
|
||||
})
|
||||
ice.AddMergeAction(func(c *ice.Context, key string, cmd *ice.Command, sub string, action *ice.Action) ice.Handler {
|
||||
switch sub {
|
||||
case TEMPLATE, COMPLETE, NAVIGATE:
|
||||
return func(m *ice.Message, arg ...string) { m.Cmd(sub, mdb.CREATE, key, m.PrefixKey()) }
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
func Complete(m *ice.Message, text string, data ice.Map) {
|
||||
|
@ -41,6 +41,7 @@ func _xterm_get(m *ice.Message, h string) xterm.XTerm {
|
||||
for {
|
||||
if n, e := term.Read(buf); !m.Warn(e) && e == nil {
|
||||
if _xterm_echo(m, h, string(buf[:n])); len(text) > 0 {
|
||||
m.Debug("what %v", text[0])
|
||||
kit.If(text[0], func(cmd string) { m.Go(func() { m.Sleep30ms(); term.Writeln(cmd) }) })
|
||||
text = text[1:]
|
||||
}
|
||||
@ -175,7 +176,7 @@ func ProcessXterm(m *ice.Message, cmds, text string, arg ...string) {
|
||||
if ls := kit.Simple(kit.UnMarshal(m.Option(ctx.ARGS))); len(ls) > 0 {
|
||||
return ls
|
||||
} else {
|
||||
return []string{mdb.TYPE, cmds, mdb.NAME, kit.Select("", arg, 0), mdb.TEXT, text}
|
||||
return []string{cmds, kit.Select("", arg, 0), text}
|
||||
}
|
||||
}, arg...)
|
||||
}
|
||||
|
4
info.go
4
info.go
@ -73,7 +73,7 @@ var Info = struct {
|
||||
Stack map[string]func(m *Message, key string, arg ...Any) Any
|
||||
Inputs []func(m *Message, arg ...string)
|
||||
|
||||
PushStream func(m *Message)
|
||||
PushStream func(m *Message) *Message
|
||||
PushNotice func(m *Message, arg ...Any)
|
||||
Save func(m *Message, key ...string) *Message
|
||||
Load func(m *Message, key ...string) *Message
|
||||
@ -90,7 +90,7 @@ var Info = struct {
|
||||
render: map[string]func(*Message, ...Any) string{},
|
||||
Stack: map[string]func(m *Message, key string, arg ...Any) Any{},
|
||||
|
||||
PushStream: func(m *Message) {},
|
||||
PushStream: func(m *Message) *Message { return m },
|
||||
PushNotice: func(m *Message, arg ...Any) {},
|
||||
Save: func(m *Message, key ...string) *Message { return m },
|
||||
Load: func(m *Message, key ...string) *Message { return m },
|
||||
|
Loading…
x
Reference in New Issue
Block a user