forked from x/ContextOS
tce add mdb.show
This commit is contained in:
parent
590466c835
commit
a599d1f39b
@ -11,9 +11,9 @@ syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd r
|
||||
syn keyword shStatement source return function
|
||||
syn keyword shStatement if else elif end for
|
||||
syn keyword shStatement let var
|
||||
syn keyword shStatement cache
|
||||
syn keyword shStatement config
|
||||
|
||||
syn keyword shCommand cache
|
||||
syn keyword shCommand config
|
||||
syn keyword shCommand command
|
||||
syn keyword shCommand open
|
||||
syn keyword shCommand cookie
|
||||
|
@ -2066,6 +2066,8 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
|
||||
"cert": &Config{Name: "证书文件", Value: "etc/cert.pem", Help: "证书文件"},
|
||||
"key": &Config{Name: "私钥文件", Value: "etc/key.pem", Help: "私钥文件"},
|
||||
|
||||
"command_list_base": &Config{Name: "命令列表的起始位置", Value: "0", Help: "命令列表的起始位置"},
|
||||
},
|
||||
Commands: map[string]*Command{
|
||||
"help": &Command{Name: "help topic", Help: "帮助", Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||
@ -2544,7 +2546,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
m.Capi("part", 1)
|
||||
return
|
||||
case "list":
|
||||
begin, end := 0, m.Capi("part")
|
||||
begin, end := m.Confi("command_list_base"), m.Capi("part")
|
||||
if len(arg) > 1 {
|
||||
n, e := strconv.Atoi(arg[1])
|
||||
m.Assert(e)
|
||||
@ -2580,8 +2582,8 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
msg := m.Spawn(m.Target())
|
||||
msg.Cmd(key)
|
||||
if m.Options("condition") {
|
||||
condition := m.Meta["condition"]
|
||||
done := true
|
||||
condition := m.Meta["condition"]
|
||||
for j := 0; j < len(condition)-1; j += 2 {
|
||||
if !msg.Has(condition[j]) || msg.Append(condition[j]) != condition[j+1] {
|
||||
m.Echo("\033[31m%s %s %s\033[0m\n", key, " fail", c.Name)
|
||||
@ -2594,6 +2596,12 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
m.Echo("%s %s %s\n", key, " done", c.Name)
|
||||
success++
|
||||
}
|
||||
} else {
|
||||
for _, v := range msg.Meta["result"] {
|
||||
m.Echo("%v", v)
|
||||
}
|
||||
m.Echo("\n")
|
||||
success++
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2767,14 +2775,14 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
m.Cap(arg[0], "")
|
||||
}
|
||||
|
||||
if m.source == m.source.master {
|
||||
m.source, m.target = m.target, m.source
|
||||
}
|
||||
// if m.source == m.source.master {
|
||||
// m.source, m.target = m.target, m.source
|
||||
// }
|
||||
m.Echo("%s", m.Cap(arg[0]))
|
||||
case 2:
|
||||
if m.source == m.source.master {
|
||||
m.source, m.target = m.target, m.source
|
||||
}
|
||||
// if m.source == m.source.master {
|
||||
// m.source, m.target = m.target, m.source
|
||||
// }
|
||||
m.Cap(arg[0], arg[1])
|
||||
case 3:
|
||||
if m.source == m.source.master {
|
||||
|
@ -215,8 +215,7 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
||||
"get": &ctx.Command{Name: "get [where str] [parse str] [table [field]]", Help: "执行查询语句",
|
||||
Formats: map[string]int{"where": 1, "parse": 1},
|
||||
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
|
||||
where := m.Conf("where")
|
||||
where := m.Conf("where") // {{{
|
||||
if m.Options("where") {
|
||||
where = m.Option("where")
|
||||
}
|
||||
@ -254,23 +253,31 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
||||
m.Echo("%v", row[field])
|
||||
}
|
||||
return false
|
||||
})
|
||||
}) // }}}
|
||||
}},
|
||||
"show": &ctx.Command{Name: "show table field [where condition]", Help: "执行查询语句",
|
||||
Formats: map[string]int{"where": 1},
|
||||
"show": &ctx.Command{Name: "show table field [where conditions]|[group fields]|[order fields]", Help: "执行查询语句",
|
||||
Formats: map[string]int{"where": 1, "group": 1, "order": 1},
|
||||
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
msg := m.Spawn(m.Target())
|
||||
msg := m.Spawn(m.Target()) // {{{
|
||||
|
||||
fields := strings.Join(arg[1:], ",")
|
||||
condition := ""
|
||||
if m.Options("where") {
|
||||
condition = fmt.Sprintf("where %s", m.Option("where"))
|
||||
}
|
||||
group := ""
|
||||
if m.Options("group") {
|
||||
group = fmt.Sprintf("group by %s", m.Option("group"))
|
||||
}
|
||||
order := ""
|
||||
if m.Options("order") {
|
||||
order = fmt.Sprintf("order by %s", m.Option("order"))
|
||||
}
|
||||
|
||||
msg.Cmd("query", fmt.Sprintf("select %s from %s %s", fields, arg[0], condition))
|
||||
m.Echo("%s %s\n", arg[0], condition)
|
||||
msg.Cmd("query", fmt.Sprintf("select %s from %s %s %s %s", fields, arg[0], condition, group, order))
|
||||
m.Echo("\033[31m%s\033[0m %s %s %s\n", arg[0], condition, group, order)
|
||||
for _, k := range msg.Meta["append"] {
|
||||
m.Echo("%s\t", k)
|
||||
m.Echo("\033[32m%s\033[0m\t", k)
|
||||
}
|
||||
m.Echo("\n")
|
||||
for i := 0; i < len(msg.Meta[msg.Meta["append"][0]]); i++ {
|
||||
@ -279,6 +286,7 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
||||
}
|
||||
m.Echo("\n")
|
||||
}
|
||||
// }}}
|
||||
}},
|
||||
"list": &ctx.Command{Name: "list add table field [where condition]", Help: "执行查询语句",
|
||||
Formats: map[string]int{"where": 1},
|
||||
|
@ -87,7 +87,17 @@ func (web *WEB) generate(m *ctx.Message, uri string, arg ...string) string { //
|
||||
|
||||
args := []string{}
|
||||
for i := 0; i < len(arg)-1; i += 2 {
|
||||
args = append(args, arg[i]+"="+url.QueryEscape(arg[i+1]))
|
||||
value := arg[i+1]
|
||||
if len(arg[i+1]) > 1 {
|
||||
switch arg[i+1][0] {
|
||||
case '$':
|
||||
value = m.Cap(arg[i+1][1:])
|
||||
case '@':
|
||||
value = m.Conf(arg[i+1][1:])
|
||||
}
|
||||
}
|
||||
|
||||
args = append(args, arg[i]+"="+url.QueryEscape(value))
|
||||
}
|
||||
p := strings.Join(args, "&")
|
||||
|
||||
@ -423,7 +433,16 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
|
||||
io.Copy(part, file)
|
||||
for i := 0; i < len(arg)-1; i += 2 {
|
||||
writer.WriteField(arg[i], arg[i])
|
||||
value := arg[i+1]
|
||||
if len(arg[i+1]) > 1 {
|
||||
switch arg[i+1][0] {
|
||||
case '$':
|
||||
value = m.Cap(arg[i+1][1:])
|
||||
case '@':
|
||||
value = m.Conf(arg[i+1][1:])
|
||||
}
|
||||
}
|
||||
writer.WriteField(arg[i], value)
|
||||
}
|
||||
|
||||
contenttype = writer.FormDataContentType()
|
||||
|
Loading…
x
Reference in New Issue
Block a user