forked from x/icebergs
add code_prepare
This commit is contained in:
parent
2e04e6328e
commit
8fbff545c7
@ -90,6 +90,19 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块",
|
|||||||
if len(cmd.Env) > 0 {
|
if len(cmd.Env) > 0 {
|
||||||
m.Info("env: %s", cmd.Env)
|
m.Info("env: %s", cmd.Env)
|
||||||
}
|
}
|
||||||
|
if m.Option("cmd_stdout") != "" {
|
||||||
|
if f, p, e := kit.Create(m.Option("cmd_stdout")); m.Assert(e) {
|
||||||
|
m.Info("stdout: %s", p)
|
||||||
|
cmd.Stdout = f
|
||||||
|
cmd.Stderr = f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m.Option("cmd_stderr") != "" {
|
||||||
|
if f, p, e := kit.Create(m.Option("cmd_stderr")); m.Assert(e) {
|
||||||
|
m.Info("stderr: %s", p)
|
||||||
|
cmd.Stderr = f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch m.Option("cmd_type") {
|
switch m.Option("cmd_type") {
|
||||||
case "daemon":
|
case "daemon":
|
||||||
|
4
conf.go
4
conf.go
@ -187,6 +187,10 @@ const ( // TYPE
|
|||||||
TYPE_INNER = "inner"
|
TYPE_INNER = "inner"
|
||||||
TYPE_MEDIA = "media"
|
TYPE_MEDIA = "media"
|
||||||
)
|
)
|
||||||
|
const ( // CODE
|
||||||
|
CODE_INSTALL = "_install"
|
||||||
|
CODE_PREPARE = "_prepare"
|
||||||
|
)
|
||||||
const ( // CHAT
|
const ( // CHAT
|
||||||
CHAT_RIVER = "river"
|
CHAT_RIVER = "river"
|
||||||
CHAT_STORM = "storm"
|
CHAT_STORM = "storm"
|
||||||
|
@ -16,6 +16,19 @@ import (
|
|||||||
var Index = &ice.Context{Name: "code", Help: "编程中心",
|
var Index = &ice.Context{Name: "code", Help: "编程中心",
|
||||||
Caches: map[string]*ice.Cache{},
|
Caches: map[string]*ice.Cache{},
|
||||||
Configs: map[string]*ice.Config{
|
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",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)},
|
||||||
"compile": {Name: "compile", Help: "编译", Value: kit.Data("path", "usr/publish")},
|
"compile": {Name: "compile", Help: "编译", Value: kit.Data("path", "usr/publish")},
|
||||||
"publish": {Name: "publish", 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(
|
"upgrade": {Name: "upgrade", Help: "升级", Value: kit.Dict(kit.MDB_HASH, kit.Dict(
|
||||||
@ -127,6 +140,15 @@ 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) {
|
||||||
|
|
||||||
|
}},
|
||||||
|
|
||||||
"compile": {Name: "compile [os [arch]]", Help: "编译", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"compile": {Name: "compile [os [arch]]", Help: "编译", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
// 目录列表
|
// 目录列表
|
||||||
|
@ -13,10 +13,37 @@ import (
|
|||||||
var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
||||||
Caches: map[string]*ice.Cache{},
|
Caches: map[string]*ice.Cache{},
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
"vim": {Name: "vim", Help: "编辑器", Value: kit.Data(kit.MDB_SHORT, "name", "history", "vim.history")},
|
"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",
|
||||||
|
"script", "",
|
||||||
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.WEB_LOGIN: {Name: "_login", Help: "_login", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
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")
|
||||||
|
|
||||||
|
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.Cmd(ice.CLI_SYSTEM, "make", "-j4")
|
||||||
|
m.Cmd(ice.CLI_SYSTEM, "make", "install")
|
||||||
|
}},
|
||||||
|
ice.CODE_PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
|
||||||
|
}},
|
||||||
|
|
||||||
|
ice.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if f, _, e := m.R.FormFile("sub"); e == nil {
|
if f, _, e := m.R.FormFile("sub"); e == nil {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if b, e := ioutil.ReadAll(f); e == nil {
|
if b, e := ioutil.ReadAll(f); e == nil {
|
||||||
|
@ -1 +1,24 @@
|
|||||||
title "vim"
|
title "vim"
|
||||||
|
|
||||||
|
refer "官网" `
|
||||||
|
官网 https://www.vim.org/
|
||||||
|
下载 https://www.vim.org/download.php
|
||||||
|
源码 ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2
|
||||||
|
`
|
||||||
|
chapter "安装"
|
||||||
|
spark "下载" `
|
||||||
|
wget ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2
|
||||||
|
tar xvf vim-8.1.tar.bz2
|
||||||
|
cd vim81
|
||||||
|
`
|
||||||
|
|
||||||
|
spark "安装" `
|
||||||
|
yum install gcc
|
||||||
|
yum install python-devel
|
||||||
|
`
|
||||||
|
|
||||||
|
spark "编译" `
|
||||||
|
./configure --prefix=/home/shaoying/usr/vim --enable-multibyte=yes --enable-cscope=yes --enable-luainterp=yes --enable-pythoninterp=yes
|
||||||
|
make -j4
|
||||||
|
make install
|
||||||
|
`
|
||||||
|
@ -82,30 +82,37 @@ ShyLogout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 发送文件
|
# 发送文件
|
||||||
ShyDownload() {
|
|
||||||
${ctx_curl} -s "${ctx_url}download" -F "cmds=$1" \
|
|
||||||
-F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}"
|
|
||||||
}
|
|
||||||
ShyUpload() {
|
|
||||||
${ctx_curl} -s "${ctx_url}upload" -F "upload=@$1" \
|
|
||||||
-F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}"
|
|
||||||
}
|
|
||||||
ShySend() {
|
ShySend() {
|
||||||
local TEMP=`mktemp /tmp/tmp.XXXXXX` && "$@" > $TEMP
|
local TEMP=`mktemp /tmp/tmp.XXXXXX` && "$@" > $TEMP
|
||||||
ShyRight "$ctx_silent" || cat $TEMP
|
ShyRight "$ctx_silent" || cat $TEMP
|
||||||
${ctx_curl} -s "${ctx_url}sync" -F "cmds=$1" -F "cmds=$*" -F "sub=@$TEMP" \
|
${ctx_curl} -s "${ctx_url}sync" -F "cmds=$1" -F "cmds=$*" -F "sub=@$TEMP" \
|
||||||
-F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}"
|
-F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}"
|
||||||
}
|
}
|
||||||
|
ShyUpload() {
|
||||||
ShyLocal() {
|
${ctx_curl} -s "${ctx_url}upload" -F "upload=@$1" \
|
||||||
which=alpine && [ "$1" != "" ] && which=$1 && shift
|
-F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}"
|
||||||
favor=tmux.auto && [ "$1" != "" ] && favor=$1 && shift
|
|
||||||
step=before arg="" && for cmd in "$@"; do
|
|
||||||
[ "$cmd" = after ] && step=after && continue
|
|
||||||
arg="$arg&$step="`ShyWord $cmd`
|
|
||||||
done
|
|
||||||
${ctx_curl} -s "$ctx_dev/code/tmux/favor?local=$which&cmds=$favor&$arg" &
|
|
||||||
}
|
}
|
||||||
|
ShyDownload() {
|
||||||
|
${ctx_curl} -s "${ctx_url}download" -F "cmds=$1" \
|
||||||
|
-F "SHELL=${SHELL}" -F "pwd=${PWD}" -F "sid=${ctx_sid}"
|
||||||
|
}
|
||||||
|
ShyInstall() {
|
||||||
|
case "$1" in
|
||||||
|
"vim")
|
||||||
|
# git vim
|
||||||
|
curl -fLo ~/.vimrc https://raw.githubusercontent.com/shylinux/contexts/master/etc/conf/vimrc
|
||||||
|
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
|
vim -c PlugInstall
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
ShyUpgrade() {
|
||||||
|
file=auto.sh && [ "$1" != "" ] && file=$1
|
||||||
|
${ctx_curl} -s $ctx_dev/publish/$file > $file && source auto.sh
|
||||||
|
}
|
||||||
|
|
||||||
ShyRelay() {
|
ShyRelay() {
|
||||||
which=relay && [ "$1" != "" ] && which=$1 && shift
|
which=relay && [ "$1" != "" ] && which=$1 && shift
|
||||||
favor=tmux.auto && [ "$1" != "" ] && favor=$1 && shift
|
favor=tmux.auto && [ "$1" != "" ] && favor=$1 && shift
|
||||||
@ -115,7 +122,35 @@ ShyRelay() {
|
|||||||
done
|
done
|
||||||
${ctx_curl} -s "$ctx_dev/code/tmux/favor?relay=$which&cmds=$favor&$arg" &
|
${ctx_curl} -s "$ctx_dev/code/tmux/favor?relay=$which&cmds=$favor&$arg" &
|
||||||
}
|
}
|
||||||
|
ShyLocal() {
|
||||||
|
which=alpine && [ "$1" != "" ] && which=$1 && shift
|
||||||
|
favor=tmux.auto && [ "$1" != "" ] && favor=$1 && shift
|
||||||
|
step=before arg="" && for cmd in "$@"; do
|
||||||
|
[ "$cmd" = after ] && step=after && continue
|
||||||
|
arg="$arg&$step="`ShyWord $cmd`
|
||||||
|
done
|
||||||
|
${ctx_curl} -s "$ctx_dev/code/tmux/favor?local=$which&cmds=$favor&$arg" &
|
||||||
|
}
|
||||||
|
ShyFavor() {
|
||||||
|
cmd=$1; [ "$READLINE_LINE" != "" ] && set $READLINE_LINE && READLINE_LINE=""
|
||||||
|
if [ "$cmd" = "sh" ] ; then
|
||||||
|
# 查看收藏
|
||||||
|
ctx_word="sh"
|
||||||
|
shift && [ "$1" != "" ] && ctx_tab="$1"
|
||||||
|
shift && ctx_note="$1"
|
||||||
|
else
|
||||||
|
# 添加收藏
|
||||||
|
[ "$1" != "" ] && ctx_word="$*" || ctx_word=`history|tail -n1|head -n1|sed -e 's/^[\ 0-9]*//g'`
|
||||||
|
fi
|
||||||
|
ShyPost favor "${ctx_word}" tab "${ctx_tab}" note "${ctx_note}"
|
||||||
|
}
|
||||||
|
ShyInput() {
|
||||||
|
if [ "$1" = "line" ] ; then
|
||||||
|
READLINE_LINE=`ShyPost input "$1" line "$READLINE_LINE" point "$READLINE_POINT"`
|
||||||
|
else
|
||||||
|
COMPREPLY=(`ShyPost input "$COMP_WORDS" line "$COMP_LINE" index "$COMP_CWORD" break "$COMP_WORDBREAKS"`)
|
||||||
|
fi
|
||||||
|
}
|
||||||
# 同步数据
|
# 同步数据
|
||||||
ShySync() {
|
ShySync() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -140,31 +175,6 @@ ShySync() {
|
|||||||
*) ShySend "$@"
|
*) ShySend "$@"
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
ShyInput() {
|
|
||||||
if [ "$1" = "line" ] ; then
|
|
||||||
READLINE_LINE=`ShyPost input "$1" line "$READLINE_LINE" point "$READLINE_POINT"`
|
|
||||||
else
|
|
||||||
COMPREPLY=(`ShyPost input "$COMP_WORDS" line "$COMP_LINE" index "$COMP_CWORD" break "$COMP_WORDBREAKS"`)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
ShyFavor() {
|
|
||||||
cmd=$1; [ "$READLINE_LINE" != "" ] && set $READLINE_LINE && READLINE_LINE=""
|
|
||||||
if [ "$cmd" = "sh" ] ; then
|
|
||||||
# 查看收藏
|
|
||||||
ctx_word="sh"
|
|
||||||
shift && [ "$1" != "" ] && ctx_tab="$1"
|
|
||||||
shift && ctx_note="$1"
|
|
||||||
else
|
|
||||||
# 添加收藏
|
|
||||||
[ "$1" != "" ] && ctx_word="$*" || ctx_word=`history|tail -n1|head -n1|sed -e 's/^[\ 0-9]*//g'`
|
|
||||||
fi
|
|
||||||
ShyPost favor "${ctx_word}" tab "${ctx_tab}" note "${ctx_note}"
|
|
||||||
}
|
|
||||||
|
|
||||||
ShyUpgrade() {
|
|
||||||
file=auto.sh && [ "$1" != "" ] && file=$1
|
|
||||||
${ctx_curl} -s $ctx_dev/publish/$file > $file && source auto.sh
|
|
||||||
}
|
|
||||||
ShyInit() {
|
ShyInit() {
|
||||||
[ "$ctx_begin" = "" ] && ctx_begin=`history|tail -n1|awk '{print $1}'`
|
[ "$ctx_begin" = "" ] && ctx_begin=`history|tail -n1|awk '{print $1}'`
|
||||||
|
|
||||||
|
@ -26,10 +26,9 @@ var Index = &ice.Context{Name: "zsh", Help: "命令行",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option("you", "tmux")
|
// 查找空间
|
||||||
m.Richs("login", nil, m.Option("sid"), func(key string, value map[string]interface{}) {
|
m.Richs("login", nil, m.Option("sid"), func(key string, value map[string]interface{}) {
|
||||||
// 查找空间
|
m.Option("you", kit.Select("tmux", value["you"]))
|
||||||
m.Option("you", value["you"])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Info("%s %s cmd: %v sub: %v", m.Option("you"), m.Option(ice.MSG_USERURL), m.Optionv("cmds"), m.Optionv("sub"))
|
m.Info("%s %s cmd: %v sub: %v", m.Option("you"), m.Option(ice.MSG_USERURL), m.Optionv("cmds"), m.Optionv("sub"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user