1
0
forked from x/icebergs

opt inner.go

This commit is contained in:
shaoying 2020-07-08 19:46:43 +08:00
parent 117b55ef8f
commit b1e015f486

View File

@ -3,6 +3,7 @@ package code
import ( import (
ice "github.com/shylinux/icebergs" ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli" "github.com/shylinux/icebergs/base/cli"
"github.com/shylinux/icebergs/base/mdb"
"github.com/shylinux/icebergs/base/web" "github.com/shylinux/icebergs/base/web"
kit "github.com/shylinux/toolkits" kit "github.com/shylinux/toolkits"
@ -127,14 +128,12 @@ func init() {
INNER: {Name: "inner", Help: "编辑器", Value: kit.Data( INNER: {Name: "inner", Help: "编辑器", Value: kit.Data(
"protect", kit.Dict("etc", "true", "var", "true", "usr", "true"), "protect", kit.Dict("etc", "true", "var", "true", "usr", "true"),
"source", kit.Dict( "source", kit.Dict(
"url", "true", "txt", "true", "url", "true",
"sh", "true", "sh", "true", "py", "true",
"sh", "true",
"py", "true",
"shy", "true", "shy", "true",
"txt", "true", "go", "true", "js", "true",
"go", "true", "c", "true", "h", "true",
"js", "true", "makefile", "true",
), ),
"plug", kit.Dict( "plug", kit.Dict(
"py", kit.Dict( "py", kit.Dict(
@ -213,6 +212,9 @@ func init() {
_inner_save(m, path.Join("./", arg[0], arg[1]), kit.Select(m.Option("content"), arg, 2)) _inner_save(m, path.Join("./", arg[0], arg[1]), kit.Select(m.Option("content"), arg, 2))
}}, }},
mdb.SEARCH: {Name: "search type name text arg...", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.SEARCH, arg)
}},
web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) { web.UPLOAD: {Name: "upload path name", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(web.CACHE, web.UPLOAD) m.Cmdy(web.CACHE, web.UPLOAD)
m.Cmdy(web.CACHE, web.WATCH, m.Option(web.DATA), path.Join(m.Option("path"), m.Option("name"))) m.Cmdy(web.CACHE, web.WATCH, m.Option(web.DATA), path.Join(m.Option("path"), m.Option("name")))
@ -220,4 +222,20 @@ func init() {
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _inner_main(m, arg...) }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _inner_main(m, arg...) }},
}, },
}, nil) }, nil)
Index.Register(&ice.Context{Name: "c", Help: "c",
Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(mdb.SEARCH, mdb.CREATE, "h", "c", c.Cap(ice.CTX_FOLLOW))
m.Cmd(mdb.SEARCH, mdb.CREATE, "c", "c", c.Cap(ice.CTX_FOLLOW))
}},
"c": {Name: "c", Help: "c", Action: map[string]*ice.Action{
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
m.Split(m.Cmdx(cli.SYSTEM, "grep", "-rn", arg[1], m.Option("_path")), "file:line:text", ":", "\n")
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
},
}, nil)
} }