mirror of
https://shylinux.com/x/icebergs
synced 2025-05-02 11:37:01 +08:00
opt nfs
This commit is contained in:
parent
244dab2e4b
commit
3ac6548226
@ -98,13 +98,6 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Right(m *ice.Message, key ...ice.Any) bool {
|
|
||||||
return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key) != ice.OK,
|
|
||||||
ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(logs.FileLine(2)))
|
|
||||||
}
|
|
||||||
func RoleRight(m *ice.Message, role string, key ...string) bool {
|
|
||||||
return m.Cmdx(ROLE, RIGHT, role, key) == ice.OK
|
|
||||||
}
|
|
||||||
func RoleAction(key ...string) ice.Actions {
|
func RoleAction(key ...string) ice.Actions {
|
||||||
return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if c, ok := ice.Info.Index[m.CommandKey()].(*ice.Context); ok && c == m.Target() {
|
if c, ok := ice.Info.Index[m.CommandKey()].(*ice.Context); ok && c == m.Target() {
|
||||||
@ -135,3 +128,21 @@ func BlackAction(key ...string) ice.Actions {
|
|||||||
}
|
}
|
||||||
}}}
|
}}}
|
||||||
}
|
}
|
||||||
|
func RoleRight(m *ice.Message, role string, key ...string) bool {
|
||||||
|
return m.Cmdx(ROLE, RIGHT, role, key) == ice.OK
|
||||||
|
}
|
||||||
|
func Right(m *ice.Message, key ...ice.Any) bool {
|
||||||
|
return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key) != ice.OK,
|
||||||
|
ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(logs.FileLine(2)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func White(m *ice.Message, key ...string) {
|
||||||
|
for _, key := range key {
|
||||||
|
m.Cmd(ROLE, WHITE, VOID, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func Black(m *ice.Message, key ...string) {
|
||||||
|
for _, key := range key {
|
||||||
|
m.Cmd(ROLE, BLACK, VOID, key)
|
||||||
|
}
|
||||||
|
}
|
@ -48,6 +48,7 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd := exec.Command(bin, arg[1:]...)
|
cmd := exec.Command(bin, arg[1:]...)
|
||||||
|
m.Debug("what %v", m.Option("cmd_dir"))
|
||||||
if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 {
|
if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 {
|
||||||
if m.Logs(mdb.EXPORT, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) {
|
if m.Logs(mdb.EXPORT, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) {
|
||||||
file.MkdirAll(cmd.Dir, ice.MOD_DIR)
|
file.MkdirAll(cmd.Dir, ice.MOD_DIR)
|
||||||
@ -128,7 +129,8 @@ const (
|
|||||||
CMD_ERR = "cmd_err"
|
CMD_ERR = "cmd_err"
|
||||||
CMD_OUT = "cmd_out"
|
CMD_OUT = "cmd_out"
|
||||||
|
|
||||||
MAN = "man"
|
MAN = "man"
|
||||||
|
GREP = "grep"
|
||||||
)
|
)
|
||||||
|
|
||||||
const SYSTEM = "system"
|
const SYSTEM = "system"
|
||||||
@ -136,7 +138,7 @@ const SYSTEM = "system"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SYSTEM: {Name: "system cmd run", Help: "系统命令", Actions: ice.Actions{
|
SYSTEM: {Name: "system cmd run", Help: "系统命令", Actions: ice.Actions{
|
||||||
nfs.FIND: {Hand: func(m *ice.Message, arg ...string) {
|
"find": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(_system_find(m, arg[0], arg[1:]...))
|
m.Echo(_system_find(m, arg[0], arg[1:]...))
|
||||||
}},
|
}},
|
||||||
nfs.PUSH: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.PUSH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -10,9 +10,7 @@ import (
|
|||||||
"shylinux.com/x/toolkits/miss"
|
"shylinux.com/x/toolkits/miss"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _hash_fields(m *ice.Message) []string {
|
func _hash_fields(m *ice.Message) []string { return kit.Split(kit.Select(HASH_FIELD, m.OptionFields())) }
|
||||||
return kit.Split(kit.Select(HASH_FIELD, m.OptionFields()))
|
|
||||||
}
|
|
||||||
func _hash_inputs(m *ice.Message, prefix, chain string, field, value string) {
|
func _hash_inputs(m *ice.Message, prefix, chain string, field, value string) {
|
||||||
list := map[string]int{}
|
list := map[string]int{}
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -62,11 +60,11 @@ func _hash_select(m *ice.Message, prefix, chain, field, value string) {
|
|||||||
}
|
}
|
||||||
func _hash_select_field(m *ice.Message, prefix, chain string, key string, field string) (value string) {
|
func _hash_select_field(m *ice.Message, prefix, chain string, key string, field string) (value string) {
|
||||||
defer RLock(m, prefix, chain)()
|
defer RLock(m, prefix, chain)()
|
||||||
Richs(m, prefix, chain, key, func(k string, v Map) {
|
Richs(m, prefix, chain, key, func(key string, val Map) {
|
||||||
if field == HASH {
|
if field == HASH {
|
||||||
value = k
|
value = key
|
||||||
} else {
|
} else {
|
||||||
value = kit.Format(v[field])
|
value = kit.Format(val[field])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -179,7 +177,7 @@ func HashModify(m *ice.Message, arg ...Any) *ice.Message {
|
|||||||
}
|
}
|
||||||
func HashSelect(m *ice.Message, arg ...string) *ice.Message {
|
func HashSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||||
if len(arg) > 0 && arg[0] == FOREACH {
|
if len(arg) > 0 && arg[0] == FOREACH {
|
||||||
m.OptionFields(HashField(m))
|
m.Fields(0, HashField(m))
|
||||||
} else {
|
} else {
|
||||||
m.Fields(len(kit.Slice(arg, 0, 1)), HashField(m))
|
m.Fields(len(kit.Slice(arg, 0, 1)), HashField(m))
|
||||||
}
|
}
|
||||||
@ -190,7 +188,7 @@ func HashSelect(m *ice.Message, arg ...string) *ice.Message {
|
|||||||
return m.StatusTime()
|
return m.StatusTime()
|
||||||
}
|
}
|
||||||
func HashPrunes(m *ice.Message, cb func(Map) bool) *ice.Message {
|
func HashPrunes(m *ice.Message, cb func(Map) bool) *ice.Message {
|
||||||
expire := kit.Select(m.Time("-72h"), m.Option("before"))
|
expire := kit.Select(m.Time("-"+kit.Select("72h", m.Config(EXPIRE))), m.Option("before"))
|
||||||
m.OptionCB(PRUNES, func(key string, value Map) bool {
|
m.OptionCB(PRUNES, func(key string, value Map) bool {
|
||||||
if kit.Format(value[TIME]) > expire {
|
if kit.Format(value[TIME]) > expire {
|
||||||
return false
|
return false
|
||||||
@ -212,16 +210,12 @@ func HashSelects(m *ice.Message, arg ...string) *ice.Message {
|
|||||||
}
|
}
|
||||||
func HashSelectValue(m *ice.Message, cb Any) *ice.Message {
|
func HashSelectValue(m *ice.Message, cb Any) *ice.Message {
|
||||||
defer RLock(m, m.PrefixKey(), "")()
|
defer RLock(m, m.PrefixKey(), "")()
|
||||||
Richs(m, m.PrefixKey(), nil, FOREACH, func(key string, value Map) {
|
Richs(m, m.PrefixKey(), nil, FOREACH, func(key string, value Map) { _mdb_select(m, cb, key, value, nil, nil) })
|
||||||
_mdb_select(m, cb, key, value, nil, nil)
|
|
||||||
})
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func HashSelectUpdate(m *ice.Message, key string, cb Any) *ice.Message {
|
func HashSelectUpdate(m *ice.Message, key string, cb Any) *ice.Message {
|
||||||
defer Lock(m, m.PrefixKey(), "")()
|
defer Lock(m, m.PrefixKey(), "")()
|
||||||
Richs(m, m.PrefixKey(), nil, key, func(key string, value Map) {
|
Richs(m, m.PrefixKey(), nil, key, func(key string, value Map) { _mdb_select(m, cb, key, value, nil, nil) })
|
||||||
_mdb_select(m, cb, key, value, nil, nil)
|
|
||||||
})
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func HashSelectDetail(m *ice.Message, key string, cb Any) (has bool) {
|
func HashSelectDetail(m *ice.Message, key string, cb Any) (has bool) {
|
||||||
|
@ -10,9 +10,7 @@ import (
|
|||||||
"shylinux.com/x/toolkits/miss"
|
"shylinux.com/x/toolkits/miss"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _list_fields(m *ice.Message) []string {
|
func _list_fields(m *ice.Message) []string { return kit.Split(kit.Select(LIST_FIELD, m.OptionFields())) }
|
||||||
return kit.Split(kit.Select(LIST_FIELD, m.OptionFields()))
|
|
||||||
}
|
|
||||||
func _list_inputs(m *ice.Message, prefix, chain string, field, value string) {
|
func _list_inputs(m *ice.Message, prefix, chain string, field, value string) {
|
||||||
list := map[string]int{}
|
list := map[string]int{}
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -39,6 +37,7 @@ func _list_modify(m *ice.Message, prefix, chain string, field, value string, arg
|
|||||||
Grows(m, prefix, chain, field, value, func(index int, val ice.Map) { _mdb_modify(m, val, field, arg...) })
|
Grows(m, prefix, chain, field, value, func(index int, val ice.Map) { _mdb_modify(m, val, field, arg...) })
|
||||||
}
|
}
|
||||||
func _list_select(m *ice.Message, prefix, chain, field, value string) {
|
func _list_select(m *ice.Message, prefix, chain, field, value string) {
|
||||||
|
defer m.SortIntR(ID)
|
||||||
fields := _list_fields(m)
|
fields := _list_fields(m)
|
||||||
defer RLock(m, prefix, chain)()
|
defer RLock(m, prefix, chain)()
|
||||||
Grows(m, prefix, chain, kit.Select(m.Option(CACHE_FIELD), field), kit.Select(m.Option(CACHE_VALUE), value), func(value ice.Map) {
|
Grows(m, prefix, chain, kit.Select(m.Option(CACHE_FIELD), field), kit.Select(m.Option(CACHE_VALUE), value), func(value ice.Map) {
|
||||||
@ -124,7 +123,6 @@ func ListField(m *ice.Message) string { return kit.Select(LIST_FIELD, m.Config(F
|
|||||||
func ListSelect(m *ice.Message, arg ...string) *ice.Message {
|
func ListSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||||
m.Fields(len(kit.Slice(arg, 0, 1)), ListField(m))
|
m.Fields(len(kit.Slice(arg, 0, 1)), ListField(m))
|
||||||
if m.Cmdy(SELECT, m.PrefixKey(), "", LIST, ID, arg); !m.FieldsIsDetail() {
|
if m.Cmdy(SELECT, m.PrefixKey(), "", LIST, ID, arg); !m.FieldsIsDetail() {
|
||||||
m.SortIntR(ID)
|
|
||||||
return m.StatusTimeCountTotal(m.Config(COUNT))
|
return m.StatusTimeCountTotal(m.Config(COUNT))
|
||||||
}
|
}
|
||||||
return m.StatusTime()
|
return m.StatusTime()
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
"shylinux.com/x/toolkits/logs"
|
|
||||||
"shylinux.com/x/toolkits/task"
|
"shylinux.com/x/toolkits/task"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -113,6 +112,7 @@ const (
|
|||||||
DETAIL = "detail"
|
DETAIL = "detail"
|
||||||
RANDOM = "random"
|
RANDOM = "random"
|
||||||
ACTION = "action"
|
ACTION = "action"
|
||||||
|
FIELDS = "fields"
|
||||||
|
|
||||||
INPUTS = "inputs"
|
INPUTS = "inputs"
|
||||||
CREATE = "create"
|
CREATE = "create"
|
||||||
|
@ -18,6 +18,7 @@ func _zone_inputs(m *ice.Message, prefix, chain, zone string, field, value strin
|
|||||||
_hash_inputs(m, prefix, chain, field, value)
|
_hash_inputs(m, prefix, chain, field, value)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer RLock(m, prefix, chain)()
|
||||||
h := _hash_select_field(m, prefix, chain, zone, HASH)
|
h := _hash_select_field(m, prefix, chain, zone, HASH)
|
||||||
_list_inputs(m, prefix, kit.Keys(chain, HASH, h), field, value)
|
_list_inputs(m, prefix, kit.Keys(chain, HASH, h), field, value)
|
||||||
}
|
}
|
||||||
@ -27,11 +28,13 @@ func _zone_insert(m *ice.Message, prefix, chain, zone string, arg ...string) {
|
|||||||
h = _hash_insert(m, prefix, chain, _mdb_getmeta(m, prefix, chain, SHORT), zone)
|
h = _hash_insert(m, prefix, chain, _mdb_getmeta(m, prefix, chain, SHORT), zone)
|
||||||
}
|
}
|
||||||
m.Assert(h != "")
|
m.Assert(h != "")
|
||||||
|
defer Lock(m, prefix, chain)()
|
||||||
_list_insert(m, prefix, kit.Keys(chain, HASH, h), arg...)
|
_list_insert(m, prefix, kit.Keys(chain, HASH, h), arg...)
|
||||||
}
|
}
|
||||||
func _zone_modify(m *ice.Message, prefix, chain, zone, id string, arg ...string) {
|
func _zone_modify(m *ice.Message, prefix, chain, zone, id string, arg ...string) {
|
||||||
h := _hash_select_field(m, prefix, chain, zone, HASH)
|
h := _hash_select_field(m, prefix, chain, zone, HASH)
|
||||||
m.Assert(h != "")
|
m.Assert(h != "")
|
||||||
|
defer Lock(m, prefix, chain)()
|
||||||
_list_modify(m, prefix, kit.Keys(chain, HASH, h), ID, id, arg...)
|
_list_modify(m, prefix, kit.Keys(chain, HASH, h), ID, id, arg...)
|
||||||
}
|
}
|
||||||
func _zone_select(m *ice.Message, prefix, chain, zone string, id string) {
|
func _zone_select(m *ice.Message, prefix, chain, zone string, id string) {
|
||||||
@ -41,6 +44,7 @@ func _zone_select(m *ice.Message, prefix, chain, zone string, id string) {
|
|||||||
} else if zone == RANDOM {
|
} else if zone == RANDOM {
|
||||||
zone = RANDOMS
|
zone = RANDOMS
|
||||||
}
|
}
|
||||||
|
defer m.SortIntR(ID)
|
||||||
fields := _zone_fields(m)
|
fields := _zone_fields(m)
|
||||||
defer RLock(m, prefix, chain)()
|
defer RLock(m, prefix, chain)()
|
||||||
Richs(m, prefix, chain, kit.Select(FOREACH, zone), func(key string, val Map) {
|
Richs(m, prefix, chain, kit.Select(FOREACH, zone), func(key string, val Map) {
|
||||||
@ -183,11 +187,10 @@ func ZoneModify(m *ice.Message, arg ...Any) {
|
|||||||
}
|
}
|
||||||
func ZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
func ZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||||
arg = kit.Slice(arg, 0, 2)
|
arg = kit.Slice(arg, 0, 2)
|
||||||
m.Fields(len(arg), kit.Fields(TIME, m.Config(SHORT), COUNT), ZoneField(m))
|
m.Fields(len(arg), kit.Select(kit.Fields(TIME, m.Config(SHORT), COUNT), m.Config(FIELDS)), ZoneField(m))
|
||||||
if m.Cmdy(SELECT, m.PrefixKey(), "", ZONE, arg, logs.FileLineMeta(logs.FileLine(-1))); len(arg) == 0 {
|
if m.Cmdy(SELECT, m.PrefixKey(), "", ZONE, arg, logs.FileLineMeta(logs.FileLine(-1))); len(arg) == 0 {
|
||||||
m.Sort(ZoneShort(m)).StatusTimeCount().PushAction(m.Config(ACTION), REMOVE)
|
m.Sort(ZoneShort(m)).StatusTimeCount().PushAction(m.Config(ACTION), REMOVE)
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
m.SortIntR(ID)
|
|
||||||
m.StatusTimeCountTotal(_mdb_getmeta(m, "", kit.Keys(HASH, HashSelectField(m, arg[0], HASH)), COUNT))
|
m.StatusTimeCountTotal(_mdb_getmeta(m, "", kit.Keys(HASH, HashSelectField(m, arg[0], HASH)), COUNT))
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
|
@ -14,14 +14,14 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _cat_find(m *ice.Message, name string) (io.ReadCloser, error) {
|
func _cat_find(m *ice.Message, file string) (io.ReadCloser, error) {
|
||||||
if m.Option(CAT_CONTENT) != "" {
|
if m.Option(CAT_CONTENT) != "" {
|
||||||
return NewReadCloser(bytes.NewBufferString(m.Option(CAT_CONTENT))), nil
|
return NewReadCloser(bytes.NewBufferString(m.Option(CAT_CONTENT))), nil
|
||||||
}
|
}
|
||||||
return OpenFile(m, path.Join(m.Option(DIR_ROOT), name))
|
return OpenFile(m, path.Join(m.Option(DIR_ROOT), file))
|
||||||
}
|
}
|
||||||
func _cat_size(m *ice.Message, p string) (nline int) {
|
func _cat_size(m *ice.Message, file string) (nline int) {
|
||||||
if f, e := OpenFile(m, p); m.Warn(e) {
|
if f, e := OpenFile(m, file); !m.Warn(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
for bio := bufio.NewScanner(f); bio.Scan(); nline++ {
|
for bio := bufio.NewScanner(f); bio.Scan(); nline++ {
|
||||||
bio.Text()
|
bio.Text()
|
||||||
@ -29,23 +29,22 @@ func _cat_size(m *ice.Message, p string) (nline int) {
|
|||||||
}
|
}
|
||||||
return nline
|
return nline
|
||||||
}
|
}
|
||||||
func _cat_hash(m *ice.Message, p string) string {
|
func _cat_hash(m *ice.Message, file string) string {
|
||||||
if f, e := OpenFile(m, p); !m.Warn(e) {
|
if f, e := OpenFile(m, file); !m.Warn(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
return kit.Hashs(f)
|
return kit.Hashs(f)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
func _cat_list(m *ice.Message, name string) {
|
func _cat_list(m *ice.Message, file string) {
|
||||||
if m.Option(CAT_CONTENT) == "" && !aaa.Right(m, name) {
|
if m.Option(CAT_CONTENT) == "" && !aaa.Right(m, file) {
|
||||||
return // 没有权限
|
return
|
||||||
}
|
}
|
||||||
f, e := _cat_find(m, name)
|
f, e := _cat_find(m, file)
|
||||||
if m.Warn(e, ice.ErrNotFound) {
|
if m.Warn(e, ice.ErrNotFound, file) {
|
||||||
return // 没有文件
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
switch cb := m.OptionCB("").(type) {
|
switch cb := m.OptionCB("").(type) {
|
||||||
case func(string, int) string:
|
case func(string, int) string:
|
||||||
list := []string{}
|
list := []string{}
|
||||||
@ -53,28 +52,25 @@ func _cat_list(m *ice.Message, name string) {
|
|||||||
list = append(list, cb(bio.Text(), i))
|
list = append(list, cb(bio.Text(), i))
|
||||||
}
|
}
|
||||||
m.Echo(strings.Join(list, ice.NL) + ice.NL)
|
m.Echo(strings.Join(list, ice.NL) + ice.NL)
|
||||||
|
|
||||||
case func(string, int):
|
case func(string, int):
|
||||||
for bio, i := bufio.NewScanner(f), 0; bio.Scan(); i++ {
|
for bio, i := bufio.NewScanner(f), 0; bio.Scan(); i++ {
|
||||||
cb(bio.Text(), i)
|
cb(bio.Text(), i)
|
||||||
}
|
}
|
||||||
|
|
||||||
case func(string):
|
case func(string):
|
||||||
for bio := bufio.NewScanner(f); bio.Scan(); {
|
for bio := bufio.NewScanner(f); bio.Scan(); {
|
||||||
cb(bio.Text())
|
cb(bio.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
case func([]string, string):
|
case func([]string, string):
|
||||||
for bio := bufio.NewScanner(f); bio.Scan(); {
|
for bio := bufio.NewScanner(f); bio.Scan(); {
|
||||||
cb(kit.Split(bio.Text()), bio.Text())
|
cb(kit.Split(bio.Text()), bio.Text())
|
||||||
}
|
}
|
||||||
case nil:
|
case nil:
|
||||||
buf, begin := make([]byte, ice.MOD_BUFS), 0
|
buf, size := make([]byte, ice.MOD_BUFS), 0
|
||||||
for {
|
for {
|
||||||
if n, e := f.Read(buf[begin:]); !m.Warn(e, ice.ErrNotValid, name) {
|
if n, e := f.Read(buf[size:]); !m.Warn(e, ice.ErrNotValid, file) {
|
||||||
m.Logs(mdb.IMPORT, FILE, name, SIZE, n)
|
m.Logs(mdb.IMPORT, FILE, file, SIZE, n)
|
||||||
if begin += n; begin < len(buf) {
|
if size += n; size < len(buf) {
|
||||||
buf = buf[:begin]
|
buf = buf[:size]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
buf = append(buf, make([]byte, ice.MOD_BUFS)...)
|
buf = append(buf, make([]byte, ice.MOD_BUFS)...)
|
||||||
@ -82,7 +78,7 @@ func _cat_list(m *ice.Message, name string) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo(string(buf))
|
m.Echo(string(buf)).StatusTime(FILE, file, SIZE, size)
|
||||||
default:
|
default:
|
||||||
m.ErrorNotImplement(cb)
|
m.ErrorNotImplement(cb)
|
||||||
}
|
}
|
||||||
@ -92,8 +88,8 @@ const (
|
|||||||
CAT_CONTENT = "cat_content"
|
CAT_CONTENT = "cat_content"
|
||||||
|
|
||||||
STDIO = "stdio"
|
STDIO = "stdio"
|
||||||
SOURCE = "source"
|
|
||||||
MODULE = "module"
|
MODULE = "module"
|
||||||
|
SOURCE = "source"
|
||||||
SCRIPT = "script"
|
SCRIPT = "script"
|
||||||
BINARY = "binary"
|
BINARY = "binary"
|
||||||
TARGET = "target"
|
TARGET = "target"
|
||||||
@ -105,29 +101,30 @@ const (
|
|||||||
REPOS = "repos"
|
REPOS = "repos"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
|
SVG = ice.SVG
|
||||||
HTML = ice.HTML
|
HTML = ice.HTML
|
||||||
CSS = ice.CSS
|
CSS = ice.CSS
|
||||||
JS = ice.JS
|
JS = ice.JS
|
||||||
GO = ice.GO
|
GO = ice.GO
|
||||||
SH = ice.SH
|
SH = ice.SH
|
||||||
SHY = ice.SHY
|
SHY = ice.SHY
|
||||||
SVG = ice.SVG
|
|
||||||
CSV = ice.CSV
|
CSV = ice.CSV
|
||||||
JSON = ice.JSON
|
JSON = ice.JSON
|
||||||
|
|
||||||
PY = "py"
|
PY = "py"
|
||||||
MD = "md"
|
MD = "md"
|
||||||
TXT = "txt"
|
TXT = "txt"
|
||||||
IML = "iml"
|
|
||||||
XML = "xml"
|
XML = "xml"
|
||||||
YML = "yml"
|
YML = "yml"
|
||||||
ZML = "zml"
|
ZML = "zml"
|
||||||
|
IML = "iml"
|
||||||
|
|
||||||
PNG = "png"
|
PNG = "png"
|
||||||
JPG = "jpg"
|
JPG = "jpg"
|
||||||
MP4 = "mp4"
|
MP4 = "mp4"
|
||||||
PDF = "pdf"
|
PDF = "pdf"
|
||||||
|
|
||||||
|
TAR = "tar"
|
||||||
PWD = "./"
|
PWD = "./"
|
||||||
PS = ice.PS
|
PS = ice.PS
|
||||||
PT = ice.PT
|
PT = ice.PT
|
||||||
@ -137,28 +134,21 @@ const CAT = "cat"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Configs: ice.Configs{
|
Index.Merge(&ice.Context{Configs: ice.Configs{
|
||||||
CAT: {Name: CAT, Help: "文件", Value: kit.Data(
|
CAT: {Value: kit.Data(SOURCE, kit.Dict(
|
||||||
SOURCE, kit.Dict(
|
HTML, ice.TRUE, CSS, ice.TRUE, JS, ice.TRUE, GO, ice.TRUE, SH, ice.TRUE, SHY, ice.TRUE, CSV, ice.TRUE, JSON, ice.TRUE,
|
||||||
HTML, ice.TRUE, CSS, ice.TRUE, JS, ice.TRUE, GO, ice.TRUE, SH, ice.TRUE, CSV, ice.TRUE, JSON, ice.TRUE,
|
PY, ice.TRUE, MD, ice.TRUE, TXT, ice.TRUE, IML, ice.TRUE, XML, ice.TRUE, YML, ice.TRUE, ZML, ice.TRUE,
|
||||||
SHY, ice.TRUE, "conf", ice.TRUE, "makefile", ice.TRUE, "license", ice.TRUE,
|
"license", ice.TRUE, "makefile", ice.TRUE, "configure", ice.TRUE, "conf", ice.TRUE,
|
||||||
PY, ice.TRUE, MD, ice.TRUE, TXT, ice.TRUE, IML, ice.TRUE, XML, ice.TRUE, YML, ice.TRUE, ZML, ice.TRUE,
|
))},
|
||||||
"configure", ice.TRUE,
|
|
||||||
),
|
|
||||||
)},
|
|
||||||
}, Commands: ice.Commands{
|
}, Commands: ice.Commands{
|
||||||
CAT: {Name: "cat path auto", Help: "文件", Actions: ice.Actions{
|
CAT: {Name: "cat path auto", Help: "文件", Actions: ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO, ice.USR_PUBLISH) }},
|
||||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_SHY)
|
|
||||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_GO)
|
|
||||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH)
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
|
if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
|
||||||
m.Cmdy(DIR, arg)
|
m.Cmdy(DIR, arg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m.Option(DIR_ROOT) != "" {
|
if m.Option(DIR_ROOT) != "" {
|
||||||
m.Logs(mdb.SELECT, DIR_ROOT, m.Option(DIR_ROOT))
|
m.Logs(mdb.SELECT, m.OptionSimple(DIR_ROOT))
|
||||||
}
|
}
|
||||||
_cat_list(m, arg[0])
|
_cat_list(m, arg[0])
|
||||||
}},
|
}},
|
||||||
@ -170,13 +160,9 @@ func IsSourceFile(m *ice.Message, ext string) bool {
|
|||||||
func OptionLoad(m *ice.Message, file string) *ice.Message {
|
func OptionLoad(m *ice.Message, file string) *ice.Message {
|
||||||
if f, e := OpenFile(m, file); e == nil {
|
if f, e := OpenFile(m, file); e == nil {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
var data ice.Any
|
var data ice.Any
|
||||||
m.Assert(json.NewDecoder(f).Decode(&data))
|
m.Assert(json.NewDecoder(f).Decode(&data))
|
||||||
|
kit.Fetch(data, func(key string, value ice.Any) { m.Option(key, kit.Simple(value)) })
|
||||||
kit.Fetch(data, func(key string, value ice.Any) {
|
|
||||||
m.Option(key, kit.Simple(value))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,14 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _dir_size(m *ice.Message, p string) int {
|
func _dir_size(m *ice.Message, dir string) int {
|
||||||
if ls, e := ReadDir(m, p); !m.Warn(e) {
|
if ls, e := ReadDir(m, dir); !m.Warn(e) {
|
||||||
return len(ls)
|
return len(ls)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
func _dir_hash(m *ice.Message, p string) string {
|
func _dir_hash(m *ice.Message, dir string) string {
|
||||||
if ls, e := ReadDir(m, p); !m.Warn(e) {
|
if ls, e := ReadDir(m, dir); !m.Warn(e) {
|
||||||
meta := []string{}
|
meta := []string{}
|
||||||
for _, s := range ls {
|
for _, s := range ls {
|
||||||
meta = append(meta, kit.Format("%s%d%s", s.Name(), s.Size(), s.ModTime()))
|
meta = append(meta, kit.Format("%s%d%s", s.Name(), s.Size(), s.ModTime()))
|
||||||
@ -28,30 +28,27 @@ func _dir_hash(m *ice.Message, p string) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
func _dir_list(m *ice.Message, root string, name 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) *ice.Message {
|
||||||
list, _ := ReadDir(m, path.Join(root, name))
|
ls, _ := ReadDir(m, path.Join(root, dir))
|
||||||
|
if len(ls) == 0 {
|
||||||
if len(list) == 0 { // 单个文件
|
if s, e := StatFile(m, path.Join(root, dir)); e == nil && !s.IsDir() {
|
||||||
if s, e := StatFile(m, path.Join(root, name)); e == nil && !s.IsDir() {
|
_ls, _ := ReadDir(m, path.Dir(path.Join(root, dir)))
|
||||||
ls, _ := ReadDir(m, path.Dir(path.Join(root, name)))
|
for _, s := range _ls {
|
||||||
for _, s := range ls {
|
if s.Name() == path.Base(dir) {
|
||||||
if s.Name() == path.Base(name) {
|
ls = append(ls, s)
|
||||||
list = append(list, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
name, deep = path.Dir(name), false
|
dir, deep = path.Dir(dir), false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, f := range ls {
|
||||||
for _, f := range list {
|
|
||||||
if f.Name() == ice.PT || f.Name() == ".." {
|
if f.Name() == ice.PT || f.Name() == ".." {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(f.Name(), ice.PT) && dir_type != TYPE_ALL {
|
if strings.HasPrefix(f.Name(), ice.PT) && dir_type != TYPE_ALL {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
p, _dir := path.Join(root, dir, f.Name()), path.Join(dir, f.Name())
|
||||||
p, pp := path.Join(root, name, f.Name()), path.Join(name, f.Name())
|
|
||||||
isDir := f.IsDir() || kit.IsDir(p)
|
isDir := f.IsDir() || kit.IsDir(p)
|
||||||
if !(dir_type == TYPE_CAT && isDir || dir_type == TYPE_DIR && !isDir) && (dir_reg == nil || dir_reg.MatchString(f.Name())) {
|
if !(dir_type == TYPE_CAT && isDir || dir_type == TYPE_DIR && !isDir) && (dir_reg == nil || dir_reg.MatchString(f.Name())) {
|
||||||
switch cb := m.OptionCB("").(type) {
|
switch cb := m.OptionCB("").(type) {
|
||||||
@ -65,14 +62,12 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
|
|||||||
default:
|
default:
|
||||||
m.ErrorNotImplement(cb)
|
m.ErrorNotImplement(cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
switch field {
|
switch field {
|
||||||
case mdb.TIME:
|
case mdb.TIME:
|
||||||
m.Push(field, f.ModTime().Format(ice.MOD_TIME))
|
m.Push(field, f.ModTime().Format(ice.MOD_TIME))
|
||||||
case mdb.TYPE:
|
case mdb.TYPE:
|
||||||
m.Push(field, kit.Select(CAT, DIR, isDir))
|
m.Push(field, kit.Select(CAT, DIR, isDir))
|
||||||
|
|
||||||
case TREE:
|
case TREE:
|
||||||
if level == 0 {
|
if level == 0 {
|
||||||
m.Push(field, f.Name())
|
m.Push(field, f.Name())
|
||||||
@ -82,12 +77,11 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
|
|||||||
case FULL:
|
case FULL:
|
||||||
m.Push(field, p+kit.Select("", ice.PS, isDir))
|
m.Push(field, p+kit.Select("", ice.PS, isDir))
|
||||||
case PATH:
|
case PATH:
|
||||||
m.Push(field, pp+kit.Select("", ice.PS, isDir))
|
m.Push(field, _dir+kit.Select("", ice.PS, isDir))
|
||||||
case FILE:
|
case FILE:
|
||||||
m.Push(field, f.Name()+kit.Select("", ice.PS, isDir))
|
m.Push(field, f.Name()+kit.Select("", ice.PS, isDir))
|
||||||
case NAME:
|
case NAME:
|
||||||
m.Push(field, f.Name())
|
m.Push(field, f.Name())
|
||||||
|
|
||||||
case SIZE:
|
case SIZE:
|
||||||
if isDir {
|
if isDir {
|
||||||
m.Push(field, _dir_size(m, p))
|
m.Push(field, _dir_size(m, p))
|
||||||
@ -129,14 +123,12 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if deep && isDir {
|
if deep && isDir {
|
||||||
switch f.Name() {
|
switch f.Name() {
|
||||||
case "node_modules", "pluged", "target", "trash":
|
case "node_modules", "pluged", "target", "trash":
|
||||||
continue // 禁用递归
|
continue
|
||||||
}
|
}
|
||||||
|
_dir_list(m, root, _dir, level+1, deep, dir_type, dir_reg, fields)
|
||||||
_dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
@ -172,33 +164,25 @@ const DIR = "dir"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
DIR: {Name: "dir path field auto upload", Help: "目录", Actions: ice.Actions{
|
DIR: {Name: "dir path field auto dir_deep upload", Help: "目录", Actions: ice.Actions{
|
||||||
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, ice.SRC)
|
aaa.White(m, ice.SRC, ice.BIN, ice.USR, ice.USR_LOCAL_GO)
|
||||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.BIN)
|
aaa.Black(m, ice.USR_LOCAL)
|
||||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR)
|
|
||||||
m.Cmd(aaa.ROLE, aaa.BLACK, aaa.VOID, ice.USR_LOCAL)
|
|
||||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_LOCAL_GO)
|
|
||||||
}},
|
|
||||||
mdb.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy("web.cache", "upload_watch", m.Option(PATH))
|
|
||||||
}},
|
|
||||||
TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy(TRASH, mdb.CREATE, m.Option(PATH))
|
|
||||||
}},
|
}},
|
||||||
|
mdb.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("web.cache", "upload_watch", m.Option(PATH)) }},
|
||||||
|
TRASH: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TRASH, mdb.CREATE, m.Option(PATH)) }},
|
||||||
}, Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, arg ...string) {
|
||||||
root, name := kit.Select(PWD, m.Option(DIR_ROOT)), kit.Select(PWD, arg, 0)
|
root, dir := kit.Select(PWD, m.Option(DIR_ROOT)), kit.Select(PWD, arg, 0)
|
||||||
if strings.HasPrefix(name, ice.PS) {
|
if strings.HasPrefix(dir, ice.PS) {
|
||||||
root = ice.PS
|
root = ice.PS
|
||||||
}
|
}
|
||||||
if !aaa.Right(m, path.Join(root, name)) {
|
if !aaa.Right(m, path.Join(root, dir)) {
|
||||||
return // 没有权限
|
return
|
||||||
}
|
}
|
||||||
fields := kit.Split(kit.Select(kit.Select(DIR_DEF_FIELDS, m.OptionFields()), kit.Join(kit.Slice(arg, 1))))
|
fields := kit.Split(kit.Select(kit.Select(DIR_DEF_FIELDS, m.OptionFields()), kit.Join(kit.Slice(arg, 1))))
|
||||||
m.Logs(mdb.SELECT, DIR_ROOT, m.Option(DIR_ROOT), DIR_REG, m.Option(DIR_REG), mdb.FIELD, kit.Join(fields, ","))
|
m.Logs(mdb.SELECT, DIR_ROOT, m.Option(DIR_ROOT), DIR_REG, m.Option(DIR_REG), mdb.FIELD, kit.Join(fields, ice.FS))
|
||||||
_dir_list(m, root, name, 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)), fields)
|
_dir_list(m, root, dir, 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)), fields)
|
||||||
m.SortTimeR(mdb.TIME)
|
m.Sort(PATH).StatusTimeCount()
|
||||||
m.StatusTimeCount()
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -211,10 +195,8 @@ func Dir(m *ice.Message, sort string) *ice.Message {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func DirDeepAll(m *ice.Message, root, dir string, cb func(ice.Maps), arg ...string) *ice.Message {
|
func DirDeepAll(m *ice.Message, root, dir string, cb func(ice.Maps), arg ...string) *ice.Message {
|
||||||
m.Option(DIR_TYPE, CAT)
|
m.Options(DIR_TYPE, CAT, DIR_ROOT, root, DIR_DEEP, ice.TRUE)
|
||||||
m.Option(DIR_ROOT, root)
|
if msg := m.Cmd(DIR, dir, arg).Tables(cb); cb == nil {
|
||||||
m.Option(DIR_DEEP, ice.TRUE)
|
|
||||||
if msg := m.Cmd(DIR, dir, arg).Sort(PATH).Tables(cb); cb == nil {
|
|
||||||
return m.Copy(msg)
|
return m.Copy(msg)
|
||||||
} else {
|
} else {
|
||||||
return msg
|
return msg
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package nfs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
|
||||||
)
|
|
||||||
|
|
||||||
const FIND = "find"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Index.MergeCommands(ice.Commands{
|
|
||||||
FIND: {Name: "find path word auto", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
for _, file := range strings.Split(m.Cmdx("cli.system", FIND, PWD, "-name", arg[1]), ice.NL) {
|
|
||||||
m.Push(FILE, strings.TrimPrefix(file, PWD))
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package nfs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
|
||||||
)
|
|
||||||
|
|
||||||
const GREP = "grep"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Index.MergeCommands(ice.Commands{
|
|
||||||
GREP: {Name: "grep word path auto", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Option("cmd_dir", arg[1])
|
|
||||||
for _, line := range strings.Split(m.Cmdx("cli.system", GREP, "--exclude=.[a-z]*", "--exclude-dir=.[a-z]*", "-rni", arg[0], ice.PT), ice.NL) {
|
|
||||||
if ls := strings.SplitN(line, ice.DF, 3); len(ls) > 2 {
|
|
||||||
m.Push(FILE, ls[0])
|
|
||||||
m.Push(LINE, ls[1])
|
|
||||||
m.Push(mdb.TEXT, ls[2])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
}
|
|
@ -4,6 +4,4 @@ import ice "shylinux.com/x/icebergs"
|
|||||||
|
|
||||||
var Index = &ice.Context{Name: "nfs", Help: "存储模块"}
|
var Index = &ice.Context{Name: "nfs", Help: "存储模块"}
|
||||||
|
|
||||||
func init() {
|
func init() { ice.Index.Register(Index, nil, CAT, DIR, PACK, DEFS, SAVE, PUSH, COPY, LINK, TAIL, TRASH) }
|
||||||
ice.Index.Register(Index, nil, TAR, CAT, DIR, PACK, DEFS, SAVE, PUSH, COPY, LINK, TAIL, TRASH, GREP)
|
|
||||||
}
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
chapter "nfs"
|
|
||||||
|
|
||||||
field "文件" nfs.cat
|
|
||||||
field "目录" nfs.dir
|
|
||||||
field "跟踪" nfs.tail
|
|
||||||
field "删除" nfs.trash
|
|
||||||
|
|
@ -19,18 +19,18 @@ func init() {
|
|||||||
pack := PackFile
|
pack := PackFile
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
PACK: {Name: "pack path auto upload create", Help: "文件系统", Actions: ice.Actions{
|
PACK: {Name: "pack path auto upload create", Help: "文件系统", Actions: ice.Actions{
|
||||||
mdb.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
mdb.UPLOAD: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if b, h, e := m.R.FormFile(mdb.UPLOAD); m.Assert(e) {
|
if c, e := DiskFile.OpenFile(m.Option(FILE)); m.Assert(e) {
|
||||||
defer b.Close()
|
defer c.Close()
|
||||||
if f, p, e := pack.CreateFile(path.Join(m.Option(PATH), h.Filename)); m.Assert(e) {
|
if f, p, e := pack.CreateFile(path.Join(m.Option(PATH), m.Option(mdb.NAME))); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if n, e := io.Copy(f, b); m.Assert(e) {
|
if n, e := io.Copy(f, c); m.Assert(e) {
|
||||||
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create path=h1/h2/hi.txt text=hello", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create path=src/hi/hi.txt text=hello", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if f, p, e := pack.CreateFile(m.Option(PATH)); m.Assert(e) {
|
if f, p, e := pack.CreateFile(m.Option(PATH)); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if n, e := f.Write([]byte(m.Option(mdb.TEXT))); m.Assert(e) {
|
if n, e := f.Write([]byte(m.Option(mdb.TEXT))); m.Assert(e) {
|
||||||
@ -38,9 +38,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) { pack.Remove(path.Clean(m.Option(PATH))) }},
|
||||||
pack.Remove(path.Clean(m.Option(PATH)))
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, arg ...string) {
|
||||||
p := kit.Select("", arg, 0)
|
p := kit.Select("", arg, 0)
|
||||||
if p != "" && !strings.HasSuffix(p, PS) {
|
if p != "" && !strings.HasSuffix(p, PS) {
|
||||||
@ -52,16 +50,13 @@ func init() {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ls, _ := pack.ReadDir(p)
|
ls, _ := pack.ReadDir(p)
|
||||||
for _, f := range ls {
|
for _, f := range ls {
|
||||||
m.Push(mdb.TIME, f.ModTime().Format(ice.MOD_TIME))
|
m.Push(mdb.TIME, f.ModTime().Format(ice.MOD_TIME))
|
||||||
m.Push(PATH, path.Join(p, f.Name())+kit.Select("", PS, f.IsDir()))
|
m.Push(PATH, path.Join(p, f.Name())+kit.Select("", PS, f.IsDir()))
|
||||||
m.Push(SIZE, kit.FmtSize(f.Size()))
|
m.Push(SIZE, kit.FmtSize(f.Size()))
|
||||||
}
|
}
|
||||||
m.Sort("time,path")
|
m.Sort(PATH).PushAction(mdb.REMOVE).StatusTimeCount()
|
||||||
m.PushAction(mdb.REMOVE)
|
|
||||||
m.StatusTimeCount()
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -23,46 +23,42 @@ func _defs_file(m *ice.Message, name string, text ...string) {
|
|||||||
func _save_file(m *ice.Message, name string, text ...string) {
|
func _save_file(m *ice.Message, name string, text ...string) {
|
||||||
if f, p, e := CreateFile(m, path.Join(m.Option(DIR_ROOT), name)); m.Assert(e) {
|
if f, p, e := CreateFile(m, path.Join(m.Option(DIR_ROOT), name)); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
defer m.Echo(p)
|
||||||
for _, v := range text {
|
for _, v := range text {
|
||||||
if n, e := fmt.Fprint(f, v); m.Assert(e) {
|
if n, e := fmt.Fprint(f, v); m.Assert(e) {
|
||||||
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo(p)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _push_file(m *ice.Message, name string, text ...string) {
|
func _push_file(m *ice.Message, name string, text ...string) {
|
||||||
if f, p, e := AppendFile(m, path.Join(m.Option(DIR_ROOT), name)); m.Assert(e) {
|
if f, p, e := AppendFile(m, path.Join(m.Option(DIR_ROOT), name)); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
defer m.Echo(p)
|
||||||
for _, k := range text {
|
for _, k := range text {
|
||||||
if n, e := fmt.Fprint(f, k); m.Assert(e) {
|
if n, e := fmt.Fprint(f, k); m.Assert(e) {
|
||||||
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo(p)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _copy_file(m *ice.Message, name string, from ...string) {
|
func _copy_file(m *ice.Message, name string, from ...string) {
|
||||||
if f, p, e := CreateFile(m, path.Join(m.Option(DIR_ROOT), name)); m.Assert(e) {
|
if f, p, e := CreateFile(m, path.Join(m.Option(DIR_ROOT), name)); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
defer m.Echo(p)
|
||||||
for _, v := range from {
|
for _, v := range from {
|
||||||
if s, e := OpenFile(m, path.Join(m.Option(DIR_ROOT), v)); !m.Warn(e, ice.ErrNotFound, name) {
|
if s, e := OpenFile(m, path.Join(m.Option(DIR_ROOT), v)); !m.Warn(e, ice.ErrNotFound, v) {
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
if n, e := io.Copy(f, s); !m.Warn(e, ice.ErrNotValid, v) {
|
||||||
if n, e := io.Copy(f, s); !m.Warn(e, ice.ErrNotFound, name) {
|
|
||||||
m.Logs(mdb.IMPORT, FILE, v, SIZE, n)
|
m.Logs(mdb.IMPORT, FILE, v, SIZE, n)
|
||||||
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
m.Logs(mdb.EXPORT, FILE, p, SIZE, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo(p)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _link_file(m *ice.Message, name string, from string) {
|
func _link_file(m *ice.Message, name string, from string) {
|
||||||
if m.Warn(from == "", ice.ErrNotValid, from) {
|
if m.Warn(from == "", ice.ErrNotValid, FROM) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
name = path.Join(m.Option(DIR_ROOT), name)
|
name = path.Join(m.Option(DIR_ROOT), name)
|
||||||
@ -72,10 +68,8 @@ func _link_file(m *ice.Message, name string, from string) {
|
|||||||
}
|
}
|
||||||
Remove(m, name)
|
Remove(m, name)
|
||||||
MkdirAll(m, path.Dir(name))
|
MkdirAll(m, path.Dir(name))
|
||||||
if m.Warn(Link(m, from, name)) {
|
if m.Warn(Link(m, from, name)) && m.Warn(Symlink(m, from, name), ice.ErrWarn, from) {
|
||||||
if m.Warn(Symlink(m, from, name), ice.ErrWarn, from) {
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m.Logs(mdb.CREATE, FILE, name, FROM, from)
|
m.Logs(mdb.CREATE, FILE, name, FROM, from)
|
||||||
m.Echo(name)
|
m.Echo(name)
|
||||||
@ -94,22 +88,22 @@ const LINK = "link"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
DEFS: {Name: "defs file text...", Help: "默认", Hand: func(m *ice.Message, arg ...string) {
|
DEFS: {Name: "defs file text run", Help: "默认", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_defs_file(m, arg[0], arg[1:]...)
|
_defs_file(m, arg[0], arg[1:]...)
|
||||||
}},
|
}},
|
||||||
SAVE: {Name: "save file text...", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
SAVE: {Name: "save file text run", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
arg = append(arg, m.Option(CONTENT))
|
arg = append(arg, m.Option(CONTENT))
|
||||||
}
|
}
|
||||||
_save_file(m, arg[0], arg[1:]...)
|
_save_file(m, arg[0], arg[1:]...)
|
||||||
}},
|
}},
|
||||||
PUSH: {Name: "push file text...", Help: "追加", Hand: func(m *ice.Message, arg ...string) {
|
PUSH: {Name: "push file text run", Help: "追加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
arg = append(arg, m.Option(CONTENT))
|
arg = append(arg, m.Option(CONTENT))
|
||||||
}
|
}
|
||||||
_push_file(m, arg[0], arg[1:]...)
|
_push_file(m, arg[0], arg[1:]...)
|
||||||
}},
|
}},
|
||||||
COPY: {Name: "copy file from...", Help: "复制", Hand: func(m *ice.Message, arg ...string) {
|
COPY: {Name: "copy file from run", Help: "复制", Hand: func(m *ice.Message, arg ...string) {
|
||||||
for _, file := range arg[1:] {
|
for _, file := range arg[1:] {
|
||||||
if ExistsFile(m, file) {
|
if ExistsFile(m, file) {
|
||||||
_copy_file(m, arg[0], arg[1:]...)
|
_copy_file(m, arg[0], arg[1:]...)
|
||||||
@ -117,7 +111,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
LINK: {Name: "link file from", Help: "链接", Hand: func(m *ice.Message, arg ...string) {
|
LINK: {Name: "link file from run", Help: "链接", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_link_file(m, arg[0], arg[1])
|
_link_file(m, arg[0], arg[1])
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,6 @@ package nfs
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
@ -11,66 +10,46 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _tail_create(m *ice.Message, arg ...string) {
|
func _tail_create(m *ice.Message, arg ...string) {
|
||||||
h := m.Cmdx(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, arg)
|
m.Debug("what %v", arg)
|
||||||
|
h := mdb.HashCreate(m, arg)
|
||||||
kit.ForEach(kit.Split(m.Option(FILE)), func(file string) {
|
kit.Fetch(kit.Split(m.Option(FILE)), func(file string) {
|
||||||
r, w := io.Pipe()
|
m.Options("cmd_output", Pipe(m, func(text string) { mdb.ZoneInsert(m, h, FILE, file, SIZE, len(text), mdb.TEXT, text) }), mdb.CACHE_CLEAR_ON_EXIT, ice.TRUE)
|
||||||
m.Go(func() {
|
|
||||||
for bio := bufio.NewScanner(r); bio.Scan(); {
|
|
||||||
m.Logs(mdb.IMPORT, FILE, file, SIZE, len(bio.Text()))
|
|
||||||
mdb.Grow(m, TAIL, kit.Keys(mdb.HASH, h), kit.Dict(
|
|
||||||
FILE, file, SIZE, len(bio.Text()), mdb.TEXT, bio.Text(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
m.Option("cmd_output", w)
|
|
||||||
m.Option(mdb.CACHE_CLEAR_ON_EXIT, ice.TRUE)
|
|
||||||
m.Cmd("cli.daemon", TAIL, "-n", "0", "-f", file)
|
m.Cmd("cli.daemon", TAIL, "-n", "0", "-f", file)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _tail_count(m *ice.Message, name string) string {
|
|
||||||
return m.Conf(TAIL, kit.KeyHash(name, kit.Keym(mdb.COUNT)))
|
|
||||||
}
|
|
||||||
|
|
||||||
const TAIL = "tail"
|
const TAIL = "tail"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TAIL: {Name: "tail name id auto page filter:text create", Help: "日志流", Actions: ice.MergeActions(ice.Actions{
|
TAIL: {Name: "tail name id auto page filter:text create", Help: "日志流", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.Richs(m, TAIL, "", mdb.FOREACH, func(key string, value ice.Map) {
|
mdb.HashSelect(m.Spawn(ice.OptionFields("name,file"))).Tables(func(value ice.Maps) {
|
||||||
value, _ = kit.GetMeta(value), m.Option(mdb.HASH, key)
|
m.Debug("what %v", value)
|
||||||
m.Cmd(TAIL, mdb.CREATE, kit.SimpleKV("file,name", value))
|
m.Cmd("", mdb.CREATE, kit.SimpleKV("name,file", value))
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case FILE:
|
case FILE:
|
||||||
m.Cmdy(DIR, kit.Select(PWD, arg, 1), PATH).RenameAppend(PATH, FILE)
|
m.Cmdy(DIR, kit.Select(PWD, arg, 1), PATH).RenameAppend(PATH, FILE).ProcessAgain()
|
||||||
m.ProcessAgain()
|
|
||||||
case mdb.NAME:
|
case mdb.NAME:
|
||||||
m.Push(arg[0], kit.Split(m.Option(FILE), ice.PS))
|
m.Push(arg[0], kit.Split(m.Option(FILE), ice.PS))
|
||||||
case mdb.LIMIT:
|
case mdb.LIMIT:
|
||||||
m.Push(arg[0], kit.List("10", "20", "30", "50"))
|
m.Push(arg[0], kit.List("10", "20", "30", "50"))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create file name", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name file", Hand: func(m *ice.Message, arg ...string) { _tail_create(m, arg...) }},
|
||||||
_tail_create(m, arg...)
|
}, mdb.PageZoneAction(mdb.SHORT, mdb.NAME, mdb.FIELDS, "time,name,count,file", mdb.FIELD, "time,id,file,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
}},
|
mdb.PageZoneSelect(m, arg...)
|
||||||
}, mdb.ZoneAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,id,file,text")), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Fields(len(kit.Slice(arg, 0, 2)), "time,name,count,file", mdb.ZoneField(m))
|
|
||||||
mdb.OptionPage(m, kit.Slice(arg, 2)...)
|
|
||||||
|
|
||||||
mdb.ZoneSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, head []string) {
|
|
||||||
if strings.Contains(value[mdb.TEXT], m.Option(mdb.CACHE_FILTER)) {
|
|
||||||
m.Push("", value, head)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if len(arg) > 0 {
|
|
||||||
m.StatusTimeCountTotal(_tail_count(m, arg[0]))
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func Pipe(m *ice.Message, cb func(string)) io.WriteCloser {
|
||||||
|
r, w := io.Pipe()
|
||||||
|
m.Go(func() {
|
||||||
|
for bio := bufio.NewScanner(r); bio.Scan(); {
|
||||||
|
cb(bio.Text())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
package nfs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"archive/tar"
|
|
||||||
"compress/gzip"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
|
||||||
kit "shylinux.com/x/toolkits"
|
|
||||||
)
|
|
||||||
|
|
||||||
const TAR = "tar"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Index.MergeCommands(ice.Commands{
|
|
||||||
TAR: {Name: "tar file path auto", Help: "打包", Actions: ice.Actions{
|
|
||||||
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if len(arg) == 1 {
|
|
||||||
arg = append(arg, arg[0])
|
|
||||||
}
|
|
||||||
if !strings.HasSuffix(arg[0], ".tar.gz") {
|
|
||||||
arg[0] += ".tar.gz"
|
|
||||||
}
|
|
||||||
m.Cmd("cli.system", "tar", "zcvf", arg)
|
|
||||||
m.Echo(arg[0])
|
|
||||||
}},
|
|
||||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd("cli.system", "tar", "xvf", arg)
|
|
||||||
m.Echo(arg[0])
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Option("cmd_dir", m.Option(DIR_ROOT))
|
|
||||||
m.Cmdy("cli.system", "tar", "zcvf", arg)
|
|
||||||
return
|
|
||||||
|
|
||||||
file, _, err := CreateFile(m, arg[0])
|
|
||||||
m.Assert(err)
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
var out io.WriteCloser = file
|
|
||||||
if strings.HasSuffix(arg[0], ".gz") {
|
|
||||||
out = gzip.NewWriter(out)
|
|
||||||
defer out.Close()
|
|
||||||
}
|
|
||||||
t := tar.NewWriter(out)
|
|
||||||
defer t.Close()
|
|
||||||
|
|
||||||
dir_root := m.Option(DIR_ROOT)
|
|
||||||
var count, total int64
|
|
||||||
for _, k := range arg[1:] {
|
|
||||||
m.Option(DIR_TYPE, TYPE_CAT)
|
|
||||||
m.Option(DIR_DEEP, ice.TRUE)
|
|
||||||
m.Cmdy(DIR, k, func(f os.FileInfo, p string) {
|
|
||||||
total += f.Size()
|
|
||||||
|
|
||||||
header, err := tar.FileInfoHeader(f, p)
|
|
||||||
if m.Warn(err != nil, err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
header.Name = strings.TrimPrefix(p, dir_root+ice.PS)
|
|
||||||
if err = t.WriteHeader(header); m.Warn(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
file, err := OpenFile(m, p)
|
|
||||||
if m.Warn(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
if _, err = io.Copy(t, file); m.Warn(err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
count++
|
|
||||||
})
|
|
||||||
}
|
|
||||||
m.StatusTimeCountTotal(kit.FmtSize(total))
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
}
|
|
@ -8,25 +8,25 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _trash_create(m *ice.Message, name string) {
|
func _trash_create(m *ice.Message, from string) {
|
||||||
if m.Warn(name == "", ice.ErrNotValid, name) {
|
if m.Warn(from == "", ice.ErrNotValid, FROM) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s, e := StatFile(m, name)
|
s, e := StatFile(m, from)
|
||||||
if m.Warn(e, ice.ErrNotFound, name) {
|
if m.Warn(e, ice.ErrNotFound, from) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p := path.Join(ice.VAR_TRASH, path.Base(name))
|
p := path.Join(ice.VAR_TRASH, path.Base(from))
|
||||||
if !s.IsDir() {
|
if !s.IsDir() {
|
||||||
if f, e := OpenFile(m, name); m.Assert(e) {
|
if f, e := OpenFile(m, from); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
p = path.Join(ice.VAR_TRASH, kit.HashsPath(f))
|
p = path.Join(ice.VAR_TRASH, kit.HashsPath(f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MkdirAll(m, path.Dir(p))
|
MkdirAll(m, path.Dir(p))
|
||||||
if RemoveAll(m, p); !m.Warn(Rename(m, name, p)) {
|
if RemoveAll(m, p); !m.Warn(Rename(m, from, p)) {
|
||||||
mdb.HashCreate(m, FROM, name, FILE, p)
|
mdb.HashCreate(m, FROM, from, FILE, p)
|
||||||
|
m.Result(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,32 +35,22 @@ const TRASH = "trash"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TRASH: {Name: "trash hash auto prunes", Help: "回收站", Actions: ice.MergeActions(ice.Actions{
|
TRASH: {Name: "trash hash auto prunes", Help: "回收站", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.REVERT: {Name: "revert", Help: "恢复", Hand: func(m *ice.Message, arg ...string) {
|
mdb.REVERT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
Rename(m, m.Option(FILE), m.Option(FROM))
|
Rename(m, m.Option(FILE), m.Option(FROM))
|
||||||
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
||||||
m.ProcessRefresh()
|
m.ProcessRefresh()
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create path", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create from", Hand: func(m *ice.Message, arg ...string) {
|
||||||
p := path.Join(ice.VAR_TRASH, path.Base(m.Option(PATH)))
|
_trash_create(m, m.Option(FROM))
|
||||||
RemoveAll(m, p)
|
|
||||||
if MkdirAll(m, path.Dir(p)); !m.Warn(Rename(m, m.Option(PATH), p)) {
|
|
||||||
mdb.HashCreate(m, FROM, m.Option(PATH), FILE, p)
|
|
||||||
m.ProcessRefresh()
|
|
||||||
m.Echo(p)
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
Remove(m, m.Option(FILE))
|
Remove(m, m.Option(FILE))
|
||||||
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
||||||
}},
|
}},
|
||||||
mdb.PRUNES: {Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
|
mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashPrunes(m, func(value ice.Map) bool {
|
mdb.HashPrunes(m, nil).Tables(func(value ice.Maps) { Remove(m, value[FILE]) })
|
||||||
return true
|
|
||||||
}).Tables(func(value ice.Maps) {
|
|
||||||
Remove(m, value[FILE])
|
|
||||||
})
|
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, FROM, mdb.FIELD, "time,hash,file,from")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, FROM, mdb.FIELD, "time,hash,from,file")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if mdb.HashSelect(m, arg...); len(arg) == 0 || !ExistsFile(m, arg[0]) {
|
if mdb.HashSelect(m, arg...); len(arg) == 0 || !ExistsFile(m, arg[0]) {
|
||||||
m.PushAction(mdb.REVERT, mdb.REMOVE)
|
m.PushAction(mdb.REVERT, mdb.REMOVE)
|
||||||
return
|
return
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
chapter "ssh"
|
|
||||||
|
|
||||||
field "脚本" source
|
|
||||||
field "模块" target
|
|
||||||
field "提示" prompt
|
|
||||||
field "输出" printf
|
|
||||||
field "屏显" screen
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
|||||||
chapter "tcp"
|
|
||||||
|
|
||||||
field "主机" host
|
|
||||||
field "端口" port
|
|
||||||
field "客户端" client
|
|
||||||
field "服务器" server
|
|
@ -1,16 +0,0 @@
|
|||||||
chapter "web"
|
|
||||||
label "web" `
|
|
||||||
share serve space dream
|
|
||||||
route spide cache story
|
|
||||||
`
|
|
||||||
|
|
||||||
field "蜘蛛侠" web.spide
|
|
||||||
field "缓存池" web.cache
|
|
||||||
field "故事会" web.story
|
|
||||||
field "路由器" web.route
|
|
||||||
|
|
||||||
field "共享链" web.share
|
|
||||||
field "服务器" web.serve
|
|
||||||
field "空间站" web.space
|
|
||||||
field "梦想家" web.dream
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
chapter "yac"
|
|
@ -37,7 +37,7 @@ func _inner_exec(m *ice.Message, ext, file, dir string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _inner_tags(m *ice.Message, dir string, value string) {
|
func _inner_tags(m *ice.Message, dir string, value string) {
|
||||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, nfs.GREP, "^"+value+"\\>", nfs.TAGS, kit.Dict(cli.CMD_DIR, dir)), ice.NL) {
|
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, cli.GREP, "^"+value+"\\>", nfs.TAGS, kit.Dict(cli.CMD_DIR, dir)), ice.NL) {
|
||||||
if strings.HasPrefix(l, "!_") {
|
if strings.HasPrefix(l, "!_") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -119,8 +119,8 @@ func init() {
|
|||||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }},
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }},
|
||||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }},
|
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }},
|
||||||
|
|
||||||
nfs.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
cli.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(nfs.GREP, arg[0], m.Option(nfs.PATH)).StatusTimeCount(mdb.INDEX, 0)
|
m.Cmdy(cli.GREP, arg[0], m.Option(nfs.PATH)).StatusTimeCount(mdb.INDEX, 0)
|
||||||
}},
|
}},
|
||||||
nfs.TAGS: {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) {
|
nfs.TAGS: {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if _inner_tags(m, m.Option(nfs.PATH), arg[0]); m.Length() == 0 {
|
if _inner_tags(m, m.Option(nfs.PATH), arg[0]); m.Length() == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user