From c9b654262d375e84ef8bfda572b8cd1339c6e1ee Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 28 Jun 2018 22:31:20 +0800 Subject: [PATCH] tce pro mdb --- etc/shy.vim | 4 +++- src/contexts/ctx.go | 8 +++++++- src/contexts/mdb/mdb.go | 9 +++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/etc/shy.vim b/etc/shy.vim index b6b928f3..cf16dc7f 100644 --- a/etc/shy.vim +++ b/etc/shy.vim @@ -1,7 +1,9 @@ syn match shComment "#.*$" syn match shNumber "-\=\<\d\+\>#\=" syn match shComment "\"[^\"]*\"" -syn match shOperator "=" +syn match shOperator "=\|+\|-\|*\|/" +syn match shOperator "<\|<=\|>\|>=\|!=\|==" +syn match shOperator "\\" syn match shOperator "\~[-_a-zA-Z0-9]\+\>" syn match shShellVariables "\$[-_a-zA-Z0-9]\+\>" syn match shShellVariables "@[-_a-zA-Z0-9]\+\>" diff --git a/src/contexts/ctx.go b/src/contexts/ctx.go index 297dfc84..3dca5426 100644 --- a/src/contexts/ctx.go +++ b/src/contexts/ctx.go @@ -2359,6 +2359,12 @@ var Index = &Context{Name: "ctx", Help: "模块中心", for i := 0; i < len(ms); i++ { if ms[i].code == n { switch arg[1] { + case "ncol": + m.Echo("%d", len(ms[i].Meta["append"])) + return + case "nrow": + m.Echo("%d", len(ms[i].Meta[ms[i].Meta["append"][0]])) + return case "option", "session", "callback", "feedback": msg := ms[i].Spawn(ms[i].target) msg.Cmd(arg[1:]) @@ -2366,7 +2372,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心", return default: index := 0 - if len(arg) >= 3 { + if len(arg) > 2 { n, e := strconv.Atoi(arg[2]) m.Assert(e) index = n diff --git a/src/contexts/mdb/mdb.go b/src/contexts/mdb/mdb.go index 011b3d48..0d898250 100644 --- a/src/contexts/mdb/mdb.go +++ b/src/contexts/mdb/mdb.go @@ -240,9 +240,9 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", // }}} }}, "show": &ctx.Command{ - Name: "show table fields... [where conditions] [group fields] [order fields] [limit fields] [offset fields] [save filename]", + Name: "show table fields... [where conditions] [group fields] [order fields] [limit fields] [offset fields] [save filename] [other rest...]", Help: "查询数据库, table: 表名, fields: 字段, where: 查询条件, group: 聚合字段, order: 排序字段", - Form: map[string]int{"where": 1, "group": 1, "order": 1, "limit": 1, "offset": 1, "extras": 1, "save": 1}, + Form: map[string]int{"where": 1, "group": 1, "order": 1, "limit": 1, "offset": 1, "extras": 1, "save": 1, "other": -1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { if mdb, ok := m.Target().Server.(*MDB); m.Assert(ok) { // {{{ table := m.Confx("table", arg, 0) @@ -266,11 +266,12 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", limit := m.Confx("limit", m.Option("limit"), "limit %s") offset := m.Confx("offset", m.Option("offset"), "offset %s") - msg := m.Spawn().Cmd("query", fmt.Sprintf("select %s from %s %s %s %s %s %s", field, table, where, group, order, limit, offset)) + msg := m.Spawn().Cmd("query", fmt.Sprintf("select %s from %s %s %s %s %s %s", field, table, where, group, order, limit, offset), m.Meta["other"]) if !m.Options("save") { - m.Color(31, table).Echo(" %s %s %s %s %s\n", where, group, order, limit, offset) + m.Color(31, table).Echo(" %s %s %s %s %s %v\n", where, group, order, limit, offset, m.Meta["other"]) } + m.Optioni("query", msg.Code()) msg.Table(func(maps map[string]string, lists []string, line int) bool { for i, v := range lists { if m.Options("save") {