diff --git a/base/lex/regexp.go b/base/lex/regexp.go index 983e24fb..7607d7f9 100644 --- a/base/lex/regexp.go +++ b/base/lex/regexp.go @@ -1,4 +1,6 @@ package lex -const REGEXP = "regexp" const PREFIX = "prefix" +const SUFFIX = "suffix" +const REGEXP = "regexp" +const PATTERN = "pattern" diff --git a/base/mdb/hash.go b/base/mdb/hash.go index 545e924a..06a634e8 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -273,16 +273,26 @@ func HashImport(m *ice.Message, arg ...Any) *ice.Message { 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) { p = value[TARGET] if pp, ok := p.(Map); ok && len(pp) == 0 { p = nil } if p == nil && add != nil { - p = add() + 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() + default: + m.ErrorNotImplement(p) + return + } value[TARGET] = p } + m.Debug("what %v %T", p, p) }) return } diff --git a/base/nfs/pack.go b/base/nfs/pack.go index 9d4552c3..c15ac5e4 100644 --- a/base/nfs/pack.go +++ b/base/nfs/pack.go @@ -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)) { buf := make([]byte, 1024*1024) + total := 0 for { 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 { break } - to.Write(buf[:n]) - cb(n) } } diff --git a/base/web/spide.go b/base/web/spide.go index 10b6ef56..76467c2d 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -38,8 +38,6 @@ func _spide_create(m *ice.Message, name, address string) { } func _spide_list(m *ice.Message, arg ...string) { 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]) != "" { m.Echo(msg.Append(arg[1])) return @@ -242,6 +240,7 @@ func _spide_send(m *ice.Message, name string, req *http.Request, timeout string) return client.Do(req) } func _spide_save(m *ice.Message, cache, save, uri string, res *http.Response) { + m.Debug("what %v", m.OptionCB("")) switch cache { case SPIDE_RAW: 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() total := kit.Int(res.Header.Get(ContentLength)) + 1 + m.Debug("what %v", m.OptionCB("")) switch cb := m.OptionCB("").(type) { case func(int, int, int): count := 0 nfs.CopyFile(m, f, res.Body, func(n int) { count += n + m.Debug("what %v %v", n, count) cb(count, total, count*100/total) }) default: diff --git a/core/code/install.go b/core/code/install.go index 0ac74fba..b34f2293 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -57,6 +57,7 @@ func _install_download(m *ice.Message) { web.PushNoticeRefresh(m) web.ToastSuccess(m) }) + m.SetResult() } func _install_build(m *ice.Message, arg ...string) string { p := m.Option(cli.CMD_DIR, _install_path(m, "")) @@ -128,7 +129,8 @@ func _install_start(m *ice.Message, arg ...string) { 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() } } @@ -140,6 +142,14 @@ func _install_stop(m *ice.Message, arg ...string) { }) 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) { arg = kit.Split(path.Base(arg[0]), "-.")[:1] 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) { _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) { 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, ""))) diff --git a/misc.go b/misc.go index 80ca11e9..d8764e75 100644 --- a/misc.go +++ b/misc.go @@ -130,7 +130,7 @@ func (m *Message) Design(action Any, help string, input ...Any) { for _, input := range input { switch input := input.(type) { case string: - list = append(list, SplitCmd("action "+input)...) + list = append(list, SplitCmd("action "+input, nil)...) case Map: if kit.Format(input[TYPE]) != "" && kit.Format(input[NAME]) != "" { list = append(list, input) @@ -333,7 +333,7 @@ func MergeActions(list ...Any) Actions { } return base } -func SplitCmd(name string) (list []Any) { +func SplitCmd(name string, actions Actions) (list []Any) { const ( TEXT = "text" TEXTAREA = "textarea" @@ -405,7 +405,7 @@ func SplitCmd(name string) (list []Any) { i++ 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) } } diff --git a/misc/bash/bash.shy b/misc/bash/bash.shy index b3b7101c..441aaeb5 100644 --- a/misc/bash/bash.shy +++ b/misc/bash/bash.shy @@ -10,7 +10,7 @@ field "命令行" web.code.bash.bash field "源代码" web.code.inner args `usr/install/bash-5.1/ input.c 636` section "构建" -spark shell ` +shell ` yum install -y wget make gcc yum install -y byacc.x86_64 @@ -22,7 +22,7 @@ make -j8 && make install ` section "启动" -spark shell ` +shell ` cd ./_install ./bin/bash ` diff --git a/misc/bash/zsh.shy b/misc/bash/zsh.shy index 8654eff3..8ceee884 100644 --- a/misc/bash/zsh.shy +++ b/misc/bash/zsh.shy @@ -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 ]` section "构建" -spark shell ` +shell ` yum install -y wget make gcc yum install -y ncurses-devel.x86_64 @@ -22,7 +22,7 @@ make -j8 && make install ` section "启动" -spark shell ` +shell ` cd ./_install ./bin/zsh ` diff --git a/misc/coder/coder.shy b/misc/coder/coder.shy index baacc58d..dede5aed 100644 --- a/misc/coder/coder.shy +++ b/misc/coder/coder.shy @@ -4,12 +4,12 @@ refer ` 源码 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 tar xvf code-server-4.4.0-linux-amd64.tar.gz && cd code-server-4.4.0-linux-amd64 ./bin/code-server ` -field web.code.coder.server refer ` 官网 https://code.visualstudio.com/ diff --git a/misc/git/git.shy b/misc/git/git.shy index 71423068..0da28003 100644 --- a/misc/git/git.shy +++ b/misc/git/git.shy @@ -10,7 +10,7 @@ field "安装" web.code.git.git field "源码" web.code.inner args `usr/install/git-2.31.1/ shell.c 145` section "构建" -spark shell ` +shell ` yum install -y wget make gcc yum install -y libcurl-devel.x86_64 openssl-devel.x86_64 yum install -y perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker @@ -23,7 +23,7 @@ make -j8 && make install ` section "启动" -spark shell ` +shell ` cd ./_install ./bin/git ` diff --git a/misc/java/compile.go b/misc/java/compile.go index c2dbae30..c376b5ef 100644 --- a/misc/java/compile.go +++ b/misc/java/compile.go @@ -18,7 +18,7 @@ const ( type compile struct { ice.Code 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:"编译器"` } diff --git a/misc/java/compile.shy b/misc/java/compile.shy index 44813707..82b99793 100644 --- a/misc/java/compile.shy +++ b/misc/java/compile.shy @@ -7,7 +7,7 @@ refer ` ` 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 tar xvf TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz && cd TencentKona-8.0.11-345/ diff --git a/misc/tmux/tmux.shy b/misc/tmux/tmux.shy index ce4f3a9d..28c9fad7 100644 --- a/misc/tmux/tmux.shy +++ b/misc/tmux/tmux.shy @@ -10,7 +10,7 @@ field "下载" web.code.tmux.tmux field "源码" web.code.inner args `usr/install/tmux-3.2/ cmd-bind-key.c` section "构建" -spark shell ` +shell ` yum install -y wget make gcc yum install -y libevent-devel.x86_64 ncurses-devel.x86_64 @@ -22,7 +22,7 @@ make -j8 && make install ` section "启动" -spark shell ` +shell ` cd ./_install ./bin/tmux -S $PWD/tmux.socket diff --git a/misc/vim/vim.shy b/misc/vim/vim.shy index 4b6c4aeb..0c5c24b8 100644 --- a/misc/vim/vim.shy +++ b/misc/vim/vim.shy @@ -10,7 +10,7 @@ field "安装" web.code.vim.vim field "源码" web.code.inner args `usr/install/vim-vim-12be734/ src/main.c 110` section "构建" -spark shell ` +shell ` yum install -y wget make gcc 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 ` -spark shell ` +shell ` 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 ncurses-devel @@ -31,7 +31,7 @@ make -j8 && make install ` section "启动" -spark shell ` +shell ` cd ./_install ./bin/vim ` diff --git a/type.go b/type.go index 3ce843b6..e1ec95dd 100644 --- a/type.go +++ b/type.go @@ -165,7 +165,7 @@ func (c *Context) Merge(s *Context) *Context { } if c.Commands[key] = cmd; cmd.List == nil { - cmd.List = SplitCmd(cmd.Name) + cmd.List = SplitCmd(cmd.Name, cmd.Actions) } if cmd.Meta == nil { cmd.Meta = kit.Dict() @@ -208,7 +208,7 @@ func (c *Context) Merge(s *Context) *Context { continue // alias cmd } if a.List == nil { - a.List = SplitCmd(a.Name) + a.List = SplitCmd(a.Name, nil) } if len(a.List) > 0 { cmd.Meta[k] = a.List