forked from x/icebergs
opt inner.go
This commit is contained in:
parent
adeb461da0
commit
9650802789
@ -20,3 +20,29 @@ field "命令" web.code.sh
|
|||||||
field "脚本" web.code.shy
|
field "脚本" web.code.shy
|
||||||
field "后端" web.code.go
|
field "后端" web.code.go
|
||||||
field "前端" web.code.js
|
field "前端" web.code.js
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
inner.go
|
||||||
|
vimer.go
|
||||||
|
favor.go
|
||||||
|
bench.go
|
||||||
|
pprof.go
|
||||||
|
|
||||||
|
install.go
|
||||||
|
compile.go
|
||||||
|
autogen.go
|
||||||
|
publish.go
|
||||||
|
upgrade.go
|
||||||
|
|
||||||
|
c.go
|
||||||
|
sh.go
|
||||||
|
shy.go
|
||||||
|
go.go
|
||||||
|
js.go
|
||||||
|
|
||||||
|
code.go
|
||||||
|
code.shy
|
||||||
|
csdn.go
|
||||||
|
github.go
|
||||||
|
pack.go
|
||||||
|
@ -3,15 +3,45 @@ 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/ctx"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func _inner_ext(name string) string {
|
||||||
|
return strings.ToLower(kit.Select(path.Base(name), strings.TrimPrefix(path.Ext(name), ".")))
|
||||||
|
}
|
||||||
|
func _inner_list(m *ice.Message, ext, file, dir string, arg ...string) {
|
||||||
|
if m.Warn(!m.Right(dir, file), ice.ErrNotRight, path.Join(dir, file)) {
|
||||||
|
return // 没有权限
|
||||||
|
}
|
||||||
|
if m.Cmdy(mdb.RENDER, ext, file, dir, arg); m.Result() != "" {
|
||||||
|
return // 解析成功
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.Conf(INNER, kit.Keys(kit.META_SOURCE, ext)) == "true" {
|
||||||
|
m.Cmdy(nfs.CAT, path.Join(dir, file))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func _inner_show(m *ice.Message, ext, file, dir string, arg ...string) {
|
||||||
|
if m.Warn(!m.Right(dir, file), ice.ErrNotRight, path.Join(dir, file)) {
|
||||||
|
return // 没有权限
|
||||||
|
}
|
||||||
|
if m.Cmdy(mdb.ENGINE, ext, file, dir, arg); m.Result() != "" {
|
||||||
|
return // 执行成功
|
||||||
|
}
|
||||||
|
|
||||||
|
if ls := kit.Simple(m.Confv(INNER, kit.Keym("show", ext))); len(ls) > 0 {
|
||||||
|
m.Option(cli.CMD_DIR, dir)
|
||||||
|
m.Cmdy(cli.SYSTEM, ls, file)
|
||||||
|
m.Set(ice.MSG_APPEND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
COMMENT = "comment"
|
COMMENT = "comment"
|
||||||
KEYWORD = "keyword"
|
KEYWORD = "keyword"
|
||||||
@ -25,77 +55,39 @@ const (
|
|||||||
SUFFIX = "suffix"
|
SUFFIX = "suffix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _inner_ext(name string) string {
|
|
||||||
return strings.ToLower(kit.Select(path.Base(name), strings.TrimPrefix(path.Ext(name), ".")))
|
|
||||||
}
|
|
||||||
func _inner_list(m *ice.Message, ext, file, dir string, arg ...string) {
|
|
||||||
if strings.HasPrefix("http", dir) {
|
|
||||||
m.Cmdy(web.SPIDE, web.SPIDE_DEV, web.SPIDE_RAW, web.SPIDE_GET, dir+file)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.Warn(!m.Right(dir, file), ice.ErrNotRight, path.Join(dir, file)) {
|
|
||||||
return // 没有权限
|
|
||||||
}
|
|
||||||
if m.Cmdy(mdb.RENDER, ext, file, dir, arg); m.Result() != "" {
|
|
||||||
return // 解析成功
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.Conf(INNER, kit.Keys(kit.META_SOURCE, ext)) == "true" {
|
|
||||||
if m.Cmdy(nfs.CAT, path.Join(dir, file)); m.Result() != "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.Echo(path.Join(dir, file))
|
|
||||||
}
|
|
||||||
func _inner_show(m *ice.Message, ext, file, dir string, arg ...string) {
|
|
||||||
if m.Warn(!m.Right(dir, file), ice.ErrNotRight, path.Join(dir, file)) {
|
|
||||||
return // 没有权限
|
|
||||||
}
|
|
||||||
if m.Cmdy(mdb.ENGINE, ext, file, dir, arg); m.Result() != "" {
|
|
||||||
return // 执行成功
|
|
||||||
}
|
|
||||||
|
|
||||||
if ls := kit.Simple(m.Confv(INNER, kit.Keys("meta.show", ext))); len(ls) > 0 {
|
|
||||||
m.Cmdy(cli.SYSTEM, ls, path.Join(dir, file)).Set(ice.MSG_APPEND)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const INNER = "inner"
|
const INNER = "inner"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
INNER: {Name: "inner path=src/ file=main.go line=1 auto project searchShow", Help: "源代码", Meta: kit.Dict(
|
INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict(
|
||||||
"display", "/plugin/local/code/inner.js", "style", "editor",
|
"display", "/plugin/local/code/inner.js", "style", "editor",
|
||||||
"trans", kit.Dict("project", "项目"),
|
|
||||||
), Action: map[string]*ice.Action{
|
), Action: map[string]*ice.Action{
|
||||||
mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
|
||||||
if m.Echo(m.Conf(INNER, kit.Keys("meta.plug", arg[0]))); m.Result() == "" {
|
m.Echo(kit.Select("{}", m.Conf(INNER, kit.Keym("plug", arg[0]))))
|
||||||
m.Echo("{}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) {
|
mdb.ENGINE: {Name: "engine", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_inner_list(m, arg[0], arg[1], arg[2], arg[3:]...)
|
_inner_show(m, arg[0], arg[1], arg[2])
|
||||||
}},
|
|
||||||
mdb.ENGINE: {Name: "engine", Help: "引擎", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_inner_show(m, arg[0], arg[1], arg[2], arg[3:]...)
|
|
||||||
}},
|
}},
|
||||||
mdb.SEARCH: {Name: "search", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Name: "search", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(cli.CMD_DIR, kit.Select("src", arg, 2))
|
m.Option(cli.CMD_DIR, arg[2])
|
||||||
|
m.Option(nfs.DIR_ROOT, arg[2])
|
||||||
m.Cmdy(mdb.SEARCH, arg[:2], "file,line,text")
|
m.Cmdy(mdb.SEARCH, arg[:2], "file,line,text")
|
||||||
}},
|
}},
|
||||||
|
|
||||||
FAVOR: {Name: "favor insert", Help: "收藏"},
|
FAVOR: {Name: "favor", Help: "收藏"},
|
||||||
mdb.INPUTS: {Name: "favor inputs", Help: "补全"},
|
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||||
nfs.DIR: {Name: "dir", Help: "目录"},
|
if arg[0] == "run" {
|
||||||
|
if arg = kit.Split(strings.Join(arg[1:], " ")); !m.Warn(!m.Right(arg)) {
|
||||||
"searchShow": {Name: "searchShow", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
if m.Cmdy(arg); len(m.Appendv(ice.MSG_APPEND)) == 0 && len(m.Resultv()) == 0 {
|
||||||
}},
|
m.Cmdy(cli.SYSTEM, arg)
|
||||||
"project": {Name: "project", Help: "项目", Hand: func(m *ice.Message, arg ...string) {
|
}
|
||||||
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0))
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Cmdy(ctx.COMMAND, arg[0])
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) < 2 {
|
if len(arg) < 2 {
|
||||||
@ -109,15 +101,14 @@ func init() {
|
|||||||
INNER: {Name: "inner", Help: "源代码", Value: kit.Data(
|
INNER: {Name: "inner", Help: "源代码", Value: kit.Data(
|
||||||
"source", kit.Dict(
|
"source", kit.Dict(
|
||||||
"s", "true", "S", "true",
|
"s", "true", "S", "true",
|
||||||
"license", "true", "makefile", "true",
|
|
||||||
"shy", "true", "py", "true",
|
"shy", "true", "py", "true",
|
||||||
"csv", "true", "json", "true",
|
"csv", "true", "json", "true",
|
||||||
"css", "true", "html", "true",
|
"css", "true", "html", "true",
|
||||||
"txt", "true", "url", "true",
|
"txt", "true", "url", "true",
|
||||||
"log", "true", "err", "true",
|
"log", "true", "err", "true",
|
||||||
|
|
||||||
"md", "true", "conf", "true", "toml", "true",
|
"md", "true", "license", "true", "makefile", "true",
|
||||||
"ini", "true",
|
"ini", "true", "conf", "true", "toml", "true",
|
||||||
),
|
),
|
||||||
"plug", kit.Dict(
|
"plug", kit.Dict(
|
||||||
"s", kit.Dict(
|
"s", kit.Dict(
|
||||||
@ -131,22 +122,10 @@ func init() {
|
|||||||
PREFIX, kit.Dict("//", COMMENT),
|
PREFIX, kit.Dict("//", COMMENT),
|
||||||
KEYWORD, kit.Dict(),
|
KEYWORD, kit.Dict(),
|
||||||
),
|
),
|
||||||
"makefile", kit.Dict(
|
|
||||||
PREFIX, kit.Dict("#", COMMENT),
|
|
||||||
SUFFIX, kit.Dict(":", COMMENT),
|
|
||||||
KEYWORD, kit.Dict(
|
|
||||||
"ifeq", KEYWORD,
|
|
||||||
"ifneq", KEYWORD,
|
|
||||||
"else", KEYWORD,
|
|
||||||
"endif", KEYWORD,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
"py", kit.Dict(
|
"py", kit.Dict(
|
||||||
PREFIX, kit.Dict("#", COMMENT),
|
PREFIX, kit.Dict("#", COMMENT),
|
||||||
KEYWORD, kit.Dict("print", KEYWORD),
|
KEYWORD, kit.Dict("print", KEYWORD),
|
||||||
),
|
),
|
||||||
"csv", kit.Dict("display", true),
|
|
||||||
"json", kit.Dict("link", true),
|
|
||||||
"html", kit.Dict(
|
"html", kit.Dict(
|
||||||
SPLIT, kit.Dict(
|
SPLIT, kit.Dict(
|
||||||
"space", " ",
|
"space", " ",
|
||||||
@ -162,6 +141,16 @@ func init() {
|
|||||||
),
|
),
|
||||||
|
|
||||||
"md", kit.Dict(),
|
"md", kit.Dict(),
|
||||||
|
"makefile", kit.Dict(
|
||||||
|
PREFIX, kit.Dict("#", COMMENT),
|
||||||
|
SUFFIX, kit.Dict(":", COMMENT),
|
||||||
|
KEYWORD, kit.Dict(
|
||||||
|
"ifeq", KEYWORD,
|
||||||
|
"ifneq", KEYWORD,
|
||||||
|
"else", KEYWORD,
|
||||||
|
"endif", KEYWORD,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
"show", kit.Dict(
|
"show", kit.Dict(
|
||||||
"py", []string{"python"},
|
"py", []string{"python"},
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package code
|
package code
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
|
||||||
"github.com/shylinux/icebergs/base/ctx"
|
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
@ -15,27 +11,13 @@ import (
|
|||||||
const VIMER = "vimer"
|
const VIMER = "vimer"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
Commands: map[string]*ice.Command{
|
VIMER: {Name: "vimer path=src/ file=main.go line=1 刷新:button=auto save", Help: "编辑器", Meta: kit.Dict(
|
||||||
VIMER: {Name: "vimer path=src/ file=main.go line=1 刷新:button=auto save project searchShow", Help: "编辑器", Meta: kit.Dict(
|
|
||||||
"display", "/plugin/local/code/vimer.js", "style", "editor",
|
"display", "/plugin/local/code/vimer.js", "style", "editor",
|
||||||
"trans", kit.Dict("display", "运行", "project", "项目", "search", "搜索"),
|
|
||||||
), Action: map[string]*ice.Action{
|
), Action: map[string]*ice.Action{
|
||||||
"searchShow": {Name: "searchShow", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
}},
|
|
||||||
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) {
|
||||||
m.Cmdy(nfs.SAVE, path.Join(m.Option(kit.MDB_PATH), m.Option(kit.MDB_FILE)))
|
m.Cmdy(nfs.SAVE, path.Join(m.Option(kit.MDB_PATH), m.Option(kit.MDB_FILE)))
|
||||||
}},
|
}},
|
||||||
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Cmdy(INNER, arg) }},
|
||||||
if arg = kit.Split(strings.Join(arg, " ")); !m.Warn(!m.Right(arg)) {
|
}})
|
||||||
if m.Cmdy(arg); len(m.Appendv(ice.MSG_APPEND)) == 0 && len(m.Resultv()) == 0 {
|
|
||||||
m.Cmdy(cli.SYSTEM, arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Cmdy(INNER, arg)
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
6
init.go
6
init.go
@ -95,9 +95,9 @@ var Index = &Context{Name: "ice", Help: "冰山模块",
|
|||||||
"^_^ 欢迎使用冰山框架 ^_^",
|
"^_^ 欢迎使用冰山框架 ^_^",
|
||||||
"^_^ Welcome to Icebergs World ^_^",
|
"^_^ Welcome to Icebergs World ^_^",
|
||||||
"",
|
"",
|
||||||
"Report: shylinuxc@gmail.com",
|
"report: shylinuxc@gmail.com",
|
||||||
"Public: https://shylinux.com",
|
"server: https://shylinux.com",
|
||||||
"Source: https://github.com/shylinux/icebergs",
|
"source: https://github.com/shylinux/icebergs",
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user