From aa2f7b0e007d1b853fe6c1fc8d6ac50d197892e0 Mon Sep 17 00:00:00 2001 From: shaoying Date: Fri, 10 Apr 2020 16:26:46 +0800 Subject: [PATCH] opt vim --- core/code/code.go | 44 +++++++++++++++++++++----------------------- misc/git/git.go | 22 ++++++++++++++++------ misc/vim/vim.go | 33 ++++++++++++++++++--------------- 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/core/code/code.go b/core/code/code.go index aab0e206..1c4d79ab 100644 --- a/core/code/code.go +++ b/core/code/code.go @@ -1,9 +1,9 @@ package code import ( - "github.com/shylinux/icebergs" + ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/web" - "github.com/shylinux/toolkits" + kit "github.com/shylinux/toolkits" "os" "path" @@ -16,19 +16,12 @@ import ( var Index = &ice.Context{Name: "code", Help: "编程中心", Caches: map[string]*ice.Cache{}, Configs: map[string]*ice.Config{ - "prepare": {Name: "prepare", Help: "准备", Value: kit.Data("path", "usr/prepare", - "tool", kit.Dict( - "vim", []interface{}{ - "wget ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2", - "tar xvf vim-8.1.tar.bz2", - "cd vim81", - - "./configure --prefix=/home/shaoying/usr/vim --enable-multibyte=yes --enable-cscope=yes --enable-luainterp=yes --enable-pythoninterp=yes", - "make -j4", - "make install", - }, - ), + "install": {Name: "install", Help: "安装", Value: kit.Data("path", "usr/install", + "source", "https://dl.google.com/go/go1.14.2.src.tar.gz", )}, + "prepare": {Name: "prepare", Help: "准备", Value: kit.Data("path", "usr/prepare")}, + "project": {Name: "project", Help: "项目", Value: kit.Data("path", "usr/prepare")}, + "compile": {Name: "compile", Help: "编译", Value: kit.Data("path", "usr/publish")}, "publish": {Name: "publish", Help: "发布", Value: kit.Data("path", "usr/publish")}, "upgrade": {Name: "upgrade", Help: "升级", Value: kit.Dict(kit.MDB_HASH, kit.Dict( @@ -38,14 +31,23 @@ var Index = &ice.Context{Name: "code", Help: "编程中心", )), ))}, - "login": {Name: "login", Help: "登录", Value: kit.Data()}, - - "pprof": {Name: "pprof", Help: "性能分析", Value: kit.Data( - kit.MDB_SHORT, kit.MDB_NAME, + "pprof": {Name: "pprof", Help: "性能分析", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME, "stop", "ps aux|grep pprof|grep -v grep|cut -d' ' -f2|xargs -n1 kill", )}, + "login": {Name: "login", Help: "终端接入", Value: kit.Data()}, }, Commands: map[string]*ice.Command{ + ice.CODE_INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + p := path.Join(m.Conf("install", "meta.path"), "go") + if _, e := os.Stat(p); e != nil { + m.Option("cmd_dir", m.Conf("install", "meta.path")) + m.Cmd(ice.CLI_SYSTEM, "wget", "-O", "go.tar.gz", m.Conf("install", "meta.source")) + m.Cmd(ice.CLI_SYSTEM, "tar", "xvf", "go.tar.gz") + } + }}, + ice.CODE_PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }}, + ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }}, @@ -60,6 +62,7 @@ var Index = &ice.Context{Name: "code", Help: "编程中心", switch arg[1] { case "prune", "清理": m.Cmdy("login", "prune") + case "clear", "清空": case "modify", "编辑": m.Richs("login", nil, m.Option("key"), func(key string, value map[string]interface{}) { @@ -140,11 +143,6 @@ var Index = &ice.Context{Name: "code", Help: "编程中心", } }}, - ice.CODE_INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - }}, - ice.CODE_PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Cmd(ice.CLI_SYSTEM, "go", "get", "github.com/gotags") - }}, "prepare": {Name: "prepare", Help: "准备", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }}, diff --git a/misc/git/git.go b/misc/git/git.go index e5d75459..087a7350 100644 --- a/misc/git/git.go +++ b/misc/git/git.go @@ -1,9 +1,9 @@ package git import ( - "github.com/shylinux/icebergs" + ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/core/code" - "github.com/shylinux/toolkits" + kit "github.com/shylinux/toolkits" "os" "path" @@ -29,16 +29,21 @@ var Index = &ice.Context{Name: "git", Help: "代码库", Configs: map[string]*ice.Config{ "git": {Name: "git", Help: "代码库", Value: kit.Data( "source", "https://github.com/git/git.git", + "config", kit.Dict( + "alias", kit.Dict("s", "status", "b", "branch"), + "color", kit.Dict("ui", "true"), + ), )}, + "repos": {Name: "repos", Help: "仓库", Value: kit.Data(kit.MDB_SHORT, "name", "owner", "https://github.com/shylinux")}, "total": {Name: "total", Help: "统计", Value: kit.Data(kit.MDB_SHORT, "name", "skip", kit.Dict("wubi-dict", "true", "word-dict", "true"))}, }, Commands: map[string]*ice.Command{ ice.CODE_INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Option("cmd_dir", "usr") - msg := m.Cmd(ice.CLI_SYSTEM, "git", "clone", m.Conf("git", "meta.git")) + m.Option("cmd_dir", m.Conf("install", "meta.path")) + m.Cmd(ice.CLI_SYSTEM, "git", "clone", m.Conf("git", "meta.source")) - m.Option("cmd_dir", "usr/git") + m.Option("cmd_dir", path.Join(m.Conf("install", "meta.path"), "git")) m.Cmd(ice.CLI_SYSTEM, "make", "configure") m.Cmd(ice.CLI_SYSTEM, "./configure", "--prefix="+kit.Path("usr/local")) @@ -46,8 +51,13 @@ var Index = &ice.Context{Name: "git", Help: "代码库", m.Cmd(ice.CLI_SYSTEM, "make", "install") }}, ice.CODE_PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - + kit.Fetch(m.Confv("git", "meta.config"), func(conf string, value interface{}) { + kit.Fetch(value, func(key string, value string) { + m.Cmd(ice.CLI_SYSTEM, "git", "config", "--global", conf+"."+key, value) + }) + }) }}, + "init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { // 系统项目 wd, _ := os.Getwd() diff --git a/misc/vim/vim.go b/misc/vim/vim.go index ad0addc9..3be93a4f 100644 --- a/misc/vim/vim.go +++ b/misc/vim/vim.go @@ -1,10 +1,13 @@ package vim import ( - "github.com/shylinux/icebergs" + "os" + "path" + + ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/web" "github.com/shylinux/icebergs/core/code" - "github.com/shylinux/toolkits" + kit "github.com/shylinux/toolkits" "io/ioutil" "strings" @@ -14,26 +17,26 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器", Caches: map[string]*ice.Cache{}, Configs: map[string]*ice.Config{ "vim": {Name: "vim", Help: "编辑器", Value: kit.Data( - kit.MDB_SHORT, "name", "history", "vim.history", - "version", "vim81", "source", "ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2", + "version", "vim81", + + kit.MDB_SHORT, "name", "history", "vim.history", "script", "", )}, }, Commands: map[string]*ice.Command{ ice.CODE_INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - msg := m.Cmd(ice.WEB_SPIDE, "dev", "cache", m.Conf("vim", "meta.source")) - m.Cmd(ice.WEB_CACHE, "watch", msg.Append("data"), "usr/vim.tar.gz") + p := path.Join(m.Conf("install", "meta.path"), m.Conf("vim", "meta.version")) + if _, e := os.Stat(p); e != nil { + m.Option("cmd_dir", m.Conf("install", "meta.path")) + m.Cmd(ice.CLI_SYSTEM, "wget", "-O", "vim.tar.gz", m.Conf("vim", "meta.source")) + m.Cmd(ice.CLI_SYSTEM, "tar", "xvf", "vim.tar.gz") + } - m.Option("cmd_dir", "usr") - m.Cmd(ice.CLI_SYSTEM, "tar", "xvf", "vim.tar.gz") - m.Option("cmd_dir", "usr/"+m.Conf("vim", "meta.version")) - m.Cmd(ice.CLI_SYSTEM, "./configure", - "--prefix="+kit.Path("usr/vim"), - "--enable-multibyte=yes", - "--enable-cscope=yes", - "--enable-luainterp=yes", - "--enable-pythoninterp=yes", + m.Option("cmd_dir", p) + m.Cmd(ice.CLI_SYSTEM, "./configure", "--enable-multibyte=yes", + "--prefix="+kit.Path("usr/local"), "--enable-cscope=yes", + "--enable-luainterp=yes", "--enable-pythoninterp=yes", ) m.Cmd(ice.CLI_SYSTEM, "make", "-j4")