1
0
mirror of https://shylinux.com/x/icebergs synced 2025-05-01 19:19:24 +08:00
This commit is contained in:
harveyshao 2022-03-30 19:21:31 +08:00
parent 11e5f1ba2c
commit 25edf639ae
7 changed files with 24 additions and 9 deletions

View File

@ -75,7 +75,7 @@ func _list_export(m *ice.Message, prefix, chain, file string) {
head := kit.Split(m.OptionFields())
m.Grows(prefix, chain, "", "", func(index int, val map[string]interface{}) {
if val = kit.GetMeta(val); index == 0 {
if len(head) == 0 || head[0] == "detail" { // 默认表头
if len(head) == 0 || head[0] == ice.CACHE_DETAIL { // 默认表头
for k := range val {
head = append(head, k)
}

View File

@ -205,6 +205,7 @@ const ( // MSG
CACHE_FILTER = "cache.filter"
CACHE_VALUE = "cache.value"
CACHE_FIELD = "cache.field"
CACHE_DETAIL = "detail"
)
const ( // RENDER
RENDER_RAW = "_raw"

View File

@ -112,6 +112,14 @@ func _go_show(m *ice.Message, arg ...string) {
}
}
}
func _sum_show(m *ice.Message, file string) {
m.Cmd(nfs.CAT, file, func(ls []string, line string) {
m.Push("repos", ls[0])
m.Push("version", ls[1])
m.Push("hash", ls[2])
})
m.StatusTimeCount()
}
func _mod_show(m *ice.Message, file string) {
const (
MODULE = "module"
@ -126,7 +134,7 @@ func _mod_show(m *ice.Message, file string) {
m.Cmd(nfs.CAT, file, func(ls []string, line string) {
switch {
case strings.HasPrefix(line, MODULE):
require[ls[1]] = ""
require[ls[1]] = m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags")
replace[ls[1]] = nfs.PWD
case strings.HasPrefix(line, REQUIRE+" ("):
block = REQUIRE
@ -155,6 +163,7 @@ func _mod_show(m *ice.Message, file string) {
m.Push(REPLACE, kit.Select("", replace[k]))
}
m.Sort(REPLACE)
m.StatusTimeCount()
}
const (
@ -183,7 +192,9 @@ func init() {
m.Cmdy(cli.SYSTEM, GO, "doc", strings.TrimSuffix(arg[1], ice.PT+arg[0]), kit.Dict(cli.CMD_DIR, arg[2])).SetAppend()
}},
}, PlugAction())},
SUM: {Name: "sum", Help: "版本", Action: PlugAction()},
SUM: {Name: "sum", Help: "版本", Action: ice.MergeAction(map[string]*ice.Action{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }},
}, PlugAction())},
MOD: {Name: "mod", Help: "模块", Action: ice.MergeAction(map[string]*ice.Action{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
}, PlugAction())},

View File

@ -125,7 +125,10 @@ func init() {
ice.RUN: {Name: "run", Help: "执行"},
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if arg = _name(m, arg); strings.Contains(arg[1], ice.NL) {
arg = append([]string{arg[0], "web.chat.div", "auto.cmd", "split", "opts.text", arg[1]}, arg[2:]...)
arg = kit.Simple(arg[0], "web.chat.div", "auto.cmd", "split", "opts.text", arg[1], arg[2:])
}
if arg[1] == "args" {
arg = kit.Simple("", arg)
}
_field_show(m, arg[0], arg[1], arg[2:]...)
}},

View File

@ -116,7 +116,7 @@ func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Messa
var v interface{}
switch k {
case KEY, HASH:
if key != "" && key != "detail" {
if key != "" && key != CACHE_DETAIL {
v = key
break
}
@ -133,7 +133,7 @@ func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Messa
// 追加数据
switch v := kit.Format(v); key {
case "detail":
case CACHE_DETAIL:
m.Add(MSG_APPEND, KEY, k)
m.Add(MSG_APPEND, VALUE, v)
default:

View File

@ -85,7 +85,7 @@ func (m *Message) Split(str string, arg ...string) *Message { // field sp nl
}
func (m *Message) FieldsIsDetail() bool {
if m.OptionFields() == "detail" {
if m.OptionFields() == CACHE_DETAIL {
return true
}
if len(m.meta[MSG_APPEND]) == 2 && m.meta[MSG_APPEND][0] == KEY && m.meta[MSG_APPEND][1] == VALUE {
@ -95,7 +95,7 @@ func (m *Message) FieldsIsDetail() bool {
}
func (m *Message) PushDetail(value interface{}, arg ...interface{}) *Message {
return m.Push("detail", value, arg...)
return m.Push(CACHE_DETAIL, value, arg...)
}
func (m *Message) IsErr(arg ...string) bool {
return len(arg) > 0 && m.Result(1) == arg[0] || m.Result(0) == ErrWarn

View File

@ -81,7 +81,7 @@ func (m *Message) OptionTemplate() string {
}
func (m *Message) Fields(length int, fields ...string) string {
return m.Option(MSG_FIELDS, kit.Select(kit.Select("detail", fields, length), m.Option(MSG_FIELDS)))
return m.Option(MSG_FIELDS, kit.Select(kit.Select(CACHE_DETAIL, fields, length), m.Option(MSG_FIELDS)))
}
func (m *Message) Upload(dir string) {
up := kit.Simple(m.Optionv(MSG_UPLOAD))