mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
tce add mdb.show.save_format
This commit is contained in:
parent
0b446010cf
commit
60199e8e49
@ -99,6 +99,7 @@ func (cli *CLI) Start(m *ctx.Message, arg ...string) bool { // {{{
|
||||
yac.Cmd("train", "num", "num", "mul{", "0", "-?[1-9][0-9]*", "0[0-9]+", "0x[0-9]+", "}")
|
||||
yac.Cmd("train", "str", "str", "mul{", "\"[^\"]*\"", "'[^']*'", "}")
|
||||
yac.Cmd("train", "tran", "tran", "mul{", "@", "$", "}", "opt{", "[a-zA-Z0-9_]+", "}")
|
||||
yac.Cmd("train", "tran", "tran", "$", "(", "cache", ")")
|
||||
|
||||
yac.Cmd("train", "op1", "op1", "mul{", "$", "@", "}")
|
||||
yac.Cmd("train", "op1", "op1", "mul{", "-z", "-n", "}")
|
||||
@ -317,9 +318,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
|
||||
if len(arg) > 0 {
|
||||
if i, e := strconv.Atoi(arg[0]); e == nil {
|
||||
m.Option("time_format", m.Conf("time_format"))
|
||||
t = time.Unix(int64(i/m.Confi("time_unit")), 0)
|
||||
arg = arg[1:]
|
||||
m.Option("time_format", m.Conf("time_format"))
|
||||
} else if n, e := time.ParseInLocation(m.Confx("time_format"), arg[0], time.Local); e == nil {
|
||||
m.Option("parse", arg[0])
|
||||
arg = arg[1:]
|
||||
t = n
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,7 +385,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
// }}}
|
||||
}},
|
||||
"echo": &ctx.Command{Name: "echo arg...", Help: "函数调用, name: 函数名, arg: 参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
m.Echo("%s", strings.Join(arg[1:], ""))
|
||||
m.Echo("%s", strings.Join(arg, ""))
|
||||
}},
|
||||
|
||||
"tran": &ctx.Command{Name: "tran word", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
|
@ -240,7 +240,10 @@ 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] [other rest...]",
|
||||
Help: "查询数据库, table: 表名, fields: 字段, where: 查询条件, group: 聚合字段, order: 排序字段",
|
||||
Form: map[string]int{"where": 1, "group": 1, "order": 1, "limit": 1, "offset": 1, "extras": 1, "extra_format": 1, "trans_field": 1, "trans_map": 2, "save": 1, "export": 1, "other": -1},
|
||||
Form: map[string]int{
|
||||
"where": 1, "group": 1, "order": 1, "limit": 1, "offset": 1,
|
||||
"extras": 1, "extra_format": 1, "trans_field": 1, "trans_map": 2,
|
||||
"save": 1, "save_format": 1, "csv_col_sep": 1, "export": 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)
|
||||
@ -283,7 +286,15 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
||||
}
|
||||
|
||||
m.Table(func(maps map[string]string, lists []string, line int) bool {
|
||||
args := []interface{}{}
|
||||
|
||||
for i, v := range lists {
|
||||
if m.Options("save_format") {
|
||||
key := m.Meta["append"][i]
|
||||
value := maps[key]
|
||||
args = append(args, value)
|
||||
continue
|
||||
}
|
||||
if m.Options("save") {
|
||||
key := m.Meta["append"][i]
|
||||
value := maps[key]
|
||||
@ -303,10 +314,17 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
||||
m.Echo(v)
|
||||
}
|
||||
if i < len(lists)-1 {
|
||||
m.Echo(m.Conf("csv_col_sep"))
|
||||
m.Echo(m.Confx("csv_col_sep"))
|
||||
}
|
||||
}
|
||||
m.Echo(m.Conf("csv_row_sep"))
|
||||
if m.Options("save_format") {
|
||||
if line > -1 {
|
||||
m.Echo(fmt.Sprintf(m.Option("save_format"), args...))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
m.Echo(m.Confx("csv_row_sep"))
|
||||
return true
|
||||
})
|
||||
|
||||
|
@ -186,7 +186,9 @@ func (yac *YAC) train(m *ctx.Message, page, hash int, word []string) (int, []*Po
|
||||
|
||||
// }}}
|
||||
func (yac *YAC) parse(m *ctx.Message, out *ctx.Message, page int, void int, line string, level int) (string, []string) { // {{{
|
||||
// m.Log("debug", nil, "%s\\%d %s(%d): %s", m.Conf("label")[0:level], level, yac.name(page), page, line)
|
||||
if m.Confs("debug") {
|
||||
m.Log("debug", nil, "%s\\%d %s(%d): %s", m.Conf("label")[0:level], level, yac.name(page), page, line)
|
||||
}
|
||||
|
||||
hash, word := 0, []string{}
|
||||
for star, s := 0, page; s != 0 && len(line) > 0; {
|
||||
@ -249,7 +251,10 @@ func (yac *YAC) parse(m *ctx.Message, out *ctx.Message, page int, void int, line
|
||||
}
|
||||
}
|
||||
|
||||
// m.Log("debug", nil, "%s/%d %s(%d): %v", m.Conf("label")[0:level], level, yac.name(page), page, word)
|
||||
if m.Confs("debug") {
|
||||
m.Log("debug", nil, "%s/%d %s(%d): %v", m.Conf("label")[0:level], level, yac.name(page), page, word)
|
||||
}
|
||||
|
||||
return line, word
|
||||
}
|
||||
|
||||
@ -368,6 +373,7 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
||||
"nparse": &ctx.Cache{Name: "nparse", Value: "0", Help: "解析器数量"},
|
||||
},
|
||||
Configs: map[string]*ctx.Config{
|
||||
"debug": &ctx.Config{Name: "debug", Value: "true", Help: "词法集合的最大数量"},
|
||||
"ncell": &ctx.Config{Name: "词法上限", Value: "128", Help: "词法集合的最大数量"},
|
||||
"nlang": &ctx.Config{Name: "语法上限", Value: "32", Help: "语法集合的最大数量"},
|
||||
"label": &ctx.Config{Name: "嵌套标记", Value: "####################", Help: "嵌套层级日志的标记"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user