forked from x/ContextOS
opt some
This commit is contained in:
parent
d868dacd3a
commit
4c3223f63f
@ -624,9 +624,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
format := kit.Select(m.Conf("time", "format"), m.Option("time_format"))
|
format := kit.Select(m.Conf("time", "format"), m.Option("time_format"))
|
||||||
t, stamp := time.Now(), true
|
t, stamp := time.Now(), true
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
if arg[0] == "show" {
|
if i, e := strconv.ParseInt(arg[0], 10, 64); e == nil {
|
||||||
stamp = false
|
|
||||||
} else if i, e := strconv.ParseInt(arg[0], 10, 64); e == nil {
|
|
||||||
t, stamp, arg = time.Unix(int64(i/int64(m.Confi("time", "unit"))), 0), false, arg[1:]
|
t, stamp, arg = time.Unix(int64(i/int64(m.Confi("time", "unit"))), 0), false, arg[1:]
|
||||||
} else if n, e := time.ParseInLocation(format, arg[0], time.Local); e == nil {
|
} else if n, e := time.ParseInLocation(format, arg[0], time.Local); e == nil {
|
||||||
t, arg = n, arg[1:]
|
t, arg = n, arg[1:]
|
||||||
@ -708,8 +706,8 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"proc": &ctx.Command{Name: "proc", Help: "进程管理", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"proc": &ctx.Command{Name: "proc", Help: "进程管理", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
m.Cmdy("cli.system", "ps", kit.Select("ax", arg, 0), "cmd_parse", "cut")
|
m.Cmdy("cli.system", "cmd_parse", "cut", "ps", kit.Select("ax", arg, 0))
|
||||||
if len(arg) > 1 {
|
if len(arg) > 0 {
|
||||||
m.Cmd("select", "reg", "COMMAND", arg[1])
|
m.Cmd("select", "reg", "COMMAND", arg[1])
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -758,13 +756,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
[]string{"stash"}, []string{"pull"}, []string{"stash", "pop"},
|
[]string{"stash"}, []string{"pull"}, []string{"stash", "pop"},
|
||||||
})
|
})
|
||||||
|
|
||||||
// 更新依赖
|
|
||||||
list := [][]string{}
|
|
||||||
m.Confm("compile", "dep", func(index int, value string) {
|
|
||||||
list = append(list, []string{value})
|
|
||||||
})
|
|
||||||
m.Cmdp(0, []string{"go build"}, []string{"cli.system", "go", "get"}, list)
|
|
||||||
|
|
||||||
// 代码状态
|
// 代码状态
|
||||||
m.Cmdy("cli.system", "git", "status", "-sb", "cmd_parse", "cut")
|
m.Cmdy("cli.system", "git", "status", "-sb", "cmd_parse", "cut")
|
||||||
return e
|
return e
|
||||||
@ -776,13 +767,16 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
[]string{"stash"}, []string{"pull"}, []string{"checkout", "-f", "master"}, []string{"stash", "pop"},
|
[]string{"stash"}, []string{"pull"}, []string{"checkout", "-f", "master"}, []string{"stash", "pop"},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 下载依赖
|
||||||
|
list := [][]string{}
|
||||||
|
m.Confm("compile", "dep", func(index int, value string) {
|
||||||
|
list = append(list, []string{value})
|
||||||
|
})
|
||||||
|
m.Cmdp(0, []string{"go build"}, []string{"cli.system", "go", "get"}, list)
|
||||||
|
|
||||||
case "stat":
|
case "stat":
|
||||||
// 代码统计
|
// 代码统计
|
||||||
m.Cmdy("nfs.dir", kit.Select("src", arg, 1), "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r")
|
m.Cmdy("nfs.dir", "src", "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r")
|
||||||
|
|
||||||
case "stats":
|
|
||||||
// 代码统计
|
|
||||||
m.Cmdy("nfs.dir", kit.Select("src", arg, 1), "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r", "dir_select", "group", "")
|
|
||||||
|
|
||||||
case "trend":
|
case "trend":
|
||||||
// 提交记录
|
// 提交记录
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-08-31 02:08:47", "mac", 497,
|
"2019-09-02 20:11:08", "centos", 489,
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,7 @@ var Index = &ctx.Context{Name: "log", Help: "日志中心",
|
|||||||
"meta": map[string]interface{}{
|
"meta": map[string]interface{}{
|
||||||
"short": []interface{}{"time", "ship"},
|
"short": []interface{}{"time", "ship"},
|
||||||
"long": []interface{}{"time", "ship"},
|
"long": []interface{}{"time", "ship"},
|
||||||
|
"cost": []interface{}{"time", "ship", "cost"},
|
||||||
},
|
},
|
||||||
|
|
||||||
"debug": map[string]interface{}{"value": []interface{}{"debug"}},
|
"debug": map[string]interface{}{"value": []interface{}{"debug"}},
|
||||||
@ -150,13 +151,14 @@ var Index = &ctx.Context{Name: "log", Help: "日志中心",
|
|||||||
"close": map[string]interface{}{"value": []interface{}{"bench", "red"}},
|
"close": map[string]interface{}{"value": []interface{}{"bench", "red"}},
|
||||||
"stack": map[string]interface{}{"value": []interface{}{"bench", "yellow"}},
|
"stack": map[string]interface{}{"value": []interface{}{"bench", "yellow"}},
|
||||||
"warn": map[string]interface{}{"value": []interface{}{"bench", "yellow"}},
|
"warn": map[string]interface{}{"value": []interface{}{"bench", "yellow"}},
|
||||||
|
"time": map[string]interface{}{"value": []interface{}{"bench", "red"}},
|
||||||
|
|
||||||
"right": map[string]interface{}{"value": []interface{}{"right"}},
|
"right": map[string]interface{}{"value": []interface{}{"right"}},
|
||||||
|
|
||||||
"error": map[string]interface{}{"value": []interface{}{"error", "red"}},
|
"error": map[string]interface{}{"value": []interface{}{"error", "red"}},
|
||||||
"trace": map[string]interface{}{"value": []interface{}{"error", "red"}},
|
"trace": map[string]interface{}{"value": []interface{}{"error", "red"}},
|
||||||
|
|
||||||
"cmd": map[string]interface{}{"value": []interface{}{"bench", "green"},
|
"cmd": map[string]interface{}{"value": []interface{}{"bench", "green", "cost"},
|
||||||
"lex": map[string]interface{}{"value": []interface{}{"debug", "green"}},
|
"lex": map[string]interface{}{"value": []interface{}{"debug", "green"}},
|
||||||
"yac": map[string]interface{}{"value": []interface{}{"debug", "green"}},
|
"yac": map[string]interface{}{"value": []interface{}{"debug", "green"}},
|
||||||
"cli": map[string]interface{}{
|
"cli": map[string]interface{}{
|
||||||
|
@ -360,6 +360,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
args = append(args, msg.Parse(v))
|
args = append(args, msg.Parse(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m.Log("time", "check: %v", m.Format("cost"))
|
||||||
msg.Cmd(tool["componet_cmd"], args, arg).CopyTo(m)
|
msg.Cmd(tool["componet_cmd"], args, arg).CopyTo(m)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -633,7 +634,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"_route": {Name: "_route", Help: "路由", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"_route": {Name: "_route", Help: "路由", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
m.Log("time", "exec: %v", m.Format("cost"))
|
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -662,6 +662,10 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
if rest := kit.Select("", names, 1); names[0] != "" {
|
if rest := kit.Select("", names, 1); names[0] != "" {
|
||||||
// 数字签名
|
// 数字签名
|
||||||
if !m.Options("remote_code") && arg[0] != "_check" {
|
if !m.Options("remote_code") && arg[0] != "_check" {
|
||||||
|
for _, k := range []string{"river"}{
|
||||||
|
m.Option(k, m.Option(k))
|
||||||
|
}
|
||||||
|
|
||||||
hash, meta := kit.Hash("rand",
|
hash, meta := kit.Hash("rand",
|
||||||
m.Option("text.time", m.Time("stamp")),
|
m.Option("text.time", m.Time("stamp")),
|
||||||
m.Option("text.cmd", strings.Join(arg, " ")),
|
m.Option("text.cmd", strings.Join(arg, " ")),
|
||||||
@ -715,7 +719,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
|
|
||||||
defer func() { m.Back(m) }()
|
defer func() { m.Back(m) }()
|
||||||
|
|
||||||
m.Log("time", "exec: %v", m.Format("cost"))
|
|
||||||
if !m.Options("remote_code") {
|
if !m.Options("remote_code") {
|
||||||
// 本地调用
|
// 本地调用
|
||||||
m.Cmdy(arg)
|
m.Cmdy(arg)
|
||||||
@ -749,8 +752,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
m.Echo("node error of %s", m.Option("node.route"))
|
m.Echo("node error of %s", m.Option("node.route"))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m.Log("time", "exec: %v", m.Format("cost"))
|
|
||||||
// 执行命令
|
// 执行命令
|
||||||
|
m.Log("time", "check: %v", m.Format("cost"))
|
||||||
m.Cmd("_exec", arg)
|
m.Cmd("_exec", arg)
|
||||||
m.Log("time", "exec: %v", m.Format("cost"))
|
m.Log("time", "exec: %v", m.Format("cost"))
|
||||||
}
|
}
|
||||||
@ -1105,8 +1108,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 执行命令
|
// 执行命令
|
||||||
|
m.Log("time", "right: %v", m.Format("cost"))
|
||||||
m.Cmdy(arg)
|
m.Cmdy(arg)
|
||||||
m.Log("time", "exec: %v", m.Format("cost"))
|
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
@ -186,6 +186,7 @@ func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 用户登录
|
// 用户登录
|
||||||
|
msg.Log("time", "parse: %v", msg.Format("cost"))
|
||||||
if msg.Put("option", "request", r).Put("option", "response", w).Sess("web", msg); web.Login(msg, w, r) {
|
if msg.Put("option", "request", r).Put("option", "response", w).Sess("web", msg); web.Login(msg, w, r) {
|
||||||
msg.Log("cmd", "%s [] %v", key, msg.Meta["option"])
|
msg.Log("cmd", "%s [] %v", key, msg.Meta["option"])
|
||||||
cmd.Hand(msg, msg.Target(), msg.Option("path"))
|
cmd.Hand(msg, msg.Target(), msg.Option("path"))
|
||||||
@ -875,6 +876,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 执行命令
|
// 执行命令
|
||||||
|
m.Log("time", "check: %v", m.Format("cost"))
|
||||||
msg.Cmd(arg)
|
msg.Cmd(arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1086,6 +1086,7 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
self := &ctx.Command{Name: strings.Join(arg[1:], " "), Help: []string{"pwd", "ls"}}
|
self := &ctx.Command{Name: strings.Join(arg[1:], " "), Help: []string{"pwd", "ls"}}
|
||||||
self.Hand = func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
self.Hand = func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
m.Goshy(self.Help.([]string), 0, nil, nil)
|
m.Goshy(self.Help.([]string), 0, nil, nil)
|
||||||
|
m.Log("time", "parse: %v", m.Format("cost"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Target().Commands[arg[1]] = self
|
m.Target().Commands[arg[1]] = self
|
||||||
|
@ -14,8 +14,8 @@ import (
|
|||||||
var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||||
Caches: map[string]*ctx.Cache{},
|
Caches: map[string]*ctx.Cache{},
|
||||||
Configs: map[string]*ctx.Config{
|
Configs: map[string]*ctx.Config{
|
||||||
"login": &ctx.Config{Name: "login", Value: map[string]interface{}{"check": "false"}, Help: "用户登录"},
|
"login": {Name: "login", Value: map[string]interface{}{"check": "false"}, Help: "用户登录"},
|
||||||
"componet": &ctx.Config{Name: "componet", Value: map[string]interface{}{
|
"componet": {Name: "componet", Value: map[string]interface{}{
|
||||||
"index": []interface{}{
|
"index": []interface{}{
|
||||||
map[string]interface{}{"name": "wiki",
|
map[string]interface{}{"name": "wiki",
|
||||||
"tmpl": "head", "metas": []interface{}{map[string]interface{}{
|
"tmpl": "head", "metas": []interface{}{map[string]interface{}{
|
||||||
@ -45,17 +45,17 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
|||||||
},
|
},
|
||||||
}, Help: "组件列表"},
|
}, Help: "组件列表"},
|
||||||
|
|
||||||
"level": &ctx.Config{Name: "level", Value: "local/wiki/自然/编程", Help: "路由数量"},
|
"level": {Name: "level", Value: "local/wiki/自然/编程", Help: "路由数量"},
|
||||||
"class": &ctx.Config{Name: "class", Value: "", Help: "路由数量"},
|
"class": {Name: "class", Value: "", Help: "路由数量"},
|
||||||
"favor": &ctx.Config{Name: "favor", Value: "index.md", Help: "路由数量"},
|
"favor": {Name: "favor", Value: "index.md", Help: "路由数量"},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"tree": &ctx.Command{Name: "tree", Help: "目录", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"tree": {Name: "tree", Help: "目录", Form: map[string]int{"level": 1, "class": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
m.Cmdy("nfs.dir", path.Join(m.Confx("level"), m.Confx("class", arg, 0)),
|
m.Cmdy("nfs.dir", path.Join(m.Confx("level"), m.Confx("class", arg, 0)),
|
||||||
"time", "size", "line", "file", "dir_sort", "time", "time_r")
|
"time", "size", "line", "file", "dir_sort", "time", "time_r")
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"text": &ctx.Command{Name: "text", Help: "文章", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"text": {Name: "text", Help: "文章", Form: map[string]int{"level": 1, "class": 1, "favor": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
which := m.Cmdx("nfs.path", path.Join(m.Confx("level"), m.Confx("class", arg, 1), m.Confx("favor", arg, 0)))
|
which := m.Cmdx("nfs.path", path.Join(m.Confx("level"), m.Confx("class", arg, 1), m.Confx("favor", arg, 0)))
|
||||||
|
|
||||||
buffer := bytes.NewBuffer([]byte{})
|
buffer := bytes.NewBuffer([]byte{})
|
||||||
|
@ -42,9 +42,9 @@ fun note "记事本" public \
|
|||||||
feature display inner
|
feature display inner
|
||||||
|
|
||||||
if $2 == "" || $2 ~ ".*/$"
|
if $2 == "" || $2 ~ ".*/$"
|
||||||
copy ssh._route _ context wiki tree __
|
copy ssh._route _ context wiki tree __ level local/wiki
|
||||||
else
|
else
|
||||||
copy ssh._route _ context wiki text __
|
copy ssh._route _ context wiki text __ level local/wiki
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user