From 8deb3d47a0c915660ae38bc27d58fbcc640679f9 Mon Sep 17 00:00:00 2001 From: shaoying Date: Fri, 9 Nov 2018 12:03:40 +0800 Subject: [PATCH] add commit.hook --- etc/init.shy | 7 +++++-- src/contexts/cli/cli.go | 6 +++--- src/contexts/cli/cli_linux.go | 1 + src/contexts/ctx/ctx.go | 3 +++ src/contexts/mdb/mdb.go | 6 +++++- src/examples/code/code.go | 9 ++++++++- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/etc/init.shy b/etc/init.shy index 640d7222..2a2dd12d 100644 --- a/etc/init.shy +++ b/etc/init.shy @@ -1,4 +1,7 @@ -source etc/local.shy - ~stdio config load var/history.json history +~code + config load var/counter.json counter + +source etc/local.shy + diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index 16122b2e..2451447c 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -885,13 +885,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", }}, "develop": &ctx.Command{Name: "develop", Help: "develop", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { m.Append("nclient", strings.Count(m.Spawn().Cmd("system", "tmux", "list-clients").Result(0), "\n")) - m.Append("nsesion", strings.Count(m.Spawn().Cmd("system", "tmux", "list-sessions").Result(0), "\n")) + m.Append("nsession", strings.Count(m.Spawn().Cmd("system", "tmux", "list-sessions").Result(0), "\n")) m.Append("nwindow", strings.Count(m.Spawn().Cmd("system", "tmux", "list-windows", "-a").Result(0), "\n")) m.Append("npane", strings.Count(m.Spawn().Cmd("system", "tmux", "list-panes", "-a").Result(0), "\n")) - m.Append("ncommand", strings.Count(m.Spawn().Cmd("system", "tmux", "list-commands").Result(0), "\n")) + m.Append("nbuf", strings.Count(m.Spawn().Cmd("system", "tmux", "list-buffers").Result(0), "\n")) + m.Append("ncmd", strings.Count(m.Spawn().Cmd("system", "tmux", "list-commands").Result(0), "\n")) m.Append("nkey", strings.Count(m.Spawn().Cmd("system", "tmux", "list-keys").Result(0), "\n")) - m.Append("nbuffer", strings.Count(m.Spawn().Cmd("system", "tmux", "list-buffers").Result(0), "\n")) m.Table() }}, diff --git a/src/contexts/cli/cli_linux.go b/src/contexts/cli/cli_linux.go index 5d1b54b9..edd34a59 100644 --- a/src/contexts/cli/cli_linux.go +++ b/src/contexts/cli/cli_linux.go @@ -5,6 +5,7 @@ import ( "fmt" "runtime" "syscall" + "time" "toolkit" ) diff --git a/src/contexts/ctx/ctx.go b/src/contexts/ctx/ctx.go index d95e4544..d45444c1 100644 --- a/src/contexts/ctx/ctx.go +++ b/src/contexts/ctx/ctx.go @@ -3371,12 +3371,15 @@ func Start(args ...string) { } if len(args) > 0 { + Pulse.Options("log", false) + cmd := Pulse.Sess("cli", false).Cmd("source", args) for _, v := range cmd.Meta["result"] { fmt.Printf("%v", v) } } else { Pulse.Options("log", true) + log := Pulse.Sess("log", false) log.target.Start(log) diff --git a/src/contexts/mdb/mdb.go b/src/contexts/mdb/mdb.go index 3737d599..667216c7 100644 --- a/src/contexts/mdb/mdb.go +++ b/src/contexts/mdb/mdb.go @@ -182,7 +182,11 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", return } - table := m.Confv("tables", arg[0]).(string) + table := arg[0] + switch v := m.Confv("tables", arg[0]).(type) { + case string: + table = v + } msg := m.Spawn().Cmd("query", fmt.Sprintf("desc %s", table)) m.Copy(msg, "append") diff --git a/src/examples/code/code.go b/src/examples/code/code.go index 106e3b13..bfd015e9 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -13,6 +13,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", "counter": &ctx.Config{Name: "counter", Value: map[string]interface{}{ "nopen": "0", "nsave": "0", }, Help: "counter"}, + "counter_service": &ctx.Config{Name: "counter_service", Value: "http://localhost:9094/code/counter", Help: "counter"}, "web_site": &ctx.Config{Name: "web_site", Value: []interface{}{ map[string]interface{}{"_name": "MDN", "site": "https://developer.mozilla.org"}, map[string]interface{}{"_name": "github", "site": "https://github.com"}, @@ -62,7 +63,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", "pre_run": true, "display_result": "", }, - map[string]interface{}{"name": "develop", "help": "develop", "template": "componet", + map[string]interface{}{"name": "counter", "help": "counter", "template": "componet", "context": "web.code", "command": "config", "arguments": []interface{}{"counter"}, "inputs": []interface{}{ map[string]interface{}{"type": "button", "label": "refresh"}, @@ -163,6 +164,12 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", count += i } m.Log("info", "%v: %v", m.Option("name"), m.Confv("counter", m.Option("name"), fmt.Sprintf("%d", count))) + m.Echo("%d", count) + } + }}, + "counter": &ctx.Command{Name: "counter name count", Help: "counter", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { + if len(arg) > 1 { + m.Copy(m.Spawn().Cmd("get", m.Conf("counter_service"), "name", arg[0], "count", arg[1]), "result") } }}, },