mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
opt m.Push
This commit is contained in:
parent
f4ef781198
commit
f290ef7853
@ -22,9 +22,9 @@ autocmd BufReadPost * call Shy("read", expand("<afile>"))
|
||||
autocmd BufWritePre * call Shy("write", expand("<afile>"))
|
||||
autocmd BufUnload * call Shy("close", expand("<afile>"))
|
||||
|
||||
autocmd BufWritePost * call Shy("sync", "regs")
|
||||
autocmd BufWritePost * call Shy("sync", "bufs")
|
||||
autocmd BufWritePost * call Shy("sync", "tags")
|
||||
autocmd BufWritePost * call Shy("sync", "regs")
|
||||
|
||||
" autocmd BufWinEnter * call Shy("enter", expand("<afile>"))
|
||||
" autocmd WinEnter * call Shy("enter", expand("<afile>"))
|
||||
|
@ -852,17 +852,17 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
case "init":
|
||||
if _, e := os.Stat(".git"); e == nil {
|
||||
// 更新代码
|
||||
m.Cmdp(0, []string{"git update"}, []string{"cli.system", "git"}, [][]string{
|
||||
m.Cmdp(0, []string{"git update"}, []string{"web.code.git", ""}, [][]string{
|
||||
[]string{"stash"}, []string{"pull"}, []string{"stash", "pop"},
|
||||
})
|
||||
|
||||
// 代码状态
|
||||
m.Cmdy("cli.system", "git", "status", "-sb", "cmd_parse", "cut")
|
||||
m.Cmdy("web.code.git", "", "status")
|
||||
return e
|
||||
}
|
||||
|
||||
// 创建项目
|
||||
m.Cmdp(0, []string{"git init"}, []string{"cli.system", "git"}, [][]string{
|
||||
m.Cmdp(0, []string{"git init"}, []string{"web.code.git", ""}, [][]string{
|
||||
[]string{"init"}, []string{"remote", "add", kit.Select("origin", arg, 1), kit.Select(m.Conf("project", "github"), arg, 2)},
|
||||
[]string{"stash"}, []string{"pull"}, []string{"checkout", "-f", "master"}, []string{"stash", "pop"},
|
||||
})
|
||||
@ -884,33 +884,25 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
|
||||
case "trend":
|
||||
// 提交记录
|
||||
if len(arg) == 1 {
|
||||
m.Cmdy("nfs.git", "sum", "-n", 20)
|
||||
} else {
|
||||
m.Cmdy("nfs.git", "sum", "--reverse", "--since", arg[1:])
|
||||
}
|
||||
m.Cmdy("web.code.git", "", "sum", arg[1:])
|
||||
|
||||
case "trends":
|
||||
m.Cmdy("web.code.git", "", "sum", "total", arg[1:])
|
||||
// 提交记录
|
||||
if len(arg) == 1 {
|
||||
m.Cmdy("nfs.git", "sum", "total")
|
||||
} else {
|
||||
m.Cmdy("nfs.git", "sum", "total", "--reverse", "--since", arg[1])
|
||||
}
|
||||
|
||||
case "submit":
|
||||
// 提交代码
|
||||
if len(arg) > 1 {
|
||||
m.Cmdp(0, []string{"git submit"}, []string{"cli.system", "git"}, [][]string{
|
||||
[]string{"commit", "-am", arg[1]}, []string{"push"},
|
||||
m.Cmdp(0, []string{"git submit"}, []string{"web.code.git", ""}, [][]string{
|
||||
[]string{"commit", arg[1]}, []string{"push"},
|
||||
})
|
||||
}
|
||||
// 提交记录
|
||||
m.Cmdy("nfs.git", "logs", "table.limit", "3")
|
||||
m.Cmdy("web.code.git", "", "log", "--stat", "-n", "3")
|
||||
|
||||
case "review":
|
||||
// 代码修改
|
||||
m.Cmdy("cli.system", "git", "diff")
|
||||
m.Cmdy("web.code.git", "", "diff")
|
||||
|
||||
case "plugin":
|
||||
// 查看插件
|
||||
|
@ -241,12 +241,26 @@ func (m *Message) Result(arg ...interface{}) string {
|
||||
return m.Insert("result", index, arg...)
|
||||
}
|
||||
|
||||
func (m *Message) Push(str string, arg ...interface{}) *Message {
|
||||
switch m.Option("table.format") {
|
||||
case "table":
|
||||
return m.Add("append", "key", str).Add("append", "value", arg...)
|
||||
func (m *Message) Push(key interface{}, arg ...interface{}) *Message {
|
||||
switch key := key.(type) {
|
||||
case string:
|
||||
switch m.Option("table.format") {
|
||||
case "table":
|
||||
m.Add("append", "key", key)
|
||||
key = "value"
|
||||
}
|
||||
return m.Add("append", key, arg...)
|
||||
case []string:
|
||||
for _, key := range key {
|
||||
switch m.Option("table.format") {
|
||||
case "table":
|
||||
m.Add("append", "key", key)
|
||||
key = "value"
|
||||
}
|
||||
m.Add("append", key, kit.Chain(arg[0], key))
|
||||
}
|
||||
}
|
||||
return m.Add("append", str, arg...)
|
||||
return m
|
||||
}
|
||||
func (m *Message) Sort(key string, arg ...string) *Message {
|
||||
cmp := "str"
|
||||
|
@ -408,7 +408,6 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
||||
"pwd": []string{"nfs.pwd"},
|
||||
"path": []string{"nfs.path"},
|
||||
"dir": []string{"nfs.dir"},
|
||||
"git": []string{"nfs.git"},
|
||||
"brow": []string{"web.brow"},
|
||||
"ifconfig": []string{"tcp.ifconfig"},
|
||||
}, Help: "启动脚本"},
|
||||
|
@ -204,6 +204,9 @@ CMD sh bin/boot.sh
|
||||
m.Table()
|
||||
return
|
||||
|
||||
case "run":
|
||||
arg = arg[1:]
|
||||
fallthrough
|
||||
default:
|
||||
m.Cmdy(prefix, "send-keys", "-t", target, strings.Join(arg[3:], " "), "Enter")
|
||||
time.Sleep(1 * time.Second)
|
||||
@ -344,22 +347,24 @@ CMD sh bin/boot.sh
|
||||
case "diff":
|
||||
m.Cmdy(prefix, "diff")
|
||||
case "status":
|
||||
m.Cmdy(prefix, "status", "-sb", "cmd_parse", "cut", " ", "2")
|
||||
m.Cmdy(prefix, "status", "-sb", "cmd_parse", "cut", " ", "2", "tags file")
|
||||
case "commit":
|
||||
if m.Cmds(prefix, "commit", "-am") {
|
||||
if len(arg) > 1 && m.Cmds(prefix, "commit", "-am", arg[1]) {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
m.Cmdy(prefix, "log", "--stat", "-n", "3")
|
||||
case "sum":
|
||||
total := false
|
||||
if len(arg) > 1 && arg[1] == "total" {
|
||||
total, arg = true, arg[1:]
|
||||
}
|
||||
|
||||
args := []string{}
|
||||
if args = append(args, "log", "--shortstat", "--pretty=commit: %ad %n%s", "--date=iso"); len(arg) > 1 {
|
||||
args = append(args, "--reverse")
|
||||
args = append(args, "--since")
|
||||
args := []string{"log", "--shortstat", "--pretty=commit: %ad %n%s", "--date=iso", "--reverse"}
|
||||
if len(arg) > 1 {
|
||||
args = append(args, kit.Select("-n", "--since", strings.Contains(arg[1], "-")))
|
||||
if strings.Contains(arg[1], "-") && !strings.Contains(arg[1], ":") {
|
||||
arg[1] = arg[1] + " 00:00:00"
|
||||
}
|
||||
args = append(args, arg[1:]...)
|
||||
} else {
|
||||
args = append(args, "-n", "30")
|
||||
@ -429,39 +434,23 @@ CMD sh bin/boot.sh
|
||||
switch arg[0] {
|
||||
case "opens":
|
||||
m.Confm("vim", "opens", func(key string, value map[string]interface{}) {
|
||||
m.Push("time", value["time"])
|
||||
m.Push("action", value["action"])
|
||||
m.Push("file", value["file"])
|
||||
m.Push("pid", value["pid"])
|
||||
m.Push("pane", value["pane"])
|
||||
m.Push("hostname", value["hostname"])
|
||||
m.Push("username", value["username"])
|
||||
m.Push([]string{"time", "action", "file", "pid", "pane", "hostname", "username"}, value)
|
||||
})
|
||||
m.Sort("time", "time_r").Table()
|
||||
case "bufs":
|
||||
m.Confm("vim", "buffer", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push("id", value["id"])
|
||||
m.Push("name", value["name"])
|
||||
m.Push("line", value["line"])
|
||||
m.Push("hostname", value["hostname"])
|
||||
m.Push("username", value["username"])
|
||||
m.Push([]string{"id", "tag", "name", "line", "hostname", "username"}, value)
|
||||
})
|
||||
m.Table()
|
||||
case "regs":
|
||||
m.Confm("vim", "register", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push("name", value["name"])
|
||||
m.Push("text", value["text"])
|
||||
m.Push("hostname", value["hostname"])
|
||||
m.Push("username", value["username"])
|
||||
m.Push([]string{"name", "text", "hostname", "username"}, value)
|
||||
})
|
||||
m.Table()
|
||||
case "tags":
|
||||
m.Confm("vim", "tag", func(key string, index int, value map[string]interface{}) {
|
||||
m.Push("tag", value["tag"])
|
||||
m.Push("line", value["line"])
|
||||
m.Push("file", value["in file/text"])
|
||||
m.Push("hostname", value["hostname"])
|
||||
m.Push("username", value["username"])
|
||||
value["file"] = value["in file/text"]
|
||||
m.Push([]string{"tag", "line", "file", "hostname", "username"}, value)
|
||||
})
|
||||
m.Table()
|
||||
}
|
||||
@ -512,6 +501,7 @@ CMD sh bin/boot.sh
|
||||
"hostname": m.Option("hostname"),
|
||||
"username": m.Option("username"),
|
||||
"id": value["id"],
|
||||
"tag": value["tag"],
|
||||
"name": value["name"],
|
||||
"line": value["line"],
|
||||
})
|
||||
|
@ -22,7 +22,7 @@ kit tmux "终端" private "web.code.tmux" \
|
||||
text "" name pane imports plugin_pane view char action auto \
|
||||
text "" name cmd \
|
||||
exports session session "" window window "" pane pane "" \
|
||||
feature detail "复制" "下载" "修改" \
|
||||
ueature detail "复制" "下载" "修改" \
|
||||
button "查看" action auto \
|
||||
button "返回" cb Last
|
||||
|
||||
@ -50,8 +50,8 @@ kit network "网络" private "web.code.docker" "network" \
|
||||
button "查看"
|
||||
|
||||
kit volume "存储" private "web.code.docker" "volume" \
|
||||
text "" name arg imports plugin_CONTAINER_ID \
|
||||
exports CONTAINER_ID CONTAINER_ID \
|
||||
text "" name arg imports plugin_VOLUME_NAME \
|
||||
exports VOLUME_NAME VOLUME_NAME \
|
||||
button "查看"
|
||||
|
||||
kit git "记录" private "ssh._route" _ "web.code.git" \
|
||||
|
Loading…
x
Reference in New Issue
Block a user