forked from x/ContextOS
add dream.share
This commit is contained in:
parent
dd882b96fd
commit
c7d04c114e
@ -26,6 +26,9 @@ fun! ShyLogin()
|
|||||||
endif
|
endif
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
fun! ShyDream(target)
|
||||||
|
call ShyPost({"cmd": "dream", "arg": a:target})
|
||||||
|
endfun
|
||||||
fun! ShySync(target)
|
fun! ShySync(target)
|
||||||
if bufname("%") == "ControlP" | return | end
|
if bufname("%") == "ControlP" | return | end
|
||||||
|
|
||||||
|
@ -1213,7 +1213,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 任务管理
|
// 任务管理
|
||||||
if m.Confs("ssh.node", arg[0]) {
|
if m.Option("dream", arg[0]); m.Confs("ssh.node", arg[0]) {
|
||||||
switch kit.Select("", arg, 1) {
|
switch kit.Select("", arg, 1) {
|
||||||
case "stop":
|
case "stop":
|
||||||
m.Cmdy("ssh._route", arg[0], "context", "cli", "quit", 0)
|
m.Cmdy("ssh._route", arg[0], "context", "cli", "quit", 0)
|
||||||
@ -1234,7 +1234,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
"cmd_dir", p,
|
"cmd_dir", p,
|
||||||
"cmd_daemon", "true",
|
"cmd_daemon", "true",
|
||||||
"cmd_env", "PATH", os.Getenv("PATH"),
|
"cmd_env", "PATH", os.Getenv("PATH"),
|
||||||
"cmd_env", "ctx_type", kit.Select(topic, arg, 1),
|
"cmd_env", "ctx_type", m.Option("topic", kit.Select(topic, arg, 1)),
|
||||||
"cmd_env", "ctx_home", m.Conf("runtime", "boot.ctx_home"),
|
"cmd_env", "ctx_home", m.Conf("runtime", "boot.ctx_home"),
|
||||||
"cmd_env", "ctx_ups", fmt.Sprintf("127.0.0.1%s", m.Conf("runtime", "boot.ssh_port")),
|
"cmd_env", "ctx_ups", fmt.Sprintf("127.0.0.1%s", m.Conf("runtime", "boot.ssh_port")),
|
||||||
"cmd_env", "ctx_box", fmt.Sprintf("http://127.0.0.1%s", m.Conf("runtime", "boot.web_port")),
|
"cmd_env", "ctx_box", fmt.Sprintf("http://127.0.0.1%s", m.Conf("runtime", "boot.web_port")),
|
||||||
@ -1243,7 +1243,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
|
|
||||||
// 启动服务
|
// 启动服务
|
||||||
m.Cmdy("cli.system", path.Join(m.Conf("runtime", "boot.ctx_home"), "bin/node.sh"), "start", args)
|
m.Cmdy("cli.system", path.Join(m.Conf("runtime", "boot.ctx_home"), "bin/node.sh"), "start", args)
|
||||||
m.Cmd("web.code.dream", "init", arg[0], kit.Select(topic, arg, 1))
|
if share := m.Cmdx("web.code.dream", "init", arg[0]); share != "" {
|
||||||
|
m.Cmd("nfs.save", path.Join(p, m.Conf("missyou", "local"), "share.txt"), share)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"version": &ctx.Command{Name: "version", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"version": &ctx.Command{Name: "version", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
@ -119,7 +119,8 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
}},
|
}},
|
||||||
"dream": {Name: "dream", Help: "使命必达", Value: map[string]interface{}{
|
"dream": {Name: "dream", Help: "使命必达", Value: map[string]interface{}{
|
||||||
"hello": map[string]interface{}{
|
"hello": map[string]interface{}{
|
||||||
"git": []interface{}{"clone https://github.com/shylinux/context"},
|
"ship": []interface{}{"tip", "miss.md", "task", "feed"},
|
||||||
|
"git": []interface{}{"clone https://github.com/shylinux/context"},
|
||||||
"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",
|
||||||
@ -129,9 +130,10 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
|
"share": {Name: "share", Help: "共享链接", Value: map[string]interface{}{}},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"dream": {Name: "dream", Help: "使令必达", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
"dream": {Name: "dream", Help: "使命必达", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "init":
|
case "init":
|
||||||
// 检查会话
|
// 检查会话
|
||||||
@ -141,26 +143,69 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 下载代码
|
// 下载代码
|
||||||
topic := kit.Select("hello", 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, "git"}, func(index int, value string) {
|
m.Confm("dream", []string{m.Option("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, " "))
|
||||||
})
|
})
|
||||||
|
|
||||||
// 创建终端
|
// 创建终端
|
||||||
m.Cmds(tmux, "new-session", "-ds", arg[1], "cmd_env", "TMUX", "", "cmd_dir", home)
|
m.Cmds(tmux, "new-session", "-ds", arg[1], "cmd_dir", home,
|
||||||
m.Confm("dream", []string{topic, "tmux"}, func(index int, value string) {
|
"cmd_env", "TMUX", "", "cmd_env", "ctx_share", m.Cmdx("dream", "share"))
|
||||||
|
m.Confm("dream", []string{m.Option("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"}
|
||||||
|
fallthrough
|
||||||
|
case "share":
|
||||||
|
if len(arg) == 1 {
|
||||||
|
m.Confm("dream", []string{kit.Select("hello", m.Option("topic")), "ship"}, func(index int, value string) {
|
||||||
|
arg = append(arg, value)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
h := kit.Hashs("uniq")[:6]
|
||||||
|
if m.Confs("share", []string{"hash", h}) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
m.Conf("share", []string{"hash", h}, map[string]interface{}{
|
||||||
|
"river": m.Option("river"),
|
||||||
|
"dream": m.Option("dream"),
|
||||||
|
"favor": kit.Select("tip", arg, 1),
|
||||||
|
"story": kit.Select("miss.md", arg, 2),
|
||||||
|
"stage": kit.Select("task", arg, 3),
|
||||||
|
"order": kit.Select("feed", arg, 4),
|
||||||
|
"expire": m.Time("10m", "stamp"),
|
||||||
|
})
|
||||||
|
m.Echo(h)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case "bind":
|
||||||
|
m.Confm("share", []string{"hash", arg[1]}, func(value map[string]interface{}) {
|
||||||
|
m.Conf("login", []string{"hash", m.Option("sid"), "ship"}, value)
|
||||||
|
})
|
||||||
|
|
||||||
|
case "list":
|
||||||
|
m.Confm("share", "hash", func(key string, value map[string]interface{}) {
|
||||||
|
m.Push("key", key)
|
||||||
|
m.Push("river", value["river"])
|
||||||
|
m.Push("dream", value["dream"])
|
||||||
|
m.Push("favor", value["favor"])
|
||||||
|
m.Push("story", value["story"])
|
||||||
|
m.Push("stage", value["stage"])
|
||||||
|
m.Push("order", value["order"])
|
||||||
|
m.Push("expire", value["expire"])
|
||||||
|
})
|
||||||
|
m.Table()
|
||||||
|
|
||||||
case "exit":
|
case "exit":
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"login": {Name: "login open|init|list|exit|quit", Help: "登录", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
"login": {Name: "login open|init|list|exit|quit", Help: "登录", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||||
|
|
||||||
switch kit.Select("list", arg, 0) {
|
switch kit.Select("list", arg, 0) {
|
||||||
@ -932,6 +977,8 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
m.Echo(strings.Join(kit.Trans(m.Confv("help", "index")), "\n"))
|
m.Echo(strings.Join(kit.Trans(m.Confv("help", "index")), "\n"))
|
||||||
case "login":
|
case "login":
|
||||||
m.Cmd("login", "init", cmd)
|
m.Cmd("login", "init", cmd)
|
||||||
|
case "dream":
|
||||||
|
m.Cmd("dream", "bind", m.Option("arg"))
|
||||||
case "logout":
|
case "logout":
|
||||||
m.Cmd("login", "exit")
|
m.Cmd("login", "exit")
|
||||||
case "tasklet":
|
case "tasklet":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user