1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
This commit is contained in:
harveyshao 2021-06-12 18:30:10 +08:00
parent e0ff004a87
commit 56e9ae881a
5 changed files with 59 additions and 76 deletions

View File

@ -83,6 +83,7 @@ func init() {
"go", "true", "vim", "true", "js", "true",
"conf", "true", "json", "true",
"makefile", "true",
"yml", "true",
),
)},
},

View File

@ -1,17 +1,17 @@
package code
import (
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli"
"github.com/shylinux/icebergs/base/mdb"
"github.com/shylinux/icebergs/base/nfs"
kit "github.com/shylinux/toolkits"
"bufio"
"os"
"path"
"strings"
"time"
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli"
"github.com/shylinux/icebergs/base/mdb"
"github.com/shylinux/icebergs/base/nfs"
kit "github.com/shylinux/toolkits"
)
func _go_find(m *ice.Message, key string) {
@ -87,6 +87,7 @@ func init() {
m.Cmd(mdb.PLUGIN, mdb.CREATE, k, m.Prefix(k))
m.Cmd(mdb.RENDER, mdb.CREATE, k, m.Prefix(k))
}
LoadPlug(m, GO)
}},
SUM: {Name: SUM, Help: "版本", Action: map[string]*ice.Action{
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) {
@ -154,18 +155,15 @@ func init() {
PREFIX, kit.Dict(
"//", COMMENT,
),
KEYWORD, kit.Dict(
"syntax", KEYWORD,
"package", KEYWORD,
"import", KEYWORD,
"option", KEYWORD,
"service", KEYWORD,
"message", KEYWORD,
"string", DATATYPE,
"int64", DATATYPE,
"int32", DATATYPE,
"_keyword", kit.Dict(
KEYWORD, kit.Simple(
"syntax", "option", "package", "import", "service", "message",
),
DATATYPE, kit.Simple(
"string", "int64", "int32",
),
),
KEYWORD, kit.Dict(),
),
)},
MOD: {Name: MOD, Help: "模块", Value: kit.Data(
@ -173,12 +171,12 @@ func init() {
PREFIX, kit.Dict(
"//", COMMENT,
),
KEYWORD, kit.Dict(
"module", KEYWORD,
"require", KEYWORD,
"replace", KEYWORD,
"=>", KEYWORD,
"_keyword", kit.Dict(
KEYWORD, kit.Simple(
"module", "require", "replace", "=>",
),
),
KEYWORD, kit.Dict(),
),
)},
GO: {Name: GO, Help: "后端", Value: kit.Data(
@ -190,59 +188,27 @@ func init() {
PREFIX, kit.Dict(
"//", COMMENT,
"/*", COMMENT,
"*", COMMENT,
"* ", COMMENT,
),
KEYWORD, kit.Dict(
"package", KEYWORD,
"import", KEYWORD,
"const", KEYWORD,
"func", KEYWORD,
"var", KEYWORD,
"type", KEYWORD,
"struct", KEYWORD,
"interface", KEYWORD,
"if", KEYWORD,
"else", KEYWORD,
"for", KEYWORD,
"range", KEYWORD,
"break", KEYWORD,
"continue", KEYWORD,
"switch", KEYWORD,
"case", KEYWORD,
"default", KEYWORD,
"fallthrough", KEYWORD,
"go", KEYWORD,
"select", KEYWORD,
"return", KEYWORD,
"defer", KEYWORD,
"map", DATATYPE,
"chan", DATATYPE,
"string", DATATYPE,
"error", DATATYPE,
"bool", DATATYPE,
"byte", DATATYPE,
"int", DATATYPE,
"int64", DATATYPE,
"float64", DATATYPE,
"len", FUNCTION,
"cap", FUNCTION,
"copy", FUNCTION,
"append", FUNCTION,
"msg", FUNCTION,
"m", FUNCTION,
"false", STRING,
"true", STRING,
"nil", STRING,
"-1", STRING,
"0", STRING,
"1", STRING,
"2", STRING,
"_keyword", 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",
),
DATATYPE, kit.Simple(
"int", "int32", "int64", "float64",
"string", "byte", "bool", "error", "chan", "map",
),
FUNCTION, kit.Simple(
"len", "cap", "copy", "append", "msg", "m",
),
STRING, kit.Simple(
"false", "true", "nil", "-1", "0", "1", "2",
),
),
KEYWORD, kit.Dict(),
),
)},
},

View File

@ -41,6 +41,13 @@ func _inner_show(m *ice.Message, ext, file, dir string, arg ...string) {
m.Set(ice.MSG_APPEND)
}
}
func LoadPlug(m *ice.Message, language string) {
m.Confm(language, kit.Keym(PLUG, "_keyword"), func(key string, value interface{}) {
for _, v := range kit.Simple(value) {
m.Conf(language, kit.Keym(PLUG, KEYWORD, v), key)
}
})
}
const (
COMMENT = "comment"
@ -102,9 +109,11 @@ func init() {
"css", "true", "html", "true",
"txt", "true", "url", "true",
"log", "true", "err", "true",
"yml", "true",
"md", "true", "license", "true", "makefile", "true",
"ini", "true", "conf", "true", "toml", "true", "yaml", "true",
"sql", "true",
),
"plug", kit.Dict(
"s", kit.Dict(
@ -138,6 +147,9 @@ func init() {
"yaml", kit.Dict(
PREFIX, kit.Dict("#", COMMENT),
),
"yml", kit.Dict(
PREFIX, kit.Dict("#", COMMENT),
),
"md", kit.Dict(),
"makefile", kit.Dict(

View File

@ -247,6 +247,7 @@ func (m *Message) SortTime(key string) { m.Sort(key, "time") }
func (m *Message) SortTimeR(key string) { m.Sort(key, "time_r") }
func (m *Message) FormatMeta() string { return m.Format("meta") }
func (m *Message) FormatSize() string { return m.Format("size") }
func (m *Message) RenameAppend(from, to string) {
for i, v := range m.meta[MSG_APPEND] {
if v == from {

View File

@ -140,6 +140,9 @@ func (c *Context) Server() Server {
}
func (c *Context) Register(s *Context, x Server, name ...string) *Context {
if s.Name == "" {
s.Name = kit.Split(kit.Split(kit.FileLine(2, 3), ":")[0], "/")[1]
}
for _, n := range name {
Name(n, s)
}
@ -388,7 +391,7 @@ func (m *Message) Format(key interface{}) string {
case string:
switch key {
case "cost":
return kit.FmtTime(kit.Int64(time.Now().Sub(m.time)))
return kit.FmtTime(kit.Int64(time.Since(m.time)))
case "meta":
return kit.Format(m.meta)
case "size":
@ -695,7 +698,7 @@ func (m *Message) cmd(arg ...interface{}) *Message {
// 解析命令
list := kit.Simple(args...)
if len(list) == 0 && m.Hand == false {
if len(list) == 0 && !m.Hand {
list = m.meta[MSG_DETAIL]
}
if len(list) == 0 {
@ -728,7 +731,7 @@ func (m *Message) cmd(arg ...interface{}) *Message {
}
// 系统命令
if m.Warn(m.Hand == false, ErrNotFound, list) {
if m.Warn(!m.Hand, ErrNotFound, list) {
return m.Set(MSG_RESULT).Cmd("cli.system", list)
}
return m