mirror of
https://shylinux.com/x/icebergs
synced 2025-04-28 10:12:02 +08:00
opt some
This commit is contained in:
parent
7588d84b62
commit
2eb4113693
@ -9,10 +9,10 @@ import (
|
|||||||
|
|
||||||
func _context_list(m *ice.Message, sub *ice.Context, name string) {
|
func _context_list(m *ice.Message, sub *ice.Context, name string) {
|
||||||
m.Travel(func(p *ice.Context, s *ice.Context) {
|
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
|
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_STATUS, s.Cap(ice.CTX_STATUS))
|
||||||
m.Push(kit.MDB_STREAM, s.Cap(ice.CTX_STREAM))
|
m.Push(kit.MDB_STREAM, s.Cap(ice.CTX_STREAM))
|
||||||
m.Push(kit.MDB_HELP, s.Help)
|
m.Push(kit.MDB_HELP, s.Help)
|
||||||
@ -23,7 +23,7 @@ const CONTEXT = "context"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
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) {
|
"spide": {Name: "spide", Help: "架构图", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 || arg[1] == CONTEXT { // 模块列表
|
if len(arg) == 0 || arg[1] == CONTEXT { // 模块列表
|
||||||
m.Cmdy(CONTEXT, kit.Select(ice.ICE, arg, 0), CONTEXT)
|
m.Cmdy(CONTEXT, kit.Select(ice.ICE, arg, 0), CONTEXT)
|
||||||
@ -31,7 +31,7 @@ func init() {
|
|||||||
"field", "name", "split", ice.PT, "prefix", "spide")
|
"field", "name", "split", ice.PT, "prefix", "spide")
|
||||||
return
|
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.Cmdy(CONTEXT, index, COMMAND).Table(func(i int, value map[string]string, head []string) {
|
||||||
m.Push("file", arg[1])
|
m.Push("file", arg[1])
|
||||||
})
|
})
|
||||||
|
@ -3,6 +3,7 @@ package nfs
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -20,25 +21,25 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
|
|||||||
return m // 没有权限
|
return m // 没有权限
|
||||||
}
|
}
|
||||||
|
|
||||||
fs, e := ioutil.ReadDir(path.Join(root, name))
|
list, e := ioutil.ReadDir(path.Join(root, name))
|
||||||
if e != nil { // 单个文件
|
if e != nil { // 单个文件
|
||||||
ls, _ := ioutil.ReadDir(path.Dir(path.Join(root, name)))
|
ls, _ := ioutil.ReadDir(path.Dir(path.Join(root, name)))
|
||||||
for _, k := range ls {
|
for _, k := range ls {
|
||||||
if k.Name() == path.Base(name) {
|
if k.Name() == path.Base(name) {
|
||||||
fs = append(fs, k)
|
list = append(list, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
name = path.Dir(name)
|
name = path.Dir(name)
|
||||||
}
|
}
|
||||||
for i := 0; i < len(fs)-1; i++ {
|
for i := 0; i < len(list)-1; i++ {
|
||||||
for j := i + 1; j < len(fs); j++ {
|
for j := i + 1; j < len(list); j++ {
|
||||||
if fs[i].Name() > fs[j].Name() {
|
if list[i].Name() > list[j].Name() {
|
||||||
fs[i], fs[j] = fs[j], fs[i]
|
list[i], list[j] = list[j], list[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range fs {
|
for _, f := range list {
|
||||||
if f.Name() == ice.PT || f.Name() == ".." {
|
if f.Name() == ice.PT || f.Name() == ".." {
|
||||||
continue
|
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())
|
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())) {
|
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) {
|
switch cb := m.Optionv(kit.Keycb(DIR)).(type) {
|
||||||
|
case func(f fs.FileInfo, p string):
|
||||||
|
cb(f, p)
|
||||||
|
continue
|
||||||
case func(p string):
|
case func(p string):
|
||||||
cb(p)
|
cb(p)
|
||||||
continue
|
continue
|
||||||
|
@ -6,4 +6,4 @@ import (
|
|||||||
|
|
||||||
var Index = &ice.Context{Name: "nfs", Help: "存储模块"}
|
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) }
|
||||||
|
2
conf.go
2
conf.go
@ -94,6 +94,8 @@ const ( // DIR
|
|||||||
INDEX_SH = "index.sh"
|
INDEX_SH = "index.sh"
|
||||||
|
|
||||||
USR_LOCAL = "usr/local"
|
USR_LOCAL = "usr/local"
|
||||||
|
USR_LOCAL_BIN = "usr/local/bin"
|
||||||
|
USR_LOCAL_LIB = "usr/local/lib"
|
||||||
USR_LOCAL_WORK = "usr/local/work"
|
USR_LOCAL_WORK = "usr/local/work"
|
||||||
USR_LOCAL_IMAGE = "usr/local/image"
|
USR_LOCAL_IMAGE = "usr/local/image"
|
||||||
USR_LOCAL_RIVER = "usr/local/river"
|
USR_LOCAL_RIVER = "usr/local/river"
|
||||||
|
@ -69,6 +69,7 @@ func init() {
|
|||||||
// 编译成功
|
// 编译成功
|
||||||
m.Log_EXPORT(cli.SOURCE, main, cli.TARGET, file)
|
m.Log_EXPORT(cli.SOURCE, main, cli.TARGET, file)
|
||||||
m.Cmdy(nfs.DIR, file, "time,path,size,link,action")
|
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.Cmdy(PUBLISH, ice.CONTEXTS, ice.BASE)
|
||||||
m.StatusTimeCount()
|
m.StatusTimeCount()
|
||||||
}},
|
}},
|
||||||
|
@ -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() {
|
} else if s, e := os.Stat(file); m.Assert(e) && s.IsDir() {
|
||||||
p := path.Base(file) + ".tar.gz"
|
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) }()
|
defer func() { os.Remove(p) }()
|
||||||
file = p // 打包目录
|
file = p // 打包目录
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ echo "hello world"
|
|||||||
`,
|
`,
|
||||||
)},
|
)},
|
||||||
}, Commands: map[string]*ice.Command{
|
}, 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) {
|
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.Config(kit.MDB_PATH))
|
||||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey())
|
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) {
|
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) {
|
mdb.CREATE: {Name: "create file", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_publish_file(m, m.Option(kit.MDB_FILE))
|
_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))
|
p := m.Option(cli.CMD_DIR, m.Config(kit.MDB_PATH))
|
||||||
os.Remove(path.Join(p, m.Option(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) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(nfs.DIR_ROOT, m.Config(kit.MDB_PATH))
|
m.Option(nfs.DIR_ROOT, m.Config(kit.MDB_PATH))
|
||||||
m.Cmdy(nfs.DIR, kit.Select("", arg, 0), "time,size,path,action,link")
|
m.Cmdy(nfs.DIR, kit.Select("", arg, 0), "time,size,path,action,link")
|
||||||
|
@ -162,8 +162,8 @@ func init() {
|
|||||||
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
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.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.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, 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, "--tags", m.MergeURL2("/x/"+value[kit.MDB_NAME]), MASTER)
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
@ -117,6 +117,9 @@ func (m *Message) StatusTimeCountTotal(arg ...interface{}) {
|
|||||||
func (m *Message) Confirm(text string) string {
|
func (m *Message) Confirm(text string) string {
|
||||||
return m.Cmdx("space", m.Option(MSG_DAEMON), "confirm", text)
|
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]]]
|
func (m *Message) Toast(text string, arg ...interface{}) { // [title [duration [progress]]]
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
switch val := arg[1].(type) {
|
switch val := arg[1].(type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user