1
0
forked from x/icebergs
This commit is contained in:
shylinux@163.com 2022-08-26 10:38:37 +08:00
parent 7537ef343b
commit 8f12abd2f5
15 changed files with 57 additions and 28 deletions

View File

@ -1,4 +1,6 @@
package lex package lex
const REGEXP = "regexp"
const PREFIX = "prefix" const PREFIX = "prefix"
const SUFFIX = "suffix"
const REGEXP = "regexp"
const PATTERN = "pattern"

View File

@ -273,16 +273,26 @@ func HashImport(m *ice.Message, arg ...Any) *ice.Message {
return m.Cmdy(IMPORT, m.PrefixKey(), "", HASH, arg) return m.Cmdy(IMPORT, m.PrefixKey(), "", HASH, arg)
} }
func HashTarget(m *ice.Message, h string, add func() Any) (p Any) { func HashTarget(m *ice.Message, h string, add Any) (p Any) {
HashSelectUpdate(m, h, func(value ice.Map) { HashSelectUpdate(m, h, func(value ice.Map) {
p = value[TARGET] p = value[TARGET]
if pp, ok := p.(Map); ok && len(pp) == 0 { if pp, ok := p.(Map); ok && len(pp) == 0 {
p = nil p = nil
} }
if p == nil && add != nil { if p == nil && add != nil {
switch add := add.(type) {
case func(ice.Map) ice.Any:
p = add(value)
m.Debug("what %v %T", p, p)
case func() ice.Any:
p = add() p = add()
default:
m.ErrorNotImplement(p)
return
}
value[TARGET] = p value[TARGET] = p
} }
m.Debug("what %v %T", p, p)
}) })
return return
} }

View File

@ -149,13 +149,16 @@ func CloseFile(m *ice.Message, p ice.Any) {
func CopyFile(m *ice.Message, to io.WriteCloser, from io.ReadCloser, cb func(int)) { func CopyFile(m *ice.Message, to io.WriteCloser, from io.ReadCloser, cb func(int)) {
buf := make([]byte, 1024*1024) buf := make([]byte, 1024*1024)
total := 0
for { for {
n, e := from.Read(buf) n, e := from.Read(buf)
to.Write(buf[:n])
cb(n)
total += n
m.Debug("what %v %v %v", n, total, e)
if e != nil { if e != nil {
break break
} }
to.Write(buf[:n])
cb(n)
} }
} }

View File

@ -38,8 +38,6 @@ func _spide_create(m *ice.Message, name, address string) {
} }
func _spide_list(m *ice.Message, arg ...string) { func _spide_list(m *ice.Message, arg ...string) {
msg := mdb.HashSelects(m.Spawn(), arg[0]) msg := mdb.HashSelects(m.Spawn(), arg[0])
m.Debug("what %v", msg.FormatMeta())
m.Debug("what %v", msg.Append(arg[1]))
if len(arg) == 2 && msg.Append(arg[1]) != "" { if len(arg) == 2 && msg.Append(arg[1]) != "" {
m.Echo(msg.Append(arg[1])) m.Echo(msg.Append(arg[1]))
return return
@ -242,6 +240,7 @@ func _spide_send(m *ice.Message, name string, req *http.Request, timeout string)
return client.Do(req) return client.Do(req)
} }
func _spide_save(m *ice.Message, cache, save, uri string, res *http.Response) { func _spide_save(m *ice.Message, cache, save, uri string, res *http.Response) {
m.Debug("what %v", m.OptionCB(""))
switch cache { switch cache {
case SPIDE_RAW: case SPIDE_RAW:
b, _ := ioutil.ReadAll(res.Body) b, _ := ioutil.ReadAll(res.Body)
@ -266,11 +265,13 @@ func _spide_save(m *ice.Message, cache, save, uri string, res *http.Response) {
defer f.Close() defer f.Close()
total := kit.Int(res.Header.Get(ContentLength)) + 1 total := kit.Int(res.Header.Get(ContentLength)) + 1
m.Debug("what %v", m.OptionCB(""))
switch cb := m.OptionCB("").(type) { switch cb := m.OptionCB("").(type) {
case func(int, int, int): case func(int, int, int):
count := 0 count := 0
nfs.CopyFile(m, f, res.Body, func(n int) { nfs.CopyFile(m, f, res.Body, func(n int) {
count += n count += n
m.Debug("what %v %v", n, count)
cb(count, total, count*100/total) cb(count, total, count*100/total)
}) })
default: default:

View File

@ -57,6 +57,7 @@ func _install_download(m *ice.Message) {
web.PushNoticeRefresh(m) web.PushNoticeRefresh(m)
web.ToastSuccess(m) web.ToastSuccess(m)
}) })
m.SetResult()
} }
func _install_build(m *ice.Message, arg ...string) string { func _install_build(m *ice.Message, arg ...string) string {
p := m.Option(cli.CMD_DIR, _install_path(m, "")) p := m.Option(cli.CMD_DIR, _install_path(m, ""))
@ -128,7 +129,8 @@ func _install_start(m *ice.Message, arg ...string) {
m.ErrorNotImplement(cb) m.ErrorNotImplement(cb)
} }
if m.Cmdy(cli.DAEMON, arg[1:], args); cli.IsSuccess(m) { bin := kit.Split(path.Base(arg[0]), "-.")[0]
if m.Cmdy(cli.DAEMON, kit.Select(path.Join(ice.BIN, bin), arg, 1), kit.Slice(arg, 2), args); cli.IsSuccess(m) {
m.SetAppend() m.SetAppend()
} }
} }
@ -140,6 +142,14 @@ func _install_stop(m *ice.Message, arg ...string) {
}) })
m.Cmd(gdb.SIGNAL, gdb.KILL, m.Option(cli.PID)) m.Cmd(gdb.SIGNAL, gdb.KILL, m.Option(cli.PID))
} }
func _install_trash(m *ice.Message, arg ...string) {
m.Cmd(cli.DAEMON, func(value ice.Maps) {
if value[cli.PID] == m.Option(cli.PID) {
m.Cmd(cli.DAEMON, mdb.REMOVE, kit.Dict(mdb.HASH, value[mdb.HASH]))
}
})
m.Cmd(nfs.TRASH, kit.Path(ice.USR_LOCAL_DAEMON, m.Option(tcp.PORT), m.Option(nfs.PATH)))
}
func _install_service(m *ice.Message, arg ...string) { func _install_service(m *ice.Message, arg ...string) {
arg = kit.Split(path.Base(arg[0]), "-.")[:1] arg = kit.Split(path.Base(arg[0]), "-.")[:1]
m.Fields(len(arg[1:]), "time,port,status,pid,cmd,dir") m.Fields(len(arg[1:]), "time,port,status,pid,cmd,dir")
@ -184,6 +194,9 @@ func init() {
cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) { cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
_install_stop(m, arg...) _install_stop(m, arg...)
}}, }},
nfs.TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
_install_trash(m, arg...)
}},
nfs.SOURCE: {Name: "source link path", Help: "源码", Hand: func(m *ice.Message, arg ...string) { nfs.SOURCE: {Name: "source link path", Help: "源码", Hand: func(m *ice.Message, arg ...string) {
if m.Option(nfs.DIR_ROOT, path.Join(_install_path(m, ""), _INSTALL)); !nfs.ExistsFile(m, m.Option(nfs.DIR_ROOT)) { if m.Option(nfs.DIR_ROOT, path.Join(_install_path(m, ""), _INSTALL)); !nfs.ExistsFile(m, m.Option(nfs.DIR_ROOT)) {
m.Option(nfs.DIR_ROOT, path.Join(_install_path(m, ""))) m.Option(nfs.DIR_ROOT, path.Join(_install_path(m, "")))

View File

@ -130,7 +130,7 @@ func (m *Message) Design(action Any, help string, input ...Any) {
for _, input := range input { for _, input := range input {
switch input := input.(type) { switch input := input.(type) {
case string: case string:
list = append(list, SplitCmd("action "+input)...) list = append(list, SplitCmd("action "+input, nil)...)
case Map: case Map:
if kit.Format(input[TYPE]) != "" && kit.Format(input[NAME]) != "" { if kit.Format(input[TYPE]) != "" && kit.Format(input[NAME]) != "" {
list = append(list, input) list = append(list, input)
@ -333,7 +333,7 @@ func MergeActions(list ...Any) Actions {
} }
return base return base
} }
func SplitCmd(name string) (list []Any) { func SplitCmd(name string, actions Actions) (list []Any) {
const ( const (
TEXT = "text" TEXT = "text"
TEXTAREA = "textarea" TEXTAREA = "textarea"
@ -405,7 +405,7 @@ func SplitCmd(name string) (list []Any) {
i++ i++
default: default:
item = kit.Dict(TYPE, kit.Select(TEXT, BUTTON, button), NAME, ls[i]) item = kit.Dict(TYPE, kit.Select(TEXT, BUTTON, button || actions != nil && actions[ls[i]] != nil), NAME, ls[i])
list = append(list, item) list = append(list, item)
} }
} }

View File

@ -10,7 +10,7 @@ field "命令行" web.code.bash.bash
field "源代码" web.code.inner args `usr/install/bash-5.1/ input.c 636` field "源代码" web.code.inner args `usr/install/bash-5.1/ input.c 636`
section "构建" section "构建"
spark shell ` shell `
yum install -y wget make gcc yum install -y wget make gcc
yum install -y byacc.x86_64 yum install -y byacc.x86_64
@ -22,7 +22,7 @@ make -j8 && make install
` `
section "启动" section "启动"
spark shell ` shell `
cd ./_install cd ./_install
./bin/bash ./bin/bash
` `

View File

@ -10,7 +10,7 @@ field zsh web.code.bash.zsh
field zsh web.code.inner args `[ usr/install/zsh-5.8/ Src/main.c 91 ]` field zsh web.code.inner args `[ usr/install/zsh-5.8/ Src/main.c 91 ]`
section "构建" section "构建"
spark shell ` shell `
yum install -y wget make gcc yum install -y wget make gcc
yum install -y ncurses-devel.x86_64 yum install -y ncurses-devel.x86_64
@ -22,7 +22,7 @@ make -j8 && make install
` `
section "启动" section "启动"
spark shell ` shell `
cd ./_install cd ./_install
./bin/zsh ./bin/zsh
` `

View File

@ -4,12 +4,12 @@ refer `
源码 https://github.com/coder/code-server/ 源码 https://github.com/coder/code-server/
` `
spark shell ` field web.code.coder.server
shell `
wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-amd64.tar.gz wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-amd64.tar.gz
tar xvf code-server-4.4.0-linux-amd64.tar.gz && cd code-server-4.4.0-linux-amd64 tar xvf code-server-4.4.0-linux-amd64.tar.gz && cd code-server-4.4.0-linux-amd64
./bin/code-server ./bin/code-server
` `
field web.code.coder.server
refer ` refer `
官网 https://code.visualstudio.com/ 官网 https://code.visualstudio.com/

View File

@ -10,7 +10,7 @@ field "安装" web.code.git.git
field "源码" web.code.inner args `usr/install/git-2.31.1/ shell.c 145` field "源码" web.code.inner args `usr/install/git-2.31.1/ shell.c 145`
section "构建" section "构建"
spark shell ` shell `
yum install -y wget make gcc yum install -y wget make gcc
yum install -y libcurl-devel.x86_64 openssl-devel.x86_64 yum install -y libcurl-devel.x86_64 openssl-devel.x86_64
yum install -y perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker yum install -y perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
@ -23,7 +23,7 @@ make -j8 && make install
` `
section "启动" section "启动"
spark shell ` shell `
cd ./_install cd ./_install
./bin/git ./bin/git
` `

View File

@ -18,7 +18,7 @@ const (
type compile struct { type compile struct {
ice.Code ice.Code
regexp string `data:".*.java"` regexp string `data:".*.java"`
linux string `data:"https://github.com/Tencent/TencentKona-8/releases/download/8.0.11-GA/TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz"` linux string `data:"https://mirrors.huaweicloud.com/openjdk/18/openjdk-18_linux-x64_bin.tar.gz"`
list string `name:"list path auto listScript order install" help:"编译器"` list string `name:"list path auto listScript order install" help:"编译器"`
} }

View File

@ -7,7 +7,7 @@ refer `
` `
field web.code.java.compile field web.code.java.compile
spark shell ` shell `
wget https://github.com/Tencent/TencentKona-8/releases/download/8.0.11-GA/TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz wget https://github.com/Tencent/TencentKona-8/releases/download/8.0.11-GA/TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz
tar xvf TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz && cd TencentKona-8.0.11-345/ tar xvf TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz && cd TencentKona-8.0.11-345/

View File

@ -10,7 +10,7 @@ field "下载" web.code.tmux.tmux
field "源码" web.code.inner args `usr/install/tmux-3.2/ cmd-bind-key.c` field "源码" web.code.inner args `usr/install/tmux-3.2/ cmd-bind-key.c`
section "构建" section "构建"
spark shell ` shell `
yum install -y wget make gcc yum install -y wget make gcc
yum install -y libevent-devel.x86_64 ncurses-devel.x86_64 yum install -y libevent-devel.x86_64 ncurses-devel.x86_64
@ -22,7 +22,7 @@ make -j8 && make install
` `
section "启动" section "启动"
spark shell ` shell `
cd ./_install cd ./_install
./bin/tmux -S $PWD/tmux.socket ./bin/tmux -S $PWD/tmux.socket

View File

@ -10,7 +10,7 @@ field "安装" web.code.vim.vim
field "源码" web.code.inner args `usr/install/vim-vim-12be734/ src/main.c 110` field "源码" web.code.inner args `usr/install/vim-vim-12be734/ src/main.c 110`
section "构建" section "构建"
spark shell ` shell `
yum install -y wget make gcc yum install -y wget make gcc
yum install -y ncurses-devel.x86_64 bzip2.x86_64 yum install -y ncurses-devel.x86_64 bzip2.x86_64
@ -21,7 +21,7 @@ tar xvf vim-8.2.2681.tar.gz && cd vim-vim-12be734
make -j8 && make install make -j8 && make install
` `
spark shell ` shell `
yum install python python-devel python36u python36u-devel yum install python python-devel python36u python36u-devel
yum install tcl-devel perl perl-devel perl-ExtUtils-ParseXS perl-ExtUtils-XSpp perl-ExtUtils-CBuilder perl-ExtUtils-Embed cscope gtk3-devel libSM-devel libXt-devel libXpm-devel libappstream-glib libacl-devel gpm-devel yum install tcl-devel perl perl-devel perl-ExtUtils-ParseXS perl-ExtUtils-XSpp perl-ExtUtils-CBuilder perl-ExtUtils-Embed cscope gtk3-devel libSM-devel libXt-devel libXpm-devel libappstream-glib libacl-devel gpm-devel
yum install ncurses-devel yum install ncurses-devel
@ -31,7 +31,7 @@ make -j8 && make install
` `
section "启动" section "启动"
spark shell ` shell `
cd ./_install cd ./_install
./bin/vim ./bin/vim
` `

View File

@ -165,7 +165,7 @@ func (c *Context) Merge(s *Context) *Context {
} }
if c.Commands[key] = cmd; cmd.List == nil { if c.Commands[key] = cmd; cmd.List == nil {
cmd.List = SplitCmd(cmd.Name) cmd.List = SplitCmd(cmd.Name, cmd.Actions)
} }
if cmd.Meta == nil { if cmd.Meta == nil {
cmd.Meta = kit.Dict() cmd.Meta = kit.Dict()
@ -208,7 +208,7 @@ func (c *Context) Merge(s *Context) *Context {
continue // alias cmd continue // alias cmd
} }
if a.List == nil { if a.List == nil {
a.List = SplitCmd(a.Name) a.List = SplitCmd(a.Name, nil)
} }
if len(a.List) > 0 { if len(a.List) > 0 {
cmd.Meta[k] = a.List cmd.Meta[k] = a.List