mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
add dream.layout
This commit is contained in:
parent
32a6ef00f8
commit
148e8a3846
@ -192,6 +192,7 @@ ShyInit() {
|
|||||||
echo "pid: $$"
|
echo "pid: $$"
|
||||||
echo "pane: $TMUX_PANE"
|
echo "pane: $TMUX_PANE"
|
||||||
echo "begin: ${ctx_begin}"
|
echo "begin: ${ctx_begin}"
|
||||||
|
echo "share: ${ctx_share}"
|
||||||
}
|
}
|
||||||
|
|
||||||
ShyInit && trap ShyLogout EXIT
|
ShyInit && trap ShyLogout EXIT
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"toolkit"
|
"toolkit"
|
||||||
@ -36,13 +35,11 @@ func (c *Context) Register(s *Context, x Server, args ...interface{}) *Context {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
func (c *Context) Plugin(s *Context, args []string) string {
|
func (c *Context) Plugin(s *Context, args []string) string {
|
||||||
runtime.GOMAXPROCS(8)
|
|
||||||
|
|
||||||
c.Register(s, nil)
|
c.Register(s, nil)
|
||||||
m := Pulse.Spawn(s)
|
m := Pulse.Spawn(s)
|
||||||
// m := &Message{code: 0, time: time.Now(), source: s, target: s, Meta: map[string][]string{}}
|
// m := &Message{code: 0, time: time.Now(), source: s, target: s, Meta: map[string][]string{}}
|
||||||
// kit.DisableLog = true
|
// kit.DisableLog = true
|
||||||
// m.Option("log.disable", true)
|
m.Option("log.disable", false)
|
||||||
m.Option("bio.modal", "action")
|
m.Option("bio.modal", "action")
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
@ -50,7 +47,7 @@ func (c *Context) Plugin(s *Context, args []string) string {
|
|||||||
m.Echo("命令列表:\n")
|
m.Echo("命令列表:\n")
|
||||||
for k, v := range s.Commands {
|
for k, v := range s.Commands {
|
||||||
if !strings.HasPrefix(k, "_") {
|
if !strings.HasPrefix(k, "_") {
|
||||||
m.Echo(" %s: %s\n %v\n\n", k, v.Name, v.Help)
|
m.Echo("--%s: %s\n %v\n\n", k, v.Name, v.Help)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo("配置列表:\n")
|
m.Echo("配置列表:\n")
|
||||||
|
@ -339,10 +339,10 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
|
|||||||
}
|
}
|
||||||
value = m.Confv(arg[0], arg[1])
|
value = m.Confv(arg[0], arg[1])
|
||||||
} else if len(arg) > 2 && arg[2] == "list" {
|
} else if len(arg) > 2 && arg[2] == "list" {
|
||||||
for i := 3; i < len(arg)-1; i += 1 {
|
for i := 3; i < len(arg); i += 1 {
|
||||||
m.Confv(arg[0], []interface{}{arg[1], -2}, arg[i])
|
m.Confv(arg[0], []interface{}{arg[1], -2}, arg[i])
|
||||||
}
|
}
|
||||||
value = m.Confv(arg[0], arg[1])
|
return
|
||||||
} else if len(arg) > 1 && arg[1] == "list" {
|
} else if len(arg) > 1 && arg[1] == "list" {
|
||||||
for i := 2; i < len(arg)-1; i += 1 {
|
for i := 2; i < len(arg)-1; i += 1 {
|
||||||
m.Confv(arg[0], -2, arg[i])
|
m.Confv(arg[0], -2, arg[i])
|
||||||
|
@ -19,9 +19,9 @@ func (m *Message) Log(action string, str string, arg ...interface{}) *Message {
|
|||||||
kit.Log("error", fmt.Sprintf("stack: %s", m.Format("stack")))
|
kit.Log("error", fmt.Sprintf("stack: %s", m.Format("stack")))
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Options("log.disable") {
|
// if m.Options("log.disable") {
|
||||||
return m
|
// return m
|
||||||
}
|
// }
|
||||||
|
|
||||||
if l := m.Sess("log", false); l != nil {
|
if l := m.Sess("log", false); l != nil {
|
||||||
if log, ok := l.target.Server.(LOGGER); ok {
|
if log, ok := l.target.Server.(LOGGER); ok {
|
||||||
|
@ -118,10 +118,29 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
"least": 3,
|
"least": 3,
|
||||||
}},
|
}},
|
||||||
"dream": {Name: "dream", Help: "使命必达", Value: map[string]interface{}{
|
"dream": {Name: "dream", Help: "使命必达", Value: map[string]interface{}{
|
||||||
|
"layout": map[string]interface{}{
|
||||||
|
"three": []interface{}{
|
||||||
|
"split-window -t $dream:1.1",
|
||||||
|
"split-window -v -t $dream:1.2",
|
||||||
|
"rename-window -t $dream:1 source",
|
||||||
|
"select-layout -t $dream:1 main-horizontal",
|
||||||
|
|
||||||
|
"new-window -t $dream:2 -n docker",
|
||||||
|
"split-window -t $dream:2.1",
|
||||||
|
"split-window -v -t $dream:2.2",
|
||||||
|
"select-layout -t $dream:2 main-horizontal",
|
||||||
|
|
||||||
|
"new-window -t $dream:3 -n online",
|
||||||
|
"split-window -t $dream:3.1",
|
||||||
|
"split-window -v -t $dream:3.2",
|
||||||
|
"select-layout -t $dream:3 main-horizontal",
|
||||||
|
},
|
||||||
|
},
|
||||||
"topic": map[string]interface{}{
|
"topic": map[string]interface{}{
|
||||||
"hello": map[string]interface{}{
|
"hello": map[string]interface{}{
|
||||||
"ship": []interface{}{"tip", "miss.md", "task", "feed"},
|
"ship": []interface{}{"tip", "miss.md", "task", "feed"},
|
||||||
"git": []interface{}{"clone https://github.com/shylinux/context"},
|
"git": []interface{}{"clone https://github.com/shylinux/context"},
|
||||||
|
"layout": []interface{}{},
|
||||||
"tmux": []interface{}{
|
"tmux": []interface{}{
|
||||||
"split-window -t $dream:1.1",
|
"split-window -t $dream:1.1",
|
||||||
"new-window -t $dream:2",
|
"new-window -t $dream:2",
|
||||||
@ -143,11 +162,12 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
if !m.Cmds(tmux, "has-session", "-t", arg[1]) {
|
if !m.Cmds(tmux, "has-session", "-t", arg[1]) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
topic := kit.Select("hello", kit.Select(m.Option("topic"), arg, 2))
|
||||||
|
|
||||||
// 下载代码
|
// 下载代码
|
||||||
home := path.Join(m.Conf("missyou", "path"), arg[1], m.Conf("missyou", "local"))
|
home := path.Join(m.Conf("missyou", "path"), arg[1], m.Conf("missyou", "local"))
|
||||||
git := kit.Trans(m.Confv("prefix", "git"), "cmd_dir", home)
|
git := kit.Trans(m.Confv("prefix", "git"), "cmd_dir", home)
|
||||||
m.Confm("dream", []string{"topic", m.Option("topic"), "git"}, func(index int, value string) {
|
m.Confm("dream", []string{"topic", topic, "git"}, func(index int, value string) {
|
||||||
value = strings.Replace(value, "$dream", arg[1], -1)
|
value = strings.Replace(value, "$dream", arg[1], -1)
|
||||||
m.Cmdx(git, strings.Split(value, " "))
|
m.Cmdx(git, strings.Split(value, " "))
|
||||||
})
|
})
|
||||||
@ -156,16 +176,21 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
m.Cmds(tmux, "set-environment", "-g", "ctx_share", m.Cmdx("dream", "share"))
|
m.Cmds(tmux, "set-environment", "-g", "ctx_share", m.Cmdx("dream", "share"))
|
||||||
m.Cmds(tmux, "new-session", "-ds", arg[1], "cmd_dir", home, "cmd_env", "TMUX", "")
|
m.Cmds(tmux, "new-session", "-ds", arg[1], "cmd_dir", home, "cmd_env", "TMUX", "")
|
||||||
m.Cmds(tmux, "set-environment", "-t", arg[1], "ctx_share", m.Cmdx("dream", "share"))
|
m.Cmds(tmux, "set-environment", "-t", arg[1], "ctx_share", m.Cmdx("dream", "share"))
|
||||||
m.Confm("dream", []string{"topic", m.Option("topic"), "tmux"}, func(index int, value string) {
|
m.Confm("dream", []string{"layout", m.Conf("dream", []string{"topic", m.Option("topic"), "layout", "0"})}, func(index int, value string) {
|
||||||
|
value = strings.Replace(value, "$dream", arg[1], -1)
|
||||||
|
m.Cmdx(tmux, strings.Split(value, " "), "cmd_dir", home)
|
||||||
|
})
|
||||||
|
m.Confm("dream", []string{"topic", topic, "tmux"}, func(index int, value string) {
|
||||||
value = strings.Replace(value, "$dream", arg[1], -1)
|
value = strings.Replace(value, "$dream", arg[1], -1)
|
||||||
m.Cmdx(tmux, strings.Split(value, " "), "cmd_dir", home)
|
m.Cmdx(tmux, strings.Split(value, " "), "cmd_dir", home)
|
||||||
})
|
})
|
||||||
|
|
||||||
arg = []string{"share"}
|
arg = []string{"share", topic}
|
||||||
fallthrough
|
fallthrough
|
||||||
case "share":
|
case "share":
|
||||||
|
topic := kit.Select("hello", kit.Select(m.Option("topic"), arg, 1))
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
m.Confm("dream", []string{"topic", kit.Select("hello", m.Option("topic")), "ship"}, func(index int, value string) {
|
m.Confm("dream", []string{"topic", kit.Select("hello", topic), "ship"}, func(index int, value string) {
|
||||||
arg = append(arg, value)
|
arg = append(arg, value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -273,6 +273,7 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
|||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"run": {Name: "run", Help: "便签", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"run": {Name: "run", Help: "便签", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
m.Option("render", "raw")
|
||||||
m.Cmdy(arg)
|
m.Cmdy(arg)
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user