mirror of
https://shylinux.com/x/icebergs
synced 2025-05-01 19:19:24 +08:00
opt git
This commit is contained in:
parent
61c7d82a86
commit
6e6807f872
@ -82,4 +82,4 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块",
|
||||
},
|
||||
}
|
||||
|
||||
func init() { ice.Index.Register(Index, nil, RUNTIME, SYSTEM, DAEMON, PYTHON, OUTPUT) }
|
||||
func init() { ice.Index.Register(Index, nil, RUNTIME, SYSTEM, DAEMON, PYTHON, OUTPUT, PROGRESS) }
|
||||
|
@ -10,6 +10,28 @@ import (
|
||||
|
||||
const OUTPUT = "output"
|
||||
|
||||
func _cli_progress(m *ice.Message, cb interface{}) {
|
||||
m.Option(mdb.FIELDS, "time,name,step,count,total")
|
||||
if m.Option(ice.MSG_PROCESS, "_progress"); m.Option("_progress") != "" {
|
||||
m.Cmdy(mdb.SELECT, PROGRESS, "", mdb.HASH, kit.MDB_HASH, m.Option("_progress"))
|
||||
if len(m.Appendv(kit.MDB_TIME)) > 0 {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
h := m.Cmdx(mdb.INSERT, PROGRESS, "", mdb.HASH, "step", 0, "count", 0, "total", 1)
|
||||
m.Cmdy(mdb.SELECT, PROGRESS, "", mdb.HASH, kit.MDB_HASH, m.Option("_progress", h))
|
||||
|
||||
m.Go(func() {
|
||||
switch cb := cb.(type) {
|
||||
case func(cb func(name string, count, total int)):
|
||||
cb(func(name string, count, total int) {
|
||||
m.Cmd(mdb.MODIFY, PROGRESS, "", mdb.HASH, kit.MDB_HASH, h, "name", name,
|
||||
"step", count*100/total, "count", count, "total", total)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
func Follow(m *ice.Message) bool {
|
||||
m.Option(ice.MSG_PROCESS, "_follow")
|
||||
if m.Option("cache.action", "build"); m.Option("cache.hash") != "" {
|
||||
@ -31,12 +53,29 @@ func Follow(m *ice.Message) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
PROGRESS_CB = "progress.cb"
|
||||
)
|
||||
|
||||
const PROGRESS = "progress"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
OUTPUT: {Name: OUTPUT, Help: "输出", Value: kit.Data()},
|
||||
PROGRESS: {Name: PROGRESS, Help: "进度", Value: kit.Data()},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
PROGRESS: {Name: "progress hash auto", Help: "进度", Action: map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
_cli_progress(m, m.Optionv(PROGRESS_CB))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option(mdb.FIELDS, kit.Select("time,name,step,count,total", mdb.DETAIL, len(arg) > 0))
|
||||
m.Cmdy(mdb.SELECT, PROGRESS, "", mdb.HASH, kit.MDB_HASH, arg)
|
||||
m.SortInt("step")
|
||||
}},
|
||||
|
||||
OUTPUT: {Name: "output hash id auto", Help: "输出", Action: map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: "create cmd", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
h := m.Cmdx(mdb.INSERT, OUTPUT, "", mdb.HASH, kit.MDB_STATUS, Status.Start, arg)
|
||||
|
@ -360,7 +360,7 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块",
|
||||
reg, _ := regexp.Compile(m.Option(DIR_REG))
|
||||
_file_list(m, kit.Select("./", m.Option(DIR_ROOT)), arg[0],
|
||||
0, m.Options(DIR_DEEP), kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), reg,
|
||||
kit.Split(kit.Select("time size path", strings.Join(arg[1:], " ")), " "))
|
||||
kit.Split(kit.Select("time size path", strings.Join(arg[1:], " "))))
|
||||
m.Sort(kit.MDB_TIME, "time_r")
|
||||
}},
|
||||
FILE: {Name: "file path auto", Help: "文件", Action: map[string]*ice.Action{
|
||||
|
@ -103,12 +103,12 @@ func init() {
|
||||
if arg[0] == kit.MDB_FOREACH {
|
||||
return
|
||||
}
|
||||
for _, k := range []string{"1", "2", "3", "8"} {
|
||||
if text := _c_help(m, k, kit.Select("main", arg, 1)); text != "" {
|
||||
for _, i := range []string{"1", "2", "3", "8"} {
|
||||
if text := _c_help(m, i, kit.Select("main", arg, 1)); text != "" {
|
||||
for _, k := range kit.Split(m.Option(mdb.FIELDS)) {
|
||||
switch k {
|
||||
case kit.MDB_FILE:
|
||||
m.Push(k, arg[1]+".man"+k)
|
||||
m.Push(k, arg[1]+".man"+i)
|
||||
case kit.MDB_LINE:
|
||||
m.Push(k, 1)
|
||||
case kit.MDB_TEXT:
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
"github.com/shylinux/icebergs/core/wiki"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
|
@ -3,6 +3,7 @@ package git
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/gdb"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
"github.com/shylinux/icebergs/core/code"
|
||||
@ -19,9 +20,9 @@ var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||
GIT: {Name: GIT, Help: "代码库", Value: kit.Data(
|
||||
"source", "https://mirrors.edge.kernel.org/pub/software/scm/git/git-1.8.3.1.tar.gz", "config", kit.Dict(
|
||||
"alias", kit.Dict("s", "status", "b", "branch"),
|
||||
"color", kit.Dict("ui", "true"),
|
||||
"push", kit.Dict("default", "simple"),
|
||||
"credential", kit.Dict("helper", "store"),
|
||||
"push", kit.Dict("default", "simple"),
|
||||
"color", kit.Dict("ui", "true"),
|
||||
),
|
||||
)},
|
||||
},
|
||||
@ -31,25 +32,19 @@ var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||
wd, _ := os.Getwd()
|
||||
_repos_insert(m, path.Base(wd), wd)
|
||||
|
||||
m.Cmd(nfs.DIR, "usr", "name path").Table(func(index int, value map[string]string, head []string) {
|
||||
_repos_insert(m, value["name"], value["path"])
|
||||
m.Cmd(nfs.DIR, "usr", "name,path").Table(func(index int, value map[string]string, head []string) {
|
||||
_repos_insert(m, value[kit.MDB_NAME], value[kit.MDB_PATH])
|
||||
})
|
||||
}},
|
||||
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
// 官方项目
|
||||
// m.Cmd(nfs.DIR, "usr", "name path").Table(func(index int, value map[string]string, head []string) {
|
||||
// _repos_insert(m, value["name"], value["path"])
|
||||
// })
|
||||
}},
|
||||
|
||||
GIT: {Name: "git port=auto path=auto auto 启动 构建 下载", Help: "代码库", Action: map[string]*ice.Action{
|
||||
"download": {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, "download", m.Conf(GIT, kit.META_SOURCE))
|
||||
GIT: {Name: "git 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(GIT, kit.META_SOURCE))
|
||||
}},
|
||||
"build": {Name: "build", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, "build", m.Conf(GIT, kit.META_SOURCE))
|
||||
gdb.BUILD: {Name: "build", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, gdb.BUILD, m.Conf(GIT, kit.META_SOURCE))
|
||||
}},
|
||||
"start": {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
gdb.START: {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Optionv("prepare", func(p string) []string {
|
||||
m.Option(cli.CMD_DIR, p)
|
||||
// kit.Fetch(m.Confv(GIT, "meta.config"), func(conf string, value interface{}) {
|
||||
@ -59,7 +54,7 @@ var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||
// })
|
||||
return []string{}
|
||||
})
|
||||
m.Cmdy(code.INSTALL, "start", m.Conf(GIT, kit.META_SOURCE), "bin/git")
|
||||
m.Cmdy(code.INSTALL, gdb.START, m.Conf(GIT, kit.META_SOURCE), "bin/git")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(code.INSTALL, path.Base(m.Conf(GIT, kit.META_SOURCE)), arg)
|
||||
|
@ -1,8 +1,8 @@
|
||||
title "git"
|
||||
refer "官网" `
|
||||
官网 https://git-scm.com/
|
||||
源码 https://github.com/git/git
|
||||
文档 https://git-scm.com/docs
|
||||
源码 https://github.com/git/git
|
||||
`
|
||||
premenu
|
||||
|
||||
@ -12,18 +12,19 @@ field git web.code.inner args `[ usr/install/git-1.8.3.1/ shell.c 145 ]`
|
||||
|
||||
section "构建"
|
||||
spark shell `
|
||||
yum install -y gcc make libcurl-devel.x86_64 openssl-devel.x86_64
|
||||
yum install -y wget make gcc
|
||||
yum install -y libcurl-devel.x86_64 openssl-devel.x86_64
|
||||
|
||||
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-1.8.3.1.tar.gz
|
||||
tar xvf git-1.8.3.1.tar.gz && cd git-1.8.3.1
|
||||
|
||||
./configure --prefix=$PWD/install
|
||||
make -j4 && make install
|
||||
./configure --prefix=$PWD/_install
|
||||
make -j8 && make install
|
||||
`
|
||||
|
||||
section "启动"
|
||||
spark shell `
|
||||
cd ./install
|
||||
cd ./_install
|
||||
./bin/git
|
||||
`
|
||||
|
||||
|
@ -33,28 +33,27 @@ func init() {
|
||||
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,name,branch,last",
|
||||
"owner", "https://github.com/shylinux",
|
||||
)},
|
||||
"progress": {Name: "progress", Help: "进度", Value: kit.Data()},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
REPOS: {Name: "repos name=auto path=auto auto 添加", Help: "代码库", Action: map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: `create repos branch name path`, Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option("name", kit.Select(strings.TrimSuffix(path.Base(m.Option("repos")), ".git"), m.Option("name")))
|
||||
m.Option("path", kit.Select(path.Join("usr", m.Option("name")), m.Option("path")))
|
||||
m.Option("repos", kit.Select(m.Conf(REPOS, "meta.owner")+"/"+m.Option("name"), m.Option("repos")))
|
||||
REPOS: {Name: "repos name path auto create", Help: "代码库", Action: map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(kit.MDB_NAME, kit.Select(strings.TrimSuffix(path.Base(m.Option(kit.SSH_REPOS)), ".git"), m.Option(kit.MDB_NAME)))
|
||||
m.Option(kit.MDB_PATH, kit.Select(path.Join("usr", m.Option(kit.MDB_NAME)), m.Option(kit.MDB_PATH)))
|
||||
m.Option(kit.SSH_REPOS, kit.Select(m.Conf(REPOS, "meta.owner")+"/"+m.Option(kit.MDB_NAME), m.Option(kit.SSH_REPOS)))
|
||||
|
||||
if _, e := os.Stat(path.Join(m.Option("path"), ".git")); e != nil && os.IsNotExist(e) {
|
||||
if _, e := os.Stat(path.Join(m.Option(kit.MDB_PATH), ".git")); e != nil && os.IsNotExist(e) {
|
||||
// 下载仓库
|
||||
if _, e := os.Stat(m.Option("path")); e == nil {
|
||||
m.Option(cli.CMD_DIR, m.Option("path"))
|
||||
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("repos"))
|
||||
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.Option("repos"), m.Option("path"))
|
||||
m.Option(kit.SSH_REPOS), m.Option(kit.MDB_PATH))
|
||||
|
||||
}
|
||||
_repos_insert(m, m.Option("name"), m.Option("path"))
|
||||
_repos_insert(m, m.Option(kit.MDB_NAME), m.Option(kit.MDB_PATH))
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
@ -70,115 +69,6 @@ func init() {
|
||||
m.Cmdy(mdb.SELECT, m.Prefix(REPOS), "", mdb.HASH, kit.MDB_NAME, arg)
|
||||
m.Sort(kit.MDB_NAME)
|
||||
}},
|
||||
"status": {Name: "status name=auto auto submit compile pull", Help: "代码状态", Action: map[string]*ice.Action{
|
||||
"pull": {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option("_process", "_progress")
|
||||
if m.Richs("progress", "", m.Option("_progress"), func(key string, value map[string]interface{}) {
|
||||
m.Push("step", kit.Int(value["count"])*100/kit.Int(value["total"]))
|
||||
m.Push("count", value["count"])
|
||||
m.Push("total", value["total"])
|
||||
m.Push("name", value["name"])
|
||||
}) != nil {
|
||||
if m.Append("count") == m.Append("total") {
|
||||
m.Option("_process", "")
|
||||
m.Set(ice.MSG_APPEND)
|
||||
m.Cmdy("status")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
count, total := 0, len(m.Confm(REPOS, "hash"))
|
||||
h := m.Rich("progress", "", kit.Dict("progress", 0, "count", count, "total", total))
|
||||
m.Gos(m, func(m *ice.Message) {
|
||||
m.Richs(REPOS, nil, kit.Select(kit.MDB_FOREACH, arg, 0), func(key string, value map[string]interface{}) {
|
||||
count++
|
||||
m.Conf("progress", kit.Keys("hash", h, "name"), kit.Value(value, "meta.name"))
|
||||
m.Conf("progress", kit.Keys("hash", h, "count"), count)
|
||||
m.Conf("progress", kit.Keys("hash", h, "progress"), count*100/total)
|
||||
m.Option(cli.CMD_DIR, kit.Value(value, "meta.path"))
|
||||
m.Echo(m.Cmdx(cli.SYSTEM, GIT, "pull"))
|
||||
})
|
||||
})
|
||||
m.Option("_progress", h)
|
||||
m.Push("step", count*100/total)
|
||||
m.Push("count", count)
|
||||
m.Push("total", total)
|
||||
m.Push("name", "")
|
||||
}},
|
||||
"compile": {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, "make")
|
||||
}},
|
||||
|
||||
"add": {Name: "add", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
if strings.Contains(m.Option("name"), ":\\") {
|
||||
m.Option(cli.CMD_DIR, m.Option("name"))
|
||||
} else {
|
||||
m.Option(cli.CMD_DIR, path.Join("usr", m.Option("name")))
|
||||
}
|
||||
m.Cmdy(cli.SYSTEM, "git", "add", m.Option("file"))
|
||||
}},
|
||||
"submit": {Name: "submit action=opt,add comment=some", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option("name") == "" {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(m.Option("name"), ":\\") {
|
||||
m.Option(cli.CMD_DIR, m.Option("name"))
|
||||
} else {
|
||||
m.Option(cli.CMD_DIR, path.Join("usr", m.Option("name")))
|
||||
}
|
||||
|
||||
if arg[0] == "action" {
|
||||
m.Cmdy(cli.SYSTEM, "git", "commit", "-am", kit.Select("opt some", arg[1]+" "+arg[3]))
|
||||
} else {
|
||||
m.Cmdy(cli.SYSTEM, "git", "commit", "-am", kit.Select("opt some", strings.Join(arg, " ")))
|
||||
}
|
||||
}},
|
||||
"push": {Name: "push", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option("name") == "" {
|
||||
return
|
||||
}
|
||||
if strings.Contains(m.Option("name"), ":\\") {
|
||||
m.Option(cli.CMD_DIR, m.Option("name"))
|
||||
} else {
|
||||
m.Option(cli.CMD_DIR, path.Join("usr", m.Option("name")))
|
||||
}
|
||||
m.Cmdy(cli.SYSTEM, "git", "push")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Richs(REPOS, nil, kit.Select(kit.MDB_FOREACH, arg, 0), func(key string, value map[string]interface{}) {
|
||||
value = kit.GetMeta(value)
|
||||
|
||||
if m.Option(cli.CMD_DIR, value[kit.MDB_PATH]); len(arg) > 0 {
|
||||
m.Echo(m.Cmdx(cli.SYSTEM, GIT, "diff"))
|
||||
return // 更改详情
|
||||
}
|
||||
|
||||
// 更改列表
|
||||
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "status", "-sb")), "\n") {
|
||||
vs := strings.SplitN(strings.TrimSpace(v), " ", 2)
|
||||
m.Push("name", value[kit.MDB_NAME])
|
||||
m.Push("tags", vs[0])
|
||||
m.Push("file", vs[1])
|
||||
|
||||
list := []string{}
|
||||
switch vs[0] {
|
||||
case "##":
|
||||
if strings.Contains(vs[1], "ahead") {
|
||||
list = append(list, "push")
|
||||
}
|
||||
default:
|
||||
if strings.Contains(vs[0], "??") {
|
||||
list = append(list, "add")
|
||||
} else {
|
||||
list = append(list, "submit")
|
||||
}
|
||||
}
|
||||
m.PushButton(strings.Join(list, ","))
|
||||
}
|
||||
})
|
||||
m.Sort(kit.MDB_NAME)
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/ctx"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/core/code"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"strings"
|
||||
@ -15,20 +16,18 @@ const SPIDE = "spide"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
SPIDE: {Name: "spide path=auto file=auto auto", Help: "结构图", Meta: kit.Dict(
|
||||
SPIDE: {Name: "spide path file auto", Help: "结构图", Meta: kit.Dict(
|
||||
"display", "/plugin/story/spide.js",
|
||||
), Action: map[string]*ice.Action{
|
||||
"command": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(ctx.COMMAND, arg[0])
|
||||
}},
|
||||
ctx.COMMAND: {Name: "ctx.command"},
|
||||
code.INNER: {Name: "web.code.inner"},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
// 仓库列表
|
||||
m.Option("_display", "table")
|
||||
m.Option(ice.MSG_DISPLAY, "table")
|
||||
m.Cmdy(TOTAL, arg)
|
||||
return
|
||||
}
|
||||
|
||||
if len(arg) == 1 {
|
||||
// 目录列表
|
||||
m.Option(nfs.DIR_ROOT, arg[0])
|
||||
@ -36,16 +35,10 @@ func init() {
|
||||
m.Cmdy(nfs.DIR, "./")
|
||||
return
|
||||
}
|
||||
if len(arg) > 1 && arg[0] == "inner" {
|
||||
// 代码详情
|
||||
m.Cmdy("web.code.inner", arg[1:])
|
||||
return
|
||||
}
|
||||
|
||||
tags := ""
|
||||
m.Option(cli.CMD_DIR, arg[0])
|
||||
if strings.HasSuffix(arg[1], ".go") {
|
||||
tags = m.Cmdx(cli.SYSTEM, "gotags", arg[1])
|
||||
if m.Option(cli.CMD_DIR, arg[0]); strings.HasSuffix(arg[1], ".go") {
|
||||
tags := m.Cmdx(cli.SYSTEM, "gotags", arg[1])
|
||||
|
||||
for _, line := range strings.Split(tags, "\n") {
|
||||
if len(line) == 0 || strings.HasPrefix(line, "!_") {
|
||||
continue
|
||||
@ -74,7 +67,8 @@ func init() {
|
||||
m.Push("extra", strings.Join(ls[4:], " "))
|
||||
}
|
||||
} else {
|
||||
tags = m.Cmdx(cli.SYSTEM, "ctags", "-f", "-", arg[1])
|
||||
tags := m.Cmdx(cli.SYSTEM, "ctags", "-f", "-", arg[1])
|
||||
|
||||
for _, line := range strings.Split(tags, "\n") {
|
||||
if len(line) == 0 || strings.HasPrefix(line, "!_") {
|
||||
continue
|
||||
@ -86,7 +80,7 @@ func init() {
|
||||
m.Push("line", "1")
|
||||
}
|
||||
}
|
||||
m.Sort("line", "int")
|
||||
m.SortInt(kit.MDB_LINE)
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
|
115
misc/git/status.go
Normal file
115
misc/git/status.go
Normal file
@ -0,0 +1,115 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
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) {
|
||||
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{}) {
|
||||
value = kit.GetMeta(value)
|
||||
|
||||
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"))
|
||||
count++
|
||||
})
|
||||
cb("", total, total)
|
||||
})
|
||||
m.Cmdy(cli.PROGRESS, mdb.CREATE)
|
||||
}},
|
||||
"compile": {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, "make")
|
||||
}},
|
||||
|
||||
"add": {Name: "add", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
if strings.Contains(m.Option(kit.MDB_NAME), ":\\") {
|
||||
m.Option(cli.CMD_DIR, m.Option(kit.MDB_NAME))
|
||||
} else {
|
||||
m.Option(cli.CMD_DIR, path.Join("usr", m.Option(kit.MDB_NAME)))
|
||||
}
|
||||
m.Cmdy(cli.SYSTEM, GIT, "add", m.Option(kit.MDB_FILE))
|
||||
}},
|
||||
"submit": {Name: "submit action=opt,add comment=some", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(kit.MDB_NAME) == "" {
|
||||
return
|
||||
}
|
||||
if strings.Contains(m.Option(kit.MDB_NAME), ":\\") {
|
||||
m.Option(cli.CMD_DIR, m.Option(kit.MDB_NAME))
|
||||
} else {
|
||||
m.Option(cli.CMD_DIR, path.Join("usr", m.Option(kit.MDB_NAME)))
|
||||
}
|
||||
|
||||
if arg[0] == "action" {
|
||||
m.Cmdy(cli.SYSTEM, GIT, "commit", "-am", kit.Select("opt some", arg[1]+" "+arg[3]))
|
||||
} else {
|
||||
m.Cmdy(cli.SYSTEM, GIT, "commit", "-am", kit.Select("opt some", strings.Join(arg, " ")))
|
||||
}
|
||||
}},
|
||||
"push": {Name: "push", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(kit.MDB_NAME) == "" {
|
||||
return
|
||||
}
|
||||
if strings.Contains(m.Option(kit.MDB_NAME), ":\\") {
|
||||
m.Option(cli.CMD_DIR, m.Option(kit.MDB_NAME))
|
||||
} else {
|
||||
m.Option(cli.CMD_DIR, path.Join("usr", m.Option(kit.MDB_NAME)))
|
||||
}
|
||||
m.Cmdy(cli.SYSTEM, GIT, "push")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Richs(REPOS, nil, kit.Select(kit.MDB_FOREACH, arg, 0), func(key string, value map[string]interface{}) {
|
||||
value = kit.GetMeta(value)
|
||||
|
||||
if m.Option(cli.CMD_DIR, value[kit.MDB_PATH]); len(arg) > 0 {
|
||||
m.Echo(m.Cmdx(cli.SYSTEM, GIT, "diff"))
|
||||
return // 更改详情
|
||||
}
|
||||
|
||||
// 更改列表
|
||||
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "status", "-sb")), "\n") {
|
||||
vs := strings.SplitN(strings.TrimSpace(v), " ", 2)
|
||||
m.Push("name", value[kit.MDB_NAME])
|
||||
m.Push("tags", vs[0])
|
||||
m.Push("file", vs[1])
|
||||
|
||||
list := []string{}
|
||||
switch vs[0] {
|
||||
case "##":
|
||||
if strings.Contains(vs[1], "ahead") {
|
||||
list = append(list, "push")
|
||||
}
|
||||
default:
|
||||
if strings.Contains(vs[0], "??") {
|
||||
list = append(list, "add")
|
||||
} else {
|
||||
list = append(list, "submit")
|
||||
}
|
||||
}
|
||||
m.PushButton(strings.Join(list, ","))
|
||||
}
|
||||
})
|
||||
m.Sort(kit.MDB_NAME)
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
}
|
@ -23,7 +23,7 @@ func init() {
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
TOTAL: {Name: "total name=auto auto", Help: "提交统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
TOTAL: {Name: "total name auto", Help: "提交统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
// 提交详情
|
||||
m.Richs(REPOS, nil, arg[0], func(key string, value map[string]interface{}) {
|
||||
@ -33,15 +33,15 @@ func init() {
|
||||
}
|
||||
|
||||
// 提交统计
|
||||
days := 0
|
||||
commit, adds, dels, rest := 0, 0, 0, 0
|
||||
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{}) {
|
||||
if m.Conf(TOTAL, kit.Keys("meta.skip", kit.Value(value, "meta.name"))) == "true" {
|
||||
return
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
m.Gos(m, func(m *ice.Message) {
|
||||
m.Go(func() {
|
||||
msg := m.Cmd("_sum", kit.Value(value, "meta.path"), "total", "10000").Table(func(index int, value map[string]string, head []string) {
|
||||
if kit.Int(value["days"]) > days {
|
||||
days = kit.Int(value["days"])
|
||||
@ -57,13 +57,14 @@ func init() {
|
||||
})
|
||||
})
|
||||
wg.Wait()
|
||||
|
||||
m.Push("name", "total")
|
||||
m.Push("days", kit.Int(days)+1)
|
||||
m.Push("commit", commit)
|
||||
m.Push("adds", adds)
|
||||
m.Push("dels", dels)
|
||||
m.Push("rest", rest)
|
||||
m.Sort("rest", "int_r")
|
||||
m.SortIntR("rest")
|
||||
}},
|
||||
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
@ -104,7 +105,6 @@ func init() {
|
||||
dels := strings.Split(fs[2], " ")
|
||||
add = adds[0]
|
||||
del = dels[0]
|
||||
// } else if adds[1] == "insertions(+)" {
|
||||
} else if strings.Contains(adds[1], "insertion") {
|
||||
add = adds[0]
|
||||
} else {
|
||||
@ -133,6 +133,7 @@ func init() {
|
||||
m.Push("time", hs[1])
|
||||
}
|
||||
}
|
||||
|
||||
if total {
|
||||
m.Push("days", int(total_day.Hours())/24)
|
||||
m.Push("commit", count)
|
||||
|
@ -10,11 +10,11 @@ const TREND = "trend"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
TREND: {Name: "trend name=auto begin_time@date auto", Help: "趋势图", Meta: kit.Dict(
|
||||
TREND: {Name: "trend name 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) {
|
||||
if len(arg) == 0 {
|
||||
m.Option("_display", "table")
|
||||
m.Option(ice.MSG_DISPLAY, "table")
|
||||
}
|
||||
m.Cmdy(TOTAL, arg)
|
||||
}},
|
||||
|
@ -71,8 +71,8 @@ var Index = &ice.Context{Name: TMUX, Help: "工作台",
|
||||
m.Cmdy(code.INSTALL, path.Base(m.Conf(TMUX, kit.META_SOURCE)), arg)
|
||||
}},
|
||||
|
||||
TEXT: {Name: "text 查看:button save 清空 text:textarea", Help: "文本", Action: map[string]*ice.Action{
|
||||
"save": {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
TEXT: {Name: "text auto save text:textarea", Help: "文本", Action: map[string]*ice.Action{
|
||||
nfs.SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] != "" {
|
||||
m.Cmd(cli.SYSTEM, TMUX, "set-buffer", arg[0])
|
||||
}
|
||||
@ -80,8 +80,8 @@ var Index = &ice.Context{Name: TMUX, Help: "工作台",
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
text := m.Cmdx(cli.SYSTEM, TMUX, "show-buffer")
|
||||
m.Cmdy(wiki.SPARK, "inner", text)
|
||||
m.Cmdy(wiki.IMAGE, "qrcode", text)
|
||||
m.Cmdy(wiki.SPARK, "inner", text)
|
||||
m.Render("")
|
||||
}},
|
||||
BUFFER: {Name: "buffer name value auto export import", Help: "缓存", Action: map[string]*ice.Action{
|
||||
|
@ -12,7 +12,8 @@ field tmux web.code.inner args `[ usr/install/tmux-3.1b cmd-bind-key.c ]`
|
||||
|
||||
section "构建"
|
||||
spark shell `
|
||||
yum install -y wget make gcc libevent-devel.x86_64 ncurses-devel.x86_64
|
||||
yum install -y wget make gcc
|
||||
yum install -y libevent-devel.x86_64 ncurses-devel.x86_64
|
||||
|
||||
wget https://github.com/tmux/tmux/releases/download/3.1b/tmux-3.1b.tar.gz
|
||||
tar xvf tmux-3.1b.tar.gz && cd tmux-3.1b
|
||||
|
Loading…
x
Reference in New Issue
Block a user