forked from x/icebergs
opt some
This commit is contained in:
parent
63fb21f3ca
commit
b131e6c61a
@ -5,6 +5,7 @@ import (
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
@ -22,7 +23,7 @@ func _dir_hash(m *ice.Message, p string) (h string) {
|
||||
kit.If(len(list) > 0, func() { h = kit.Hashs(list) })
|
||||
return ""
|
||||
}
|
||||
func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string) *ice.Message {
|
||||
func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string) (total int64, last time.Time) {
|
||||
ls, _ := ReadDir(m, path.Join(root, dir))
|
||||
if len(ls) == 0 {
|
||||
if s, e := StatFile(m, path.Join(root, dir)); e == nil && !s.IsDir() {
|
||||
@ -49,6 +50,9 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
|
||||
default:
|
||||
m.ErrorNotImplement(cb)
|
||||
}
|
||||
if s.ModTime().After(last) {
|
||||
last = s.ModTime()
|
||||
}
|
||||
for _, field := range fields {
|
||||
switch field {
|
||||
case mdb.TIME:
|
||||
@ -74,6 +78,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
|
||||
m.Push(field, _dir_size(m, p))
|
||||
} else {
|
||||
m.Push(field, kit.FmtSize(s.Size()))
|
||||
total += s.Size()
|
||||
}
|
||||
case LINE:
|
||||
if isDir {
|
||||
@ -121,10 +126,13 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
|
||||
case "pluged":
|
||||
continue
|
||||
}
|
||||
_dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields)
|
||||
_total, _last := _dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields)
|
||||
if total += _total; _last.After(last) {
|
||||
last = _last
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const (
|
||||
@ -171,7 +179,9 @@ func init() {
|
||||
}}, mdb.UPLOAD: {},
|
||||
"finder": {Help: "本机", Hand: func(m *ice.Message, arg ...string) { m.Cmd("cli.system", "opens", "Finder.app") }},
|
||||
TRASH: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(TRASH, mdb.CREATE, m.Option(PATH)) }},
|
||||
mdb.SHOW: {Hand: func(m *ice.Message, arg ...string) { Show(m.ProcessInner(), m.Option(PATH)) }},
|
||||
mdb.SHOW: {Hand: func(m *ice.Message, arg ...string) {
|
||||
Show(m.ProcessInner(), path.Join(m.Option(DIR_ROOT), m.Option(PATH)))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
root, dir := kit.Select(PWD, m.Option(DIR_ROOT)), kit.Select(PWD, arg, 0)
|
||||
kit.If(strings.HasPrefix(dir, PS), func() { root = "" })
|
||||
@ -180,7 +190,8 @@ func init() {
|
||||
}
|
||||
m.Logs(FIND, DIR_ROOT, root, PATH, dir, DIR_TYPE, m.Option(DIR_TYPE))
|
||||
fields := kit.Split(kit.Select(kit.Select(DIR_DEF_FIELDS, m.OptionFields()), kit.Join(kit.Slice(arg, 1))))
|
||||
_dir_list(m, root, dir, 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), regexp.MustCompile(m.Option(DIR_REG)), fields).StatusTimeCount()
|
||||
size, last := _dir_list(m, root, dir, 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), regexp.MustCompile(m.Option(DIR_REG)), fields)
|
||||
m.Status(mdb.TIME, last, mdb.COUNT, kit.Split(m.FormatSize())[0], SIZE, kit.FmtSize(size), kit.MDB_COST, m.FormatCost())
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -30,14 +30,15 @@ func (l Listener) Close() error {
|
||||
|
||||
func _server_listen(m *ice.Message, arg ...string) {
|
||||
l, e := net.Listen(TCP, m.Option(HOST)+nfs.DF+m.Option(PORT))
|
||||
if m.Warn(e) {
|
||||
return
|
||||
}
|
||||
l = &Listener{Listener: l, m: m, h: mdb.HashCreate(m, arg, kit.Dict(mdb.TARGET, l), STATUS, kit.Select(ERROR, OPEN, e == nil), ERROR, kit.Format(e)), s: &Stat{}}
|
||||
defer kit.If(e == nil, func() { l.Close() })
|
||||
switch cb := m.OptionCB("").(type) {
|
||||
case func(net.Listener):
|
||||
m.Assert(e)
|
||||
cb(l)
|
||||
case func(net.Conn):
|
||||
m.Assert(e)
|
||||
for {
|
||||
if c, e := l.Accept(); !m.Warn(e) {
|
||||
cb(c)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"path"
|
||||
@ -57,11 +58,16 @@ func (f *Frame) Start(m *ice.Message, arg ...string) {
|
||||
case func(http.Handler):
|
||||
cb(f)
|
||||
default:
|
||||
m.Cmd(tcp.SERVER, tcp.LISTEN, mdb.TYPE, HTTP, mdb.NAME, logs.FileLine(1), m.OptionSimple(tcp.HOST, tcp.PORT), func(l net.Listener) {
|
||||
m.Cmdy(tcp.SERVER, tcp.LISTEN, mdb.TYPE, HTTP, mdb.NAME, logs.FileLine(1), m.OptionSimple(tcp.HOST, tcp.PORT), func(l net.Listener) {
|
||||
defer mdb.HashCreateDeferRemove(m, m.OptionSimple(mdb.NAME, tcp.PROTO), arg, cli.STATUS, tcp.START)()
|
||||
gdb.Event(m, SERVE_START, arg)
|
||||
m.Warn(f.Server.Serve(l))
|
||||
})
|
||||
if m.IsErr() {
|
||||
fmt.Println()
|
||||
fmt.Println(m.Result())
|
||||
m.Cmd(ice.QUIT)
|
||||
}
|
||||
}
|
||||
}
|
||||
func (f *Frame) Close(m *ice.Message, arg ...string) {}
|
||||
|
1
conf.go
1
conf.go
@ -118,6 +118,7 @@ const ( // DIR
|
||||
USR_VOLCANOS = "usr/volcanos/"
|
||||
USR_LEARNING = "usr/learning/"
|
||||
USR_PORTAL = "usr/portal/"
|
||||
USR_ICONS = "usr/icons/"
|
||||
|
||||
USR_LOCAL = "usr/local/"
|
||||
USR_LOCAL_GO = "usr/local/go/"
|
||||
|
@ -75,7 +75,7 @@ func _binpack_all(m *ice.Message) {
|
||||
}
|
||||
for _, k := range kit.SortedKey(list) {
|
||||
v := kit.Select(k, list[k])
|
||||
m.Cmd(nfs.DIR, nfs.PWD, nfs.PATH, kit.Dict(nfs.DIR_ROOT, v, nfs.DIR_REG, kit.ExtReg(SH, SHY, PY, JS, CSS, HTML))).Table(func(value ice.Maps) {
|
||||
m.Cmd(nfs.DIR, nfs.PWD, nfs.PATH, kit.Dict(nfs.DIR_ROOT, v, nfs.DIR_REG, kit.ExtReg(kit.Split(mdb.Config(m, "extreg"))...))).Table(func(value ice.Maps) {
|
||||
if ice.Info.Make.Remote != "https://shylinux.com/x/contexts" && kit.HasPrefix(k, ice.USR_ICEBERGS) {
|
||||
return
|
||||
}
|
||||
@ -90,7 +90,7 @@ func _binpack_all(m *ice.Message) {
|
||||
}
|
||||
})
|
||||
m.Option(nfs.DIR_REG, kit.ExtReg(nfs.SHY))
|
||||
if ice.Info.Make.Remote == "shylinux.com/x/contexts" {
|
||||
if ice.Info.Make.Remote == "https://shylinux.com/x/contexts" {
|
||||
_binpack_dir(m, w, "usr/release/")
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ func init() {
|
||||
BINPACK: {Name: "binpack path auto create insert", Help: "打包", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { _binpack_all(m) }},
|
||||
mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m, m.OptionSimple(nfs.PATH)) }},
|
||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path"))},
|
||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path", "extreg", "sh,shy,py,js,css,html,png,jpg"))},
|
||||
})
|
||||
}
|
||||
func GoCache(m *ice.Message) string {
|
||||
|
@ -484,7 +484,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
STASH: {Hand: func(m *ice.Message, arg ...string) { _repos_cmd(m, kit.Select(m.Option(REPOS), arg, 0), STASH) }},
|
||||
COMMIT: {Name: "commit actions=add,opt,fix comment*=some", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
COMMIT: {Name: "commit actions=add,fix,opt message*=some", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||
if work, err := _repos_open(m, m.Option(REPOS)).Worktree(); !m.Warn(err) {
|
||||
opt := &git.CommitOptions{All: true}
|
||||
if cfg, err := config.LoadConfig(config.GlobalScope); err == nil {
|
||||
@ -496,7 +496,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err := work.Commit(m.Option("actions")+lex.SP+m.Option("comment"), opt)
|
||||
_, err := work.Commit(m.Option("actions")+lex.SP+m.Option("message"), opt)
|
||||
m.Warn(err)
|
||||
}
|
||||
}},
|
||||
|
@ -38,7 +38,7 @@ func init() {
|
||||
})
|
||||
})
|
||||
}},
|
||||
}, ctx.ConfAction("skip", kit.DictList("go-git", "go-qrcode", "websocket"))), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, ctx.ConfAction("skip", kit.DictList("go-git", "go-qrcode", "websocket", "webview", "word-dict"))), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
ReposList(m).Table(func(value ice.Maps) {
|
||||
kit.If(value[REPOS] == arg[0], func() { m.Cmdy("_sum", value[nfs.PATH], arg[1:]) })
|
||||
|
@ -220,12 +220,9 @@ func (m *Message) resource(file string) string {
|
||||
return file
|
||||
}
|
||||
p := strings.TrimPrefix(kit.FileLines(3), Info.Make.Path)
|
||||
p = strings.TrimPrefix(p, kit.Path("")+PS)
|
||||
if strings.Contains(p, "/pkg/mod/") {
|
||||
if p = strings.TrimPrefix(p, kit.Path("")+PS); strings.Contains(p, "/pkg/mod/") {
|
||||
p = strings.Split(p, "/pkg/mod/")[1]
|
||||
}
|
||||
if file != "" {
|
||||
p = path.Join(path.Dir(p), file)
|
||||
}
|
||||
kit.If(file != "", func() { p = path.Join(path.Dir(p), file) })
|
||||
return "/require/" + p
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user