diff --git a/base/ctx/context.go b/base/ctx/context.go index 14c27b7e..699ba2e9 100644 --- a/base/ctx/context.go +++ b/base/ctx/context.go @@ -9,10 +9,10 @@ import ( func _context_list(m *ice.Message, sub *ice.Context, name string) { m.Travel(func(p *ice.Context, s *ice.Context) { - if !strings.HasPrefix(s.Cap(ice.CTX_FOLLOW), name+ice.PT) { + if name != "" && !strings.HasPrefix(s.Cap(ice.CTX_FOLLOW), name+ice.PT) { return } - m.Push(kit.MDB_NAME, strings.TrimPrefix(s.Cap(ice.CTX_FOLLOW), name+ice.PT)) + m.Push(kit.MDB_NAME, s.Cap(ice.CTX_FOLLOW)) m.Push(kit.MDB_STATUS, s.Cap(ice.CTX_STATUS)) m.Push(kit.MDB_STREAM, s.Cap(ice.CTX_STREAM)) m.Push(kit.MDB_HELP, s.Help) @@ -23,7 +23,7 @@ const CONTEXT = "context" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - CONTEXT: {Name: "context name=web.chat action=context,command,config key auto spide", Help: "模块", Action: ice.MergeAction(map[string]*ice.Action{ + CONTEXT: {Name: "context name=web action=context,command,config key auto spide", Help: "模块", Action: ice.MergeAction(map[string]*ice.Action{ "spide": {Name: "spide", Help: "架构图", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[1] == CONTEXT { // 模块列表 m.Cmdy(CONTEXT, kit.Select(ice.ICE, arg, 0), CONTEXT) @@ -31,7 +31,7 @@ func init() { "field", "name", "split", ice.PT, "prefix", "spide") return } - if index := kit.Keys(arg[0], arg[1]); strings.HasSuffix(index, arg[2]) { // 命令列表 + if index := kit.Keys(arg[1]); strings.HasSuffix(index, arg[2]) { // 命令列表 m.Cmdy(CONTEXT, index, COMMAND).Table(func(i int, value map[string]string, head []string) { m.Push("file", arg[1]) }) diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 4238d9be..933480c2 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -3,6 +3,7 @@ package nfs import ( "bufio" "crypto/sha1" + "io/fs" "io/ioutil" "os" "path" @@ -20,25 +21,25 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d return m // 没有权限 } - fs, e := ioutil.ReadDir(path.Join(root, name)) + list, e := ioutil.ReadDir(path.Join(root, name)) if e != nil { // 单个文件 ls, _ := ioutil.ReadDir(path.Dir(path.Join(root, name))) for _, k := range ls { if k.Name() == path.Base(name) { - fs = append(fs, k) + list = append(list, k) } } name = path.Dir(name) } - for i := 0; i < len(fs)-1; i++ { - for j := i + 1; j < len(fs); j++ { - if fs[i].Name() > fs[j].Name() { - fs[i], fs[j] = fs[j], fs[i] + for i := 0; i < len(list)-1; i++ { + for j := i + 1; j < len(list); j++ { + if list[i].Name() > list[j].Name() { + list[i], list[j] = list[j], list[i] } } } - for _, f := range fs { + for _, f := range list { if f.Name() == ice.PT || f.Name() == ".." { continue } @@ -49,6 +50,9 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d p := path.Join(root, name, f.Name()) if !(dir_type == TYPE_CAT && f.IsDir() || dir_type == TYPE_DIR && !f.IsDir()) && (dir_reg == nil || dir_reg.MatchString(f.Name())) { switch cb := m.Optionv(kit.Keycb(DIR)).(type) { + case func(f fs.FileInfo, p string): + cb(f, p) + continue case func(p string): cb(p) continue diff --git a/base/nfs/nfs.go b/base/nfs/nfs.go index d07c9a6c..3e1c4723 100644 --- a/base/nfs/nfs.go +++ b/base/nfs/nfs.go @@ -6,4 +6,4 @@ import ( var Index = &ice.Context{Name: "nfs", Help: "存储模块"} -func init() { ice.Index.Register(Index, nil, CAT, DIR, TAIL, TRASH, SAVE, PUSH, COPY, LINK, DEFS) } +func init() { ice.Index.Register(Index, nil, TAR, CAT, DIR, TAIL, TRASH, SAVE, PUSH, COPY, LINK, DEFS) } diff --git a/conf.go b/conf.go index 3771df43..073d2be7 100644 --- a/conf.go +++ b/conf.go @@ -94,6 +94,8 @@ const ( // DIR INDEX_SH = "index.sh" USR_LOCAL = "usr/local" + USR_LOCAL_BIN = "usr/local/bin" + USR_LOCAL_LIB = "usr/local/lib" USR_LOCAL_WORK = "usr/local/work" USR_LOCAL_IMAGE = "usr/local/image" USR_LOCAL_RIVER = "usr/local/river" diff --git a/core/code/compile.go b/core/code/compile.go index 758cbfc6..5087dcd4 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -69,6 +69,7 @@ func init() { // 编译成功 m.Log_EXPORT(cli.SOURCE, main, cli.TARGET, file) m.Cmdy(nfs.DIR, file, "time,path,size,link,action") + m.Cmdy(PUBLISH, mdb.CREATE, ice.BIN_ICE_SH) m.Cmdy(PUBLISH, ice.CONTEXTS, ice.BASE) m.StatusTimeCount() }}, diff --git a/core/code/publish.go b/core/code/publish.go index 1627f531..6344aae2 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -38,7 +38,7 @@ func _publish_file(m *ice.Message, file string, arg ...string) string { } else if s, e := os.Stat(file); m.Assert(e) && s.IsDir() { p := path.Base(file) + ".tar.gz" - m.Cmd(cli.SYSTEM, "tar", "-zcf", p, file) + m.Cmd(nfs.TAR, p, file) defer func() { os.Remove(p) }() file = p // 打包目录 } @@ -69,7 +69,7 @@ echo "hello world" `, )}, }, Commands: map[string]*ice.Command{ - PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Action: map[string]*ice.Action{ + PUBLISH: {Name: "publish path auto create volcanos icebergs intshell export", Help: "发布", Action: map[string]*ice.Action{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Config(kit.MDB_PATH)) m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey()) @@ -111,7 +111,8 @@ echo "hello world" } }}, mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(web.DREAM, mdb.INPUTS, arg) + m.Cmdy(nfs.DIR, kit.Select(ice.PWD, arg, 1)) + m.ProcessAgain() }}, mdb.CREATE: {Name: "create file", Help: "添加", Hand: func(m *ice.Message, arg ...string) { _publish_file(m, m.Option(kit.MDB_FILE)) @@ -120,6 +121,36 @@ echo "hello world" p := m.Option(cli.CMD_DIR, m.Config(kit.MDB_PATH)) os.Remove(path.Join(p, m.Option(kit.MDB_PATH))) }}, + mdb.EXPORT: {Name: "export", Help: "工具链", Hand: func(m *ice.Message, arg ...string) { + var list = []string{} + m.Cmd(nfs.CAT, ice.ETC_PATH, func(text string) { + if strings.HasPrefix(text, ice.USR_PUBLISH) { + return + } + if strings.HasPrefix(text, ice.BIN) { + return + } + if strings.HasPrefix(text, ice.PS) { + return + } + list = append(list, text) + }) + + web.PushStream(m) + defer m.ProcessHold() + defer m.StatusTimeCount() + m.Cmd(nfs.TAR, kit.Path(ice.USR_PUBLISH, "vim.tar.gz"), ".vim/plugged", kit.Dict(nfs.DIR_ROOT, os.Getenv(cli.HOME))) + m.Cmd(nfs.TAR, kit.Path(ice.USR_PUBLISH, "contexts.lib.tar.gz"), ice.USR_LOCAL_LIB) + m.Cmd(nfs.TAR, kit.Path(ice.USR_PUBLISH, "contexts.bin.tar.gz"), list) + m.Cmd(PUBLISH, mdb.CREATE, ice.ETC_PATH) + + m.Cmd(PUBLISH, mdb.CREATE, ice.ETC_MISS_SH) + m.Cmd(PUBLISH, mdb.CREATE, ice.GO_MOD) + m.Cmd(PUBLISH, mdb.CREATE, ice.GO_SUM) + + m.Cmd("web.code.git.server", mdb.IMPORT) + m.ToastSuccess() + }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Option(nfs.DIR_ROOT, m.Config(kit.MDB_PATH)) m.Cmdy(nfs.DIR, kit.Select("", arg, 0), "time,size,path,action,link") diff --git a/misc/git/server.go b/misc/git/server.go index 3124c6cb..e911fb9a 100644 --- a/misc/git/server.go +++ b/misc/git/server.go @@ -162,8 +162,8 @@ func init() { mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("time,name,path")).Table(func(index int, value map[string]string, head []string) { m.Option(cli.CMD_DIR, value[nfs.PATH]) - m.Cmd(cli.SYSTEM, "git", "push", m.MergeURL2("/x/"+value[kit.MDB_NAME]), "master") - m.Cmd(cli.SYSTEM, "git", "push", "--tags", m.MergeURL2("/x/"+value[kit.MDB_NAME]), "master") + m.Cmd(cli.SYSTEM, GIT, PUSH, m.MergeURL2("/x/"+value[kit.MDB_NAME]), MASTER) + m.Cmd(cli.SYSTEM, GIT, PUSH, "--tags", m.MergeURL2("/x/"+value[kit.MDB_NAME]), MASTER) }) }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { diff --git a/option.go b/option.go index 1b10b4bc..1cbe1cb4 100644 --- a/option.go +++ b/option.go @@ -117,6 +117,9 @@ func (m *Message) StatusTimeCountTotal(arg ...interface{}) { func (m *Message) Confirm(text string) string { return m.Cmdx("space", m.Option(MSG_DAEMON), "confirm", text) } +func (m *Message) ToastSuccess(arg ...interface{}) { + m.Toast(SUCCESS, arg...) +} func (m *Message) Toast(text string, arg ...interface{}) { // [title [duration [progress]]] if len(arg) > 1 { switch val := arg[1].(type) {