1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-26 01:04:06 +08:00

add commit.hook

This commit is contained in:
shaoying 2018-11-09 12:03:40 +08:00
parent d22cf113a6
commit 8deb3d47a0
6 changed files with 25 additions and 7 deletions

View File

@ -1,4 +1,7 @@
source etc/local.shy
~stdio ~stdio
config load var/history.json history config load var/history.json history
~code
config load var/counter.json counter
source etc/local.shy

View File

@ -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) { "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("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("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("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("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() m.Table()
}}, }},

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"runtime" "runtime"
"syscall" "syscall"
"time"
"toolkit" "toolkit"
) )

View File

@ -3371,12 +3371,15 @@ func Start(args ...string) {
} }
if len(args) > 0 { if len(args) > 0 {
Pulse.Options("log", false)
cmd := Pulse.Sess("cli", false).Cmd("source", args) cmd := Pulse.Sess("cli", false).Cmd("source", args)
for _, v := range cmd.Meta["result"] { for _, v := range cmd.Meta["result"] {
fmt.Printf("%v", v) fmt.Printf("%v", v)
} }
} else { } else {
Pulse.Options("log", true) Pulse.Options("log", true)
log := Pulse.Sess("log", false) log := Pulse.Sess("log", false)
log.target.Start(log) log.target.Start(log)

View File

@ -182,7 +182,11 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
return 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)) msg := m.Spawn().Cmd("query", fmt.Sprintf("desc %s", table))
m.Copy(msg, "append") m.Copy(msg, "append")

View File

@ -13,6 +13,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
"counter": &ctx.Config{Name: "counter", Value: map[string]interface{}{ "counter": &ctx.Config{Name: "counter", Value: map[string]interface{}{
"nopen": "0", "nsave": "0", "nopen": "0", "nsave": "0",
}, Help: "counter"}, }, 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{}{ "web_site": &ctx.Config{Name: "web_site", Value: []interface{}{
map[string]interface{}{"_name": "MDN", "site": "https://developer.mozilla.org"}, map[string]interface{}{"_name": "MDN", "site": "https://developer.mozilla.org"},
map[string]interface{}{"_name": "github", "site": "https://github.com"}, map[string]interface{}{"_name": "github", "site": "https://github.com"},
@ -62,7 +63,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
"pre_run": true, "pre_run": true,
"display_result": "", "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"}, "context": "web.code", "command": "config", "arguments": []interface{}{"counter"},
"inputs": []interface{}{ "inputs": []interface{}{
map[string]interface{}{"type": "button", "label": "refresh"}, map[string]interface{}{"type": "button", "label": "refresh"},
@ -163,6 +164,12 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
count += i count += i
} }
m.Log("info", "%v: %v", m.Option("name"), m.Confv("counter", m.Option("name"), fmt.Sprintf("%d", count))) 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")
} }
}}, }},
}, },