From 5a8f9566d9a012823ce6a243211c8dc00d253ee3 Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 31 Jul 2018 22:20:44 +0800 Subject: [PATCH] tce add something --- Makefile | 2 +- src/contexts/cli/cli.go | 17 +++++++++-------- src/contexts/ctx.go | 2 +- src/contexts/mdb/mdb.go | 6 ++---- src/contexts/nfs/nfs.go | 40 +++++++++++++++++++++------------------- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index c97086a5..45f79a31 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ install: @cp etc/shy.vim ~/.vim/syntax/ @touch etc/local.shy go install $(BENCH) - @[ `uname` = "Darwin" ] && md5 `which bench` + # @[ `uname` = "Darwin" ] && md5 `which bench` @date build: diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index c6294efc..57432dcf 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -138,6 +138,12 @@ func (cli *CLI) Start(m *ctx.Message, arg ...string) bool { // {{{ m.Options("scan_end", false) m.Optionv("ps_target", cli.target) m.Option("prompt", m.Conf("prompt")) + m.Options("init.shy", false) + if arg[1] == "stdio" { + if _, e := os.Stat(m.Conf("init.shy")); e == nil { + m.Options("init.shy", true) + } + } m.Cap("stream", m.Spawn(yac.Target()).Call(func(cmd *ctx.Message) *ctx.Message { if !m.Caps("parse") { switch cmd.Detail(0) { @@ -161,14 +167,9 @@ func (cli *CLI) Start(m *ctx.Message, arg ...string) bool { // {{{ return nil }, "parse", arg[1]).Target().Name) - if arg[1] == "stdio" { - if _, e := os.Stat(m.Conf("init.shy")); e == nil { - msg := m.Spawn().Cmd("source", m.Conf("init.shy")) - msg.Result(0, msg.Meta["return"]) - } else { - m.Spawn().Cmd("alias", "import", "nfs") - m.Spawn().Cmd("login", "root", "root") - } + if m.Options("init.shy") { + msg := m.Spawn().Cmd("source", m.Conf("init.shy")) + msg.Result(0, msg.Meta["return"]) } return false } diff --git a/src/contexts/ctx.go b/src/contexts/ctx.go index 03d01b25..7243560d 100644 --- a/src/contexts/ctx.go +++ b/src/contexts/ctx.go @@ -2887,5 +2887,5 @@ func Start(args ...string) { log.target.Start(log) Pulse.Options("terminal_color", true) - Pulse.Sess("cli", false).Cmd("source", "stdio", "async").Wait() + Pulse.Sess("cli", false).Cmd("source", "stdio").Wait() } diff --git a/src/contexts/mdb/mdb.go b/src/contexts/mdb/mdb.go index 3929e266..3a754155 100644 --- a/src/contexts/mdb/mdb.go +++ b/src/contexts/mdb/mdb.go @@ -239,7 +239,7 @@ 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_field": 1, "extra_format": 1, "trans_field": 1, "trans_map": 2, "save": 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) @@ -249,9 +249,7 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", fields := []string{"*"} if len(arg) > 1 { - if fields = arg[1:]; m.Options("extras") { - fields = append(fields, "extra") - } + fields = arg[1:] } else if m.Confs("field") { fields = []string{m.Conf("field")} } diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index 88afd5f9..c875829b 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -598,26 +598,28 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool { // {{{ nfs.Cap("termbox", "true") nfs.Conf("color", "true") } + if !m.Options("init.shy") { - for _, v := range []string{ - // "say you are so pretty", - "context web serve ./ :9094", - } { - m.Back(m.Spawn(m.Source()).Set("detail", v)) - } - for _, v := range []string{ - "say you are so pretty", - "context web brow 'http://localhost:9094'", - } { - nfs.history = append(nfs.history, v) - m.Capi("nline", 1) - } - for _, v := range []string{ - "say you are so pretty\n", - "your can brow 'http://localhost:9094'\n", - "press \"brow\" then press Enter\n", - } { - nfs.print(fmt.Sprintf(v)) + for _, v := range []string{ + // "say you are so pretty", + "context web serve ./ :9094", + } { + m.Back(m.Spawn(m.Source()).Set("detail", v)) + } + for _, v := range []string{ + "say you are so pretty", + "context web brow 'http://localhost:9094'", + } { + nfs.history = append(nfs.history, v) + m.Capi("nline", 1) + } + for _, v := range []string{ + "say you are so pretty\n", + "your can brow 'http://localhost:9094'\n", + "press \"brow\" then press Enter\n", + } { + nfs.print(fmt.Sprintf(v)) + } } }