forked from x/icebergs
opt cli
This commit is contained in:
parent
bf9b1d1b35
commit
593663cbdf
@ -34,9 +34,9 @@ func _file_list(m *ice.Message, root string, name string, level int, deep bool,
|
||||
|
||||
fs, e := ioutil.ReadDir(path.Join(root, name))
|
||||
if e != nil {
|
||||
ls, _ := ioutil.ReadDir(root)
|
||||
ls, _ := ioutil.ReadDir(path.Dir(path.Join(root, name)))
|
||||
for _, k := range ls {
|
||||
if k.Name() == name {
|
||||
if k.Name() == path.Base(name) {
|
||||
fs = append(fs, k)
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
// 系统项目
|
||||
wd, _ := os.Getwd()
|
||||
_repos_insert(m, path.Base(wd), wd)
|
||||
|
||||
|
@ -4,11 +4,10 @@ refer "官网" `
|
||||
文档 https://git-scm.com/docs
|
||||
源码 https://github.com/git/git
|
||||
`
|
||||
premenu
|
||||
|
||||
chapter "源码"
|
||||
field git web.code.git.git
|
||||
field git web.code.inner args `[ usr/install/git-1.8.3.1/ shell.c 145 ]`
|
||||
field git web.code.inner args `usr/install/git-1.8.3.1/ shell.c 145`
|
||||
|
||||
section "构建"
|
||||
spark shell `
|
||||
@ -31,12 +30,7 @@ cd ./_install
|
||||
chapter "应用"
|
||||
field "代码库" web.code.git.repos
|
||||
field "统计量" web.code.git.total
|
||||
field "代码管理" web.code.git.status
|
||||
field "提交趋势" web.code.git.trend args icebergs
|
||||
field "代码结构" web.code.git.spide args `usr/icebergs`
|
||||
field "代码结构" web.code.git.spide args icebergs
|
||||
field "代码管理" web.code.git.status
|
||||
|
||||
chapter "项目"
|
||||
refer `
|
||||
go https://github.com/google/gitprotocolio
|
||||
`
|
||||
field icebergs web.code.inner args `[ usr/icebergs misc/git/git.go ]`
|
||||
|
@ -14,23 +14,30 @@ import (
|
||||
|
||||
func _repos_insert(m *ice.Message, name string, dir string) {
|
||||
if s, e := os.Stat(m.Option(cli.CMD_DIR, path.Join(dir, ".git"))); e == nil && s.IsDir() {
|
||||
ls := strings.SplitN(strings.Trim(m.Cmdx(cli.SYSTEM, "git", "log", "-n1", `--pretty=format:"%ad %s"`, "--date=iso"), "\""), " ", 4)
|
||||
ls := strings.SplitN(strings.Trim(m.Cmdx(cli.SYSTEM, GIT, "log", "-n1", `--pretty=format:"%ad %s"`, "--date=iso"), "\""), " ", 4)
|
||||
m.Rich(REPOS, nil, kit.Data(
|
||||
"name", name, "path", dir,
|
||||
"last", kit.Select("", ls, 3), "time", strings.Join(ls[:2], " "),
|
||||
"branch", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "branch")),
|
||||
"remote", strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "remote", "-v")),
|
||||
kit.MDB_NAME, name, kit.MDB_PATH, dir,
|
||||
COMMIT, kit.Select("", ls, 3), kit.MDB_TIME, strings.Join(ls[:2], " "),
|
||||
BRANCH, strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, BRANCH)),
|
||||
REMOTE, strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, REMOTE, "-v")),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
REMOTE = "remote"
|
||||
ORIGIN = "origin"
|
||||
BRANCH = "branch"
|
||||
MASTER = "master"
|
||||
COMMIT = "commit"
|
||||
)
|
||||
const REPOS = "repos"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
REPOS: {Name: REPOS, Help: "仓库", Value: kit.Data(
|
||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,name,branch,last",
|
||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,name,branch,commit",
|
||||
"owner", "https://github.com/shylinux",
|
||||
)},
|
||||
},
|
||||
@ -46,10 +53,10 @@ func init() {
|
||||
if _, e := os.Stat(m.Option(kit.MDB_PATH)); e == nil {
|
||||
m.Option(cli.CMD_DIR, m.Option(kit.MDB_PATH))
|
||||
m.Cmd(cli.SYSTEM, GIT, "init")
|
||||
m.Cmd(cli.SYSTEM, GIT, "remote", "add", "origin", m.Option(kit.SSH_REPOS))
|
||||
m.Cmd(cli.SYSTEM, GIT, "pull", "origin", "master")
|
||||
m.Cmd(cli.SYSTEM, GIT, REMOTE, "add", ORIGIN, m.Option(kit.SSH_REPOS))
|
||||
m.Cmd(cli.SYSTEM, GIT, "pull", ORIGIN, MASTER)
|
||||
} else {
|
||||
m.Cmd(cli.SYSTEM, GIT, "clone", "-b", kit.Select("master", m.Option("branch")),
|
||||
m.Cmd(cli.SYSTEM, GIT, "clone", "-b", kit.Select(MASTER, m.Option(BRANCH)),
|
||||
m.Option(kit.SSH_REPOS), m.Option(kit.MDB_PATH))
|
||||
|
||||
}
|
||||
@ -61,7 +68,12 @@ func init() {
|
||||
if wd, _ := os.Getwd(); arg[0] != path.Base(wd) {
|
||||
m.Option(nfs.DIR_ROOT, path.Join("usr", arg[0]))
|
||||
}
|
||||
m.Cmdy(nfs.DIR, kit.Select("./", path.Join(arg[1:]...)))
|
||||
file := kit.Select("./", path.Join(arg[1:]...))
|
||||
if strings.HasSuffix(file, "/") {
|
||||
m.Cmdy(nfs.DIR, file)
|
||||
} else {
|
||||
m.Cmdy(nfs.CAT, file)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/ctx"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/core/code"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
@ -16,27 +20,35 @@ const SPIDE = "spide"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
SPIDE: {Name: "spide path file auto", Help: "结构图", Meta: kit.Dict(
|
||||
SPIDE: {Name: "spide name=icebergs@key auto", Help: "结构图", Meta: kit.Dict(
|
||||
"display", "/plugin/story/spide.js",
|
||||
), Action: map[string]*ice.Action{
|
||||
ctx.COMMAND: {Name: "ctx.command"},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(REPOS).Appendv(ice.MSG_APPEND, kit.Split("name,branch,commit"))
|
||||
}},
|
||||
code.INNER: {Name: "web.code.inner"},
|
||||
ctx.COMMAND: {Name: "ctx.command"},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
// 仓库列表
|
||||
m.Option(ice.MSG_DISPLAY, "table")
|
||||
m.Cmdy(TOTAL, arg)
|
||||
m.Cmdy(REPOS, arg)
|
||||
return
|
||||
}
|
||||
|
||||
if wd, _ := os.Getwd(); arg[0] == path.Base(wd) {
|
||||
m.Option(nfs.DIR_ROOT, path.Join("src"))
|
||||
} else {
|
||||
m.Option(nfs.DIR_ROOT, path.Join("usr", arg[0]))
|
||||
}
|
||||
if len(arg) == 1 {
|
||||
// 目录列表
|
||||
m.Option(nfs.DIR_ROOT, arg[0])
|
||||
m.Option(nfs.DIR_DEEP, "true")
|
||||
m.Cmdy(nfs.DIR, "./")
|
||||
return
|
||||
}
|
||||
|
||||
if m.Option(cli.CMD_DIR, arg[0]); strings.HasSuffix(arg[1], ".go") {
|
||||
if m.Option(cli.CMD_DIR, m.Option(nfs.DIR_ROOT)); strings.HasSuffix(arg[1], ".go") {
|
||||
tags := m.Cmdx(cli.SYSTEM, "gotags", arg[1])
|
||||
|
||||
for _, line := range strings.Split(tags, "\n") {
|
||||
|
@ -10,19 +10,16 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
PULL = "pull"
|
||||
)
|
||||
const STATUS = "status"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
REPOS: {Name: REPOS, Help: "仓库", Value: kit.Data(
|
||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,name,branch,last",
|
||||
"owner", "https://github.com/shylinux",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
STATUS: {Name: "status name auto submit compile pull", Help: "代码状态", Action: map[string]*ice.Action{
|
||||
"pull": {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(cli.PROGRESS_CB, func(cb func(name string, count, total int)) {
|
||||
count, total := 0, len(m.Confm(REPOS, kit.MDB_HASH))
|
||||
m.Richs(REPOS, nil, kit.Select(kit.MDB_FOREACH, arg, 0), func(key string, value map[string]interface{}) {
|
||||
@ -30,7 +27,7 @@ func init() {
|
||||
|
||||
cb(kit.Format(value[kit.MDB_NAME]), count, total)
|
||||
m.Option(cli.CMD_DIR, value[kit.MDB_PATH])
|
||||
m.Echo(m.Cmdx(cli.SYSTEM, GIT, "pull"))
|
||||
m.Cmd(cli.SYSTEM, GIT, PULL)
|
||||
count++
|
||||
})
|
||||
cb("", total, total)
|
||||
|
@ -1,14 +1,14 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
const TOTAL = "total"
|
||||
@ -17,9 +17,7 @@ func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
TOTAL: {Name: TOTAL, Help: "统计", Value: kit.Data(
|
||||
kit.MDB_SHORT, kit.MDB_NAME, "skip", kit.Dict(
|
||||
"wubi-dict", "true", "word-dict", "true",
|
||||
),
|
||||
kit.MDB_SHORT, kit.MDB_NAME, "skip", kit.Dict("wubi-dict", "true", "word-dict", "true"),
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
@ -27,12 +25,13 @@ func init() {
|
||||
if len(arg) > 0 {
|
||||
// 提交详情
|
||||
m.Richs(REPOS, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||
m.Cmdy("_sum", kit.Value(value, "meta.path"), arg[1:])
|
||||
m.Cmdy("_sum", kit.Value(value, kit.META_PATH), arg[1:])
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 提交统计
|
||||
mu := &sync.Mutex{}
|
||||
wg := &sync.WaitGroup{}
|
||||
days, commit, adds, dels, rest := 0, 0, 0, 0, 0
|
||||
m.Richs(REPOS, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||
@ -42,7 +41,14 @@ func init() {
|
||||
|
||||
wg.Add(1)
|
||||
m.Go(func() {
|
||||
msg := m.Cmd("_sum", kit.Value(value, "meta.path"), "total", "10000").Table(func(index int, value map[string]string, head []string) {
|
||||
defer wg.Done()
|
||||
|
||||
msg := m.Cmd("_sum", kit.Value(value, "meta.path"), "total", "10000")
|
||||
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
msg.Table(func(index int, value map[string]string, head []string) {
|
||||
if kit.Int(value["days"]) > days {
|
||||
days = kit.Int(value["days"])
|
||||
}
|
||||
@ -53,7 +59,6 @@ func init() {
|
||||
})
|
||||
m.Push("name", kit.Value(value, "meta.name"))
|
||||
m.Copy(msg)
|
||||
wg.Done()
|
||||
})
|
||||
})
|
||||
wg.Wait()
|
||||
|
@ -2,6 +2,7 @@ package git
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
@ -10,9 +11,13 @@ const TREND = "trend"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
TREND: {Name: "trend name begin_time@date auto", Help: "趋势图", Meta: kit.Dict(
|
||||
TREND: {Name: "trend name=icebergs@key begin_time@date auto", Help: "趋势图", Meta: kit.Dict(
|
||||
"display", "/plugin/story/trend.js",
|
||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
), Action: map[string]*ice.Action{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(REPOS).Appendv(ice.MSG_APPEND, kit.Split("name,branch,commit"))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Option(ice.MSG_DISPLAY, "table")
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package misc
|
||||
|
||||
import (
|
||||
_ "github.com/shylinux/icebergs/misc/git"
|
||||
_ "github.com/shylinux/icebergs/misc/bash"
|
||||
_ "github.com/shylinux/icebergs/misc/tmux"
|
||||
|
||||
_ "github.com/shylinux/icebergs/misc/git"
|
||||
_ "github.com/shylinux/icebergs/misc/vim"
|
||||
_ "github.com/shylinux/icebergs/misc/zsh"
|
||||
)
|
||||
|
@ -1,246 +0,0 @@
|
||||
package tmux
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/gdb"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
"github.com/shylinux/icebergs/core/code"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
LOCAL = "local"
|
||||
RELAY = "relay"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
LOCAL: {Name: "local", Help: "虚拟机", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)},
|
||||
RELAY: {Name: "relay", Help: "跳板机", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME,
|
||||
"count", 100, "sleep", "100ms", "tail", kit.Dict(
|
||||
"verify", "Verification code:",
|
||||
"password", "Password:",
|
||||
"login", "[relay ~]$",
|
||||
),
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if m.Cmdy(cli.SYSTEM, "tmux", "ls"); m.Append("code") != "0" {
|
||||
return
|
||||
}
|
||||
|
||||
m.Cmd(web.PROXY, "add", "tmux", m.AddCmd(&ice.Command{Name: "proxy", Help: "代理", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd("session").Table(func(index int, value map[string]string, head []string) {
|
||||
if value["tag"] == "1" {
|
||||
m.Echo(value["session"])
|
||||
}
|
||||
})
|
||||
}}))
|
||||
}},
|
||||
"_install": {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option("cmd_dir", m.Conf("install", "meta.path"))
|
||||
m.Cmd(cli.SYSTEM, "git", "clone", "https://github.com/tmux/tmux")
|
||||
}},
|
||||
code.PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd("nfs.link", path.Join(os.Getenv("HOME"), ".tmux.conf"), "etc/conf/tmux.conf")
|
||||
}},
|
||||
code.PROJECT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
}},
|
||||
|
||||
gdb.INIT: {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Watch(gdb.DREAM_START)
|
||||
return
|
||||
|
||||
if m.Richs(web.FAVOR, nil, "tmux.auto", nil) == nil {
|
||||
m.Cmd(web.FAVOR, "tmux.auto", web.TYPE_SHELL, "脚本", `curl $ctx_dev/publish/auto.sh > auto.sh`)
|
||||
m.Cmd(web.FAVOR, "tmux.auto", web.TYPE_SHELL, "脚本", `source auto.sh`)
|
||||
m.Cmd(web.FAVOR, "tmux.auto", web.TYPE_SHELL, "脚本", `ShyInit && ShyLogin && trap ShyLogout EXIT`)
|
||||
}
|
||||
|
||||
for _, v := range []string{"auto.sh", "auto.vim", "auto.tmux"} {
|
||||
p := path.Join(m.Conf("web.code.publish", "meta.path"), v)
|
||||
if _, e := os.Stat(p); e != nil && os.IsNotExist(e) {
|
||||
// 下载脚本
|
||||
if h := m.Cmdx(web.SPIDE, "shy", "cache", "GET", "/publish/"+v); h != "" {
|
||||
m.Cmd(web.STORY, web.WATCH, h, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}},
|
||||
gdb.AUTO: {Name: "auto", Help: "自动化", Action: map[string]*ice.Action{
|
||||
web.DREAM_START: {Name: "dream.start", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmd(cli.SYSTEM, TMUX, "has-session", "-t", arg[0]).Append(cli.CMD_CODE) == "0" {
|
||||
return
|
||||
}
|
||||
// 创建会话
|
||||
m.Option(cli.CMD_ENV, "TMUX", "", "ctx_pod", arg[0], "ctx_dev", m.Conf(cli.RUNTIME, "conf.ctx_dev"))
|
||||
m.Option(cli.CMD_DIR, path.Join(m.Conf(web.DREAM, "meta.path"), arg[0]))
|
||||
m.Cmd(cli.SYSTEM, TMUX, "new-session", "-ds", arg[0])
|
||||
return
|
||||
|
||||
// 共享空间
|
||||
share, dev := "", kit.Select(m.Conf(cli.RUNTIME, "conf.ctx_dev"), m.Conf(cli.RUNTIME, "host.ctx_self"))
|
||||
m.Richs(web.SPACE, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||
share = kit.Format(value["share"])
|
||||
})
|
||||
|
||||
// 环境变量
|
||||
m.Option("cmd_env", "TMUX", "", "ctx_dev", dev, "ctx_share", share)
|
||||
m.Option("cmd_dir", path.Join(m.Conf(web.DREAM, "meta.path"), arg[0]))
|
||||
|
||||
if arg[0] != "" && m.Cmd(cli.SYSTEM, TMUX, "has-session", "-t", arg[0]).Append("code") != "0" {
|
||||
// 创建会话
|
||||
m.Cmd(cli.SYSTEM, TMUX, "new-session", "-ds", arg[0])
|
||||
}
|
||||
|
||||
if m.Option("local") != "" {
|
||||
// 创建容器
|
||||
m.Cmd("local", m.Option("local"), arg[0])
|
||||
}
|
||||
if m.Option("relay") != "" {
|
||||
// 远程登录
|
||||
m.Cmd("relay", m.Option("relay"), arg[0])
|
||||
}
|
||||
|
||||
for _, v := range kit.Simple(m.Optionv("before")) {
|
||||
// 前置命令
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[0], v, "Enter")
|
||||
}
|
||||
|
||||
// 连接参数
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[0], "export ctx_dev=", dev, "Enter")
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[0], "export ctx_share=", share, "Enter")
|
||||
|
||||
m.Cmd(web.FAVOR, kit.Select("tmux.auto", arg, 1)).Table(func(index int, value map[string]string, head []string) {
|
||||
switch value["type"] {
|
||||
case web.TYPE_SHELL:
|
||||
// 发送命令
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[0], value["text"], "Enter")
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
})
|
||||
|
||||
for _, v := range kit.Simple(m.Optionv("after")) {
|
||||
// 后置命令
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[0], v, "Enter")
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||
|
||||
"make": {Name: "make name cmd...", Help: "个性化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
session := m.Conf(cli.RUNTIME, "node.name")
|
||||
if arg[1] == "session" {
|
||||
session, arg[2], arg = arg[2], arg[0], arg[2:]
|
||||
}
|
||||
|
||||
if m.Warn(m.Cmd(cli.SYSTEM, TMUX, "has-session", "-t", session).Append("code") != "0", "session miss") {
|
||||
// 会话不存在
|
||||
return
|
||||
}
|
||||
|
||||
if m.Cmdx("session", session, "has", arg[0]) != "" {
|
||||
// 窗口已存在
|
||||
return
|
||||
}
|
||||
|
||||
switch arg[1] {
|
||||
case "init":
|
||||
m.Cmdx(cli.SYSTEM, TMUX, "rename-window", "-t", session, arg[0])
|
||||
arg[1], arg = arg[0], arg[1:]
|
||||
case "link":
|
||||
m.Cmdx(cli.SYSTEM, TMUX, "link-window", "-dt", session, "-s", arg[2])
|
||||
return
|
||||
default:
|
||||
m.Cmd(cli.SYSTEM, TMUX, "new-window", "-dt", session, "-n", arg[0])
|
||||
}
|
||||
|
||||
for _, v := range arg[1:] {
|
||||
switch ls := kit.Split(v); ls[1] {
|
||||
case "v":
|
||||
m.Cmd(cli.SYSTEM, TMUX, "split-window", "-h", "-dt", session+":"+arg[0]+"."+ls[0], ls[2:])
|
||||
case "u", "split-window":
|
||||
m.Cmd(cli.SYSTEM, TMUX, "split-window", "-dt", session+":"+arg[0]+"."+ls[0], ls[2:])
|
||||
case "k":
|
||||
m.Cmd(cli.SYSTEM, TMUX, "send-key", "-t", session+":"+arg[0]+"."+ls[0], ls[2:])
|
||||
default:
|
||||
m.Cmd(cli.SYSTEM, TMUX, ls[1], "-t", session+":"+arg[0]+"."+ls[0], ls[2:])
|
||||
}
|
||||
}
|
||||
}},
|
||||
|
||||
"relay": {Name: "relay [name [favor]]", Help: "跳板机", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
// 认证列表
|
||||
m.Richs(cmd, nil, "*", func(key string, value map[string]interface{}) {
|
||||
m.Push(key, value, []string{"name", "username", "website"})
|
||||
})
|
||||
return
|
||||
}
|
||||
if len(arg) == 1 {
|
||||
// 认证详情
|
||||
m.Richs(cmd, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||
m.Push("detail", value)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if len(arg) > 4 {
|
||||
// 添加认证
|
||||
m.Rich(cmd, nil, kit.Dict(kit.MDB_NAME, arg[0], kit.MDB_TEXT, arg[1],
|
||||
"username", arg[2], "website", arg[3], "password", arg[4],
|
||||
))
|
||||
return
|
||||
}
|
||||
|
||||
m.Richs(cmd, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||
// 登录命令
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[1], kit.Format("ssh %s@%s", value["username"], value["website"]), "Enter")
|
||||
|
||||
sleep := kit.Duration(m.Conf(cmd, "meta.sleep"))
|
||||
for i := 0; i < kit.Int(m.Conf(cmd, "meta.count")); i++ {
|
||||
time.Sleep(sleep)
|
||||
list := strings.Split(strings.TrimSpace(m.Cmdx(cli.SYSTEM, TMUX, "capture-pane", "-p")), "\n")
|
||||
|
||||
if tail := list[len(list)-1]; tail == m.Conf(cmd, "meta.tail.login") {
|
||||
// 登录成功
|
||||
break
|
||||
} else if tail == m.Conf(cmd, "meta.tail.password") {
|
||||
// 输入密码
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[1], value["password"], "Enter")
|
||||
} else if tail == m.Conf(cmd, "meta.tail.verify") {
|
||||
// 输入密码
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "send-keys", "-t", arg[1], m.Cmdx("aaa.totp.get", value["text"]), "Enter")
|
||||
}
|
||||
}
|
||||
})
|
||||
}},
|
||||
|
||||
"/favor": {Name: "/favor", Help: "收藏", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
current := ""
|
||||
m.Cmd("session").Table(func(index int, value map[string]string, head []string) {
|
||||
if value["tag"] == "1" {
|
||||
current = value["session"]
|
||||
}
|
||||
})
|
||||
|
||||
m.Option(ice.MSG_OUTPUT, ice.RENDER_RESULT)
|
||||
switch arg = kit.Split(kit.Select("tmux.auto", arg, 0)); arg[0] {
|
||||
case "ice":
|
||||
if m.Cmdy(arg[1:]); len(m.Resultv()) == 0 {
|
||||
m.Table()
|
||||
}
|
||||
default:
|
||||
m.Cmd("auto", current, arg)
|
||||
}
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
}
|
@ -1 +0,0 @@
|
||||
bind C-F command-prompt -p "send favor:" -I "tmux.auto" 'run-shell -b "curl $ctx_dev/code/tmux/favor?cmds=`echo %%|sed \"s/ /%20/g\"`"'
|
@ -1,14 +1,13 @@
|
||||
title "tmux"
|
||||
refer "官网" `
|
||||
refer `
|
||||
官网 http://tmux.github.io/
|
||||
源码 https://github.com/tmux/tmux
|
||||
文档 http://man.openbsd.org/OpenBSD-current/man1/tmux.1
|
||||
源码 https://github.com/tmux/tmux
|
||||
`
|
||||
premenu
|
||||
|
||||
chapter "源码"
|
||||
field tmux web.code.tmux.tmux
|
||||
field tmux web.code.inner args `[ usr/install/tmux-3.1b cmd-bind-key.c ]`
|
||||
field tmux web.code.inner args `usr/install/tmux-3.1b cmd-bind-key.c`
|
||||
|
||||
section "构建"
|
||||
spark shell `
|
||||
@ -34,5 +33,3 @@ field buffer web.code.tmux.buffer
|
||||
field script web.code.tmux.script
|
||||
field session web.code.tmux.session
|
||||
|
||||
chapter "项目"
|
||||
field icebergs web.code.inner args `[ usr/icebergs misc/tmux/tmux.go ]`
|
||||
|
@ -15,6 +15,7 @@ field "文档" web.code.inner args `usr/install/vim81/_install/share/vim/vim81/d
|
||||
section "构建"
|
||||
spark shell `
|
||||
yum install -y wget make gcc
|
||||
yum install -y bzip2.x86_64
|
||||
|
||||
wget ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2
|
||||
tar xvf vim-8.1.tar.bz2 && cd vim81
|
||||
|
@ -1,38 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/gdb"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
"github.com/shylinux/icebergs/core/code"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"path"
|
||||
)
|
||||
|
||||
const BASH = "bash"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
BASH: {Name: BASH, Help: "命令行", Value: kit.Data(
|
||||
"source", "http://mirrors.aliyun.com/gnu/bash/bash-4.2.53.tar.gz",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
BASH: {Name: "bash port path auto start build download", Help: "命令行", Action: map[string]*ice.Action{
|
||||
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, web.DOWNLOAD, m.Conf(BASH, kit.META_SOURCE))
|
||||
}},
|
||||
gdb.BUILD: {Name: "build", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, gdb.BUILD, m.Conf(BASH, kit.META_SOURCE))
|
||||
}},
|
||||
gdb.START: {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, gdb.START, m.Conf(BASH, kit.META_SOURCE), "bin/bash")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, path.Base(m.Conf(BASH, kit.META_SOURCE)), arg)
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
title "bash"
|
||||
refer `
|
||||
官网 https://www.gnu.org/software/bash/
|
||||
文档 https://www.gnu.org/software/bash/manual/bash.html
|
||||
源码 http://ftp.gnu.org/gnu/bash/
|
||||
`
|
||||
|
||||
chapter "源码"
|
||||
field "bash" web.code.zsh.bash
|
||||
field "bash" web.code.inner args `[ usr/install/bash-4.2.53/ input.c 625 ]`
|
||||
|
||||
section "构建"
|
||||
spark shell `
|
||||
yum install -y wget make gcc
|
||||
yum install -y byacc.x86_64
|
||||
|
||||
wget http://mirrors.aliyun.com/gnu/bash/bash-4.2.53.tar.gz
|
||||
tar xvf bash-4.2.53.tar.gz && cd bash-4.2.53
|
||||
|
||||
./configure --prefix=$PWD/_install
|
||||
make -j4 && make install
|
||||
`
|
||||
|
||||
section "启动"
|
||||
spark shell `
|
||||
cd ./_install
|
||||
./bin/bash
|
||||
`
|
||||
|
||||
chapter "应用"
|
||||
web.code.zsh.sess contexts
|
||||
|
||||
field "文件夹" web.chat.files
|
||||
field "会话流" web.code.zsh.sess
|
||||
field "回收站" web.code.zsh.trash
|
||||
field "收藏夹" web.code.zsh.favor
|
||||
field "同步流" web.code.zsh.sync
|
||||
|
@ -1,36 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
"/download": {Name: "/download", Help: "下载", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 || arg[0] == "" {
|
||||
m.Cmdy("web.chat.files").Table()
|
||||
return
|
||||
}
|
||||
|
||||
// 下载文件
|
||||
m.Cmdy(web.CACHE, m.Cmd("web.chat.files", arg[0]).Append("data"))
|
||||
m.Render(kit.Select(ice.RENDER_DOWNLOAD, ice.RENDER_RESULT, m.Append("file") == ""), m.Append("text"))
|
||||
}},
|
||||
"/upload": {Name: "/upload", Help: "上传", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
// 缓存文件
|
||||
msg := m.Cmd(web.CACHE, web.UPLOAD)
|
||||
m.Option(ice.MSG_UPLOAD, msg.Append(kit.MDB_HASH), msg.Append(kit.MDB_NAME))
|
||||
m.Cmd("web.chat.files", "upload")
|
||||
|
||||
m.Echo("data: %s\n", msg.Append("data"))
|
||||
m.Echo("time: %s\n", msg.Append("time"))
|
||||
m.Echo("type: %s\n", msg.Append("type"))
|
||||
m.Echo("name: %s\n", msg.Append("name"))
|
||||
m.Echo("size: %s\n", msg.Append("size"))
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
const FAVOR = "favor"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
FAVOR: {Name: FAVOR, Help: "收藏夹", Value: kit.Data(
|
||||
kit.MDB_SHORT, kit.MDB_TOPIC, kit.MDB_FIELD, "time,id,type,name,text",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
FAVOR: {Name: "favor topic id auto create export import", Help: "收藏夹", Action: map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: "create topic", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(FAVOR), "", mdb.HASH, arg)
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert topic=数据结构 type=shell name=hi text=hello file=hi.c line=1", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(FAVOR), "", mdb.HASH, kit.MDB_TOPIC, m.Option(kit.MDB_TOPIC))
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(FAVOR), kit.SubKey(m.Option(kit.MDB_TOPIC)), mdb.LIST, arg[2:])
|
||||
}},
|
||||
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.MODIFY, m.Prefix(FAVOR), kit.SubKey(m.Option(kit.MDB_TOPIC)), mdb.LIST, kit.MDB_ID, m.Option(kit.MDB_ID), arg)
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.DELETE, m.Prefix(FAVOR), "", mdb.HASH, kit.MDB_TOPIC, m.Option(kit.MDB_TOPIC))
|
||||
}},
|
||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.EXPORT, m.Prefix(FAVOR), "", mdb.HASH)
|
||||
}},
|
||||
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.IMPORT, m.Prefix(FAVOR), "", mdb.HASH)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case kit.MDB_TOPIC:
|
||||
m.Cmdy(mdb.INPUTS, m.Prefix(FAVOR), "", mdb.HASH, arg)
|
||||
default:
|
||||
m.Cmdy(mdb.INPUTS, m.Prefix(FAVOR), kit.SubKey(m.Option(kit.MDB_TOPIC)), mdb.LIST, arg)
|
||||
}
|
||||
}},
|
||||
cli.SYSTEM: {Name: "system", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] == mdb.RENDER {
|
||||
m.Cmdy(cli.SYSTEM, arg[1:])
|
||||
return
|
||||
}
|
||||
|
||||
m.PushPlugin(cli.SYSTEM, cli.SYSTEM, mdb.RENDER)
|
||||
m.Push(kit.SSH_ARG, kit.Format([]string{m.Option(kit.MDB_TEXT)}))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Option(mdb.FIELDS, "time,count,topic")
|
||||
m.Cmdy(mdb.SELECT, m.Prefix(FAVOR), "", mdb.HASH)
|
||||
m.PushAction(mdb.REMOVE)
|
||||
return
|
||||
}
|
||||
|
||||
m.Option(mdb.FIELDS, kit.Select(m.Conf(m.Prefix(FAVOR), kit.META_FIELD), mdb.DETAIL, len(arg) > 1))
|
||||
m.Cmdy(mdb.SELECT, m.Prefix(FAVOR), kit.SubKey(arg[0]), mdb.LIST, kit.MDB_ID, arg[1:])
|
||||
m.PushAction(cli.SYSTEM)
|
||||
}},
|
||||
|
||||
"/favor": {Name: "/favor", Help: "收藏", Action: map[string]*ice.Action{
|
||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo("#!/bin/sh\n\n")
|
||||
m.Cmdy(m.Prefix(FAVOR), m.Option("tab")).Table(func(index int, value map[string]string, head []string) {
|
||||
// 查看收藏
|
||||
if m.Option("note") == "" || m.Option("note") == value[kit.MDB_NAME] {
|
||||
m.Echo("# %v\n%v\n\n", value[kit.MDB_NAME], value[kit.MDB_TEXT])
|
||||
}
|
||||
})
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(m.Prefix(FAVOR)).Table()
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{},
|
||||
Commands: map[string]*ice.Command{
|
||||
"/qrcode": {Name: "/qrcode", Help: "二维码", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, cli.QRCODE, kit.MDB_TEXT, m.Option(kit.MDB_TEXT))
|
||||
}},
|
||||
"/input": {Name: "/input", Help: "补全", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
list := kit.Split(m.Option("line"), m.Option("break"))
|
||||
word := list[kit.Int(m.Option("index"))]
|
||||
switch arg[0] {
|
||||
case "shy":
|
||||
m.Cmd("web.code.input.find", word).Table(func(index int, value map[string]string, head []string) {
|
||||
m.Echo(value["text"]).Echo(" ")
|
||||
})
|
||||
|
||||
case "line":
|
||||
if strings.HasPrefix(m.Option("line"), "ice ") {
|
||||
list := kit.Split(m.Option("line"))
|
||||
switch list[1] {
|
||||
case "add":
|
||||
m.Cmd("web.code.input.push", list[2:])
|
||||
m.Option("line", list[4])
|
||||
m.Option("point", 0)
|
||||
default:
|
||||
m.Cmdy(list[1:])
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
line := []rune(m.Option("line"))
|
||||
if begin := kit.Int(m.Option("point")); begin < len(line) {
|
||||
m.Richs("login", nil, m.Option("sid"), func(key string, value map[string]interface{}) {
|
||||
m.Echo(string(line[:begin]))
|
||||
for i := begin; i < len(line); i++ {
|
||||
if i-begin < 3 && i < len(line)-1 {
|
||||
continue
|
||||
}
|
||||
// 编码转换
|
||||
for j := 0; j < 4; j++ {
|
||||
code := string(line[begin : i+1-j])
|
||||
list := append(m.Cmd("web.code.input.find", code).Appendv("text"), code)
|
||||
if len(list) > 1 {
|
||||
m.Echo(kit.Select(code, list[0]))
|
||||
m.Info("input %s->%s", code, list[0])
|
||||
i = i - j
|
||||
break
|
||||
}
|
||||
}
|
||||
// 输出编码
|
||||
begin = i + 1
|
||||
}
|
||||
})
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case "end":
|
||||
m.Richs("login", nil, m.Option("sid"), func(key string, value map[string]interface{}) {
|
||||
last_text := kit.Format(kit.Value(value, "last.text"))
|
||||
last_list := kit.Simple(kit.Value(value, "last.list"))
|
||||
last_index := kit.Int(kit.Value(value, "last.index"))
|
||||
|
||||
if last_text != "" && strings.HasSuffix(m.Option("line"), last_text) {
|
||||
// 补全记录
|
||||
index := last_index + 1
|
||||
text := last_list[index%len(last_list)]
|
||||
kit.Value(value, "last.index", index)
|
||||
kit.Value(value, "last.text", text)
|
||||
m.Echo(strings.TrimSuffix(m.Option("line"), last_text) + text)
|
||||
m.Info("%d %v", index, last_list)
|
||||
return
|
||||
}
|
||||
|
||||
line := []rune(m.Option("line"))
|
||||
for i := len(line); i >= 0; i-- {
|
||||
if i > 0 && len(line)-i < 4 && unicode.IsLower(line[i-1]) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 编码转换
|
||||
code := string(line[i:])
|
||||
list := append(m.Cmd("web.code.input.find", code).Appendv("text"), code)
|
||||
value["last"] = kit.Dict("code", code, "text", list[0], "list", list, "index", 0)
|
||||
|
||||
// 输出编码
|
||||
m.Echo(string(line[:i]))
|
||||
m.Echo(kit.Select(code, list[0]))
|
||||
m.Info("input %s->%s", code, list[0])
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
m.Info("trans: %v", m.Result())
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/aaa"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/tcp"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
SID = "sid"
|
||||
ARG = "arg"
|
||||
SUB = "sub"
|
||||
PWD = "pwd"
|
||||
PID = "pid"
|
||||
)
|
||||
const SESS = "sess"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
SESS: {Name: SESS, Help: "会话流", Value: kit.Data(
|
||||
kit.MDB_FIELD, "time,hash,status,username,hostname,pid,pwd",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
SESS: {Name: "sess hash auto prunes", Help: "会话流", Action: map[string]*ice.Action{
|
||||
mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(mdb.FIELDS, m.Conf(m.Prefix(SESS), kit.META_FIELD))
|
||||
m.Cmdy(mdb.PRUNES, m.Prefix(SESS), "", mdb.HASH, kit.MDB_STATUS, "logout")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option(mdb.FIELDS, kit.Select(m.Conf(m.Prefix(SESS), kit.META_FIELD), mdb.DETAIL, len(arg) > 0))
|
||||
m.Cmdy(mdb.SELECT, m.Prefix(SESS), "", mdb.HASH, kit.MDB_HASH, arg)
|
||||
}},
|
||||
|
||||
web.LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if f, _, e := m.R.FormFile(SUB); e == nil {
|
||||
defer f.Close()
|
||||
// 文件参数
|
||||
if b, e := ioutil.ReadAll(f); e == nil {
|
||||
m.Option(SUB, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
if strings.TrimSpace(m.Option(SID)) != "" {
|
||||
m.Option(mdb.FIELDS, m.Conf(m.Prefix(SESS), kit.META_FIELD))
|
||||
msg := m.Cmd(mdb.SELECT, m.Prefix(SESS), "", mdb.HASH, kit.MDB_HASH, strings.TrimSpace(m.Option(SID)))
|
||||
if m.Option(SID, msg.Append(kit.MDB_HASH)) != "" {
|
||||
m.Option(aaa.USERNAME, msg.Append(aaa.USERNAME))
|
||||
m.Option(tcp.HOSTNAME, msg.Append(tcp.HOSTNAME))
|
||||
}
|
||||
}
|
||||
m.Render(ice.RENDER_RESULT)
|
||||
}},
|
||||
"/sess": {Name: "/sess", Help: "会话", Action: map[string]*ice.Action{
|
||||
"logout": {Name: "logout", Help: "退出", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.MODIFY, m.Prefix(SESS), "", mdb.HASH, kit.MDB_HASH, m.Option(SID), kit.MDB_STATUS, "logout")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if strings.TrimSpace(m.Option(SID)) == "" {
|
||||
m.Option(SID, m.Cmdx(mdb.INSERT, m.Prefix(SESS), "", mdb.HASH, kit.MDB_STATUS, "login",
|
||||
aaa.USERNAME, m.Option(aaa.USERNAME), tcp.HOSTNAME, m.Option(tcp.HOSTNAME), PID, m.Option(PID), PWD, m.Option(PWD)))
|
||||
} else {
|
||||
m.Cmdy(mdb.MODIFY, m.Prefix(SESS), "", mdb.HASH, kit.MDB_HASH, m.Option(SID), kit.MDB_STATUS, "login")
|
||||
}
|
||||
m.Echo(m.Option(SID))
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/aaa"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/tcp"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
SHELL = "shell"
|
||||
)
|
||||
const SYNC = "sync"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
SYNC: {Name: SYNC, Help: "同步流", Value: kit.Data(
|
||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,id,type,name,text",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
SYNC: {Name: "sync id auto export import", Help: "同步流", Action: map[string]*ice.Action{
|
||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.EXPORT, m.Prefix(SYNC), "", mdb.LIST)
|
||||
}},
|
||||
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.IMPORT, m.Prefix(SYNC), "", mdb.LIST)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case kit.MDB_TOPIC:
|
||||
m.Cmdy(m.Prefix(FAVOR)).Appendv(ice.MSG_APPEND, kit.MDB_TOPIC, kit.MDB_COUNT, kit.MDB_TIME)
|
||||
}
|
||||
}},
|
||||
FAVOR: {Name: "favor topic type name text", Help: "收藏", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(m.Prefix(FAVOR), mdb.INSERT, kit.MDB_TOPIC, m.Option(kit.MDB_TOPIC),
|
||||
kit.MDB_TYPE, m.Option(kit.MDB_TYPE), kit.MDB_NAME, m.Option(kit.MDB_NAME), kit.MDB_TEXT, m.Option(kit.MDB_TEXT))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
m.Option(mdb.FIELDS, mdb.DETAIL)
|
||||
m.Option(mdb.CACHE_FILED, kit.MDB_ID)
|
||||
m.Option(mdb.CACHE_VALUE, arg[0])
|
||||
} else {
|
||||
m.Option(mdb.FIELDS, m.Conf(SYNC, kit.META_FIELD))
|
||||
m.Option(ice.MSG_CONTROL, ice.CONTROL_PAGE)
|
||||
defer m.PushAction(FAVOR)
|
||||
}
|
||||
|
||||
m.Cmdy(mdb.SELECT, m.Prefix(SYNC), "", mdb.LIST, m.Option(mdb.CACHE_FILED), m.Option(mdb.CACHE_VALUE))
|
||||
}},
|
||||
"/sync": {Name: "/sync", Help: "同步", Action: map[string]*ice.Action{
|
||||
"history": {Name: "history", Help: "历史", Hand: func(m *ice.Message, arg ...string) {
|
||||
ls := strings.SplitN(strings.TrimSpace(m.Option(ARG)), " ", 4)
|
||||
if text := strings.TrimSpace(strings.Join(ls[3:], " ")); text != "" {
|
||||
m.Cmd(mdb.INSERT, m.Prefix(SYNC), "", mdb.LIST, kit.MDB_TYPE, SHELL, kit.MDB_NAME, ls[0],
|
||||
tcp.HOSTNAME, m.Option(tcp.HOSTNAME), aaa.USERNAME, m.Option(aaa.USERNAME),
|
||||
kit.MDB_TEXT, text, PWD, m.Option(PWD), kit.MDB_TIME, ls[1]+" "+ls[2])
|
||||
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(mdb.INSERT, m.Prefix(SYNC), "", mdb.HASH, kit.MDB_TYPE, SHELL, kit.MDB_NAME, arg[0],
|
||||
kit.MDB_TEXT, m.Option(SUB), PWD, m.Option(PWD))
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/base/tcp"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"path"
|
||||
)
|
||||
|
||||
const TRASH = "trash"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
TRASH: {Name: TRASH, Help: "回收站", Value: kit.Data(
|
||||
kit.MDB_FIELD, "time,hash,hostname,size,from,to",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
TRASH: {Name: "TRASH hash path auto prunes", Help: "回收站", Action: map[string]*ice.Action{
|
||||
mdb.INSERT: {Name: "insert from= to=", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(TRASH), "", mdb.HASH, "from", m.Option("from"), "to", m.Option("to"))
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, "rm", "-rf", m.Option("to"))
|
||||
m.Cmdy(mdb.DELETE, m.Prefix(TRASH), "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
|
||||
}},
|
||||
"reback": {Name: "reback", Help: "恢复", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, "mv", m.Option("to"), m.Option("from"))
|
||||
m.Cmdy(mdb.DELETE, m.Prefix(TRASH), "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
|
||||
}},
|
||||
mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
m.Cmd(mdb.SELECT, m.Prefix(TRASH), "", mdb.HASH, kit.MDB_HASH, arg).Table(func(index int, value map[string]string, head []string) {
|
||||
m.Cmdy(nfs.DIR, path.Join(value["to"], kit.Select("", arg, 1)))
|
||||
})
|
||||
return
|
||||
}
|
||||
m.Option(mdb.FIELDS, kit.Select(m.Conf(m.Prefix(TRASH), kit.META_FIELD), mdb.DETAIL, len(arg) > 0))
|
||||
m.Cmdy(mdb.SELECT, m.Prefix(TRASH), "", mdb.HASH, kit.MDB_HASH, arg)
|
||||
m.PushAction("reback", mdb.REMOVE)
|
||||
}},
|
||||
|
||||
"/trash": {Name: "/trash", Help: "回收", Action: map[string]*ice.Action{
|
||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(TRASH), "", mdb.HASH, tcp.HOSTNAME, m.Option(tcp.HOSTNAME),
|
||||
kit.MDB_SIZE, m.Option(kit.MDB_SIZE), "from", m.Option("from"), "to", m.Option("to"))
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package zsh
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/gdb"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
"github.com/shylinux/icebergs/core/code"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"path"
|
||||
)
|
||||
|
||||
const ZSH = "zsh"
|
||||
|
||||
var Index = &ice.Context{Name: ZSH, Help: "命令行",
|
||||
Configs: map[string]*ice.Config{
|
||||
ZSH: {Name: ZSH, Help: "命令行", Value: kit.Data(
|
||||
"source", "https://nchc.dl.sourceforge.net/project/zsh/zsh/5.8/zsh-5.8.tar.xz",
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
|
||||
|
||||
ZSH: {Name: "zsh port path auto start build download", Help: "命令行", Action: map[string]*ice.Action{
|
||||
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, web.DOWNLOAD, m.Conf(ZSH, kit.META_SOURCE))
|
||||
}},
|
||||
gdb.BUILD: {Name: "build", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, gdb.BUILD, m.Conf(ZSH, kit.META_SOURCE))
|
||||
}},
|
||||
gdb.START: {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, gdb.START, m.Conf(ZSH, kit.META_SOURCE), "bin/zsh")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, path.Base(m.Conf(ZSH, kit.META_SOURCE)), arg)
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
func init() { code.Index.Register(Index, &web.Frame{}) }
|
@ -1,29 +0,0 @@
|
||||
title "zsh"
|
||||
refer `
|
||||
官网 https://www.zsh.org/
|
||||
文档 http://zsh.sourceforge.net/Doc/Release/zsh_toc.html
|
||||
源码 https://github.com/zsh-users/zsh/
|
||||
`
|
||||
|
||||
chapter "源码"
|
||||
field zsh web.code.zsh.zsh
|
||||
field zsh web.code.inner args `[ usr/install/zsh-5.8/ Src/main.c 91 ]`
|
||||
|
||||
section "构建"
|
||||
spark shell `
|
||||
yum install -y wget make gcc
|
||||
yum install -y ncurses-devel.x86_64
|
||||
|
||||
wget https://nchc.dl.sourceforge.net/project/zsh/zsh/5.8/zsh-5.8.tar.xz
|
||||
tar xvf zsh-5.8.tar.xz && cd zsh-5.8
|
||||
|
||||
./configure --prefix=$PWD/_install
|
||||
make -j8 && make install
|
||||
`
|
||||
|
||||
section "启动"
|
||||
spark shell `
|
||||
cd ./_install
|
||||
./bin/zsh
|
||||
`
|
||||
|
Loading…
x
Reference in New Issue
Block a user