mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt some
This commit is contained in:
parent
f32cff5473
commit
9b18b12f77
@ -179,11 +179,11 @@ const HASH = "hash"
|
||||
|
||||
func HashAction(args ...Any) ice.Actions {
|
||||
return ice.Actions{ice.CTX_INIT: AutoConfig(args...), ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { HashSelectClose(m) }},
|
||||
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { HashInputs(m, arg) }},
|
||||
INPUTS: {Hand: func(m *ice.Message, arg ...string) { HashInputs(m, arg) }},
|
||||
CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) { HashCreate(m, arg) }},
|
||||
REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { HashRemove(m, arg) }},
|
||||
MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { HashModify(m, arg) }},
|
||||
SELECT: {Name: "select", Help: "列表", Hand: func(m *ice.Message, arg ...string) { HashSelect(m, arg...) }},
|
||||
MODIFY: {Hand: func(m *ice.Message, arg ...string) { HashModify(m, arg) }},
|
||||
SELECT: {Hand: func(m *ice.Message, arg ...string) { HashSelect(m, arg...) }},
|
||||
PRUNES: {Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) { HashPrunes(m, nil) }},
|
||||
EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) { HashExport(m, arg) }},
|
||||
IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) { HashImport(m, arg) }},
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -14,8 +15,7 @@ const EPIC = "epic"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
EPIC: {Name: "epic hash list create export import", Help: "史记", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.CREATE: {Name: "create time@date zone name"},
|
||||
mdb.MODIFY: {Name: "modify hash time@date zone name"},
|
||||
mdb.CREATE: {Name: "create time@date zone name"}, mdb.MODIFY: {Name: "modify hash time@date zone name"},
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name")), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
|
||||
if span := kit.Time(m.Time()) - kit.Time(value[mdb.TIME]); span > 0 {
|
||||
@ -27,8 +27,8 @@ func init() {
|
||||
-int(time.Duration(span)/time.Hour/24)+1, kit.Split(value[mdb.TIME])[0],
|
||||
))
|
||||
}
|
||||
})
|
||||
m.Sort(mdb.TIME).PushAction(mdb.MODIFY, mdb.REMOVE)
|
||||
}).Sort(mdb.TIME).PushAction(mdb.MODIFY, mdb.REMOVE)
|
||||
web.PushPodCmd(m, "", arg...)
|
||||
ctx.DisplayTableCard(m)
|
||||
}},
|
||||
})
|
||||
|
@ -43,10 +43,9 @@ func _plan_list(m *ice.Message, begin_time, end_time time.Time) *ice.Message {
|
||||
m.OptionFields("begin_time,close_time,zone,id,level,status,score,type,name,text,pod,extra")
|
||||
m.Cmd(mdb.SELECT, m.Prefix(TASK), "", mdb.ZONE, mdb.FOREACH, func(key string, fields []string, value, val ice.Map) {
|
||||
begin, _ := time.ParseInLocation(ice.MOD_TIME, kit.Format(value[BEGIN_TIME]), time.Local)
|
||||
if begin_time.After(begin) || begin.After(end_time) {
|
||||
return
|
||||
if begin.After(begin_time) && end_time.After(begin) {
|
||||
m.Push(key, value, fields, val).PushButton(_task_action(m, value[STATUS], mdb.PLUGIN))
|
||||
}
|
||||
m.Push(key, value, fields, val).PushButton(_task_action(m, value[STATUS], mdb.PLUGIN))
|
||||
})
|
||||
return m
|
||||
}
|
||||
@ -65,9 +64,6 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }},
|
||||
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(TASK, mdb.INSERT, arg)
|
||||
}},
|
||||
mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(TASK, mdb.MODIFY, arg)
|
||||
}},
|
||||
@ -77,18 +73,12 @@ func init() {
|
||||
return
|
||||
}
|
||||
if cmd := m.CmdAppend(TASK, kit.Slice(arg, 0, 2), ctx.INDEX); cmd != "" {
|
||||
m.Cmdy(m.CmdAppend(TASK, arg[0], arg[1], ctx.INDEX), arg[2:])
|
||||
m.Cmdy(cmd, arg[2:])
|
||||
} else if aaa.Right(m, arg) {
|
||||
m.Cmdy(arg)
|
||||
}
|
||||
}},
|
||||
mdb.EXPORT: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.EXPORT) }},
|
||||
mdb.IMPORT: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.IMPORT) }},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
||||
m.Cmdy(TASK, arg)
|
||||
return
|
||||
}
|
||||
}, TASK, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
begin_time, end_time := _plan_scope(m, 8, kit.Slice(arg, 0, 2)...)
|
||||
_plan_list(m, begin_time, end_time)
|
||||
web.PushPodCmd(m, "", arg...)
|
||||
|
@ -58,6 +58,16 @@ const TASK = "task"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
TASK: {Name: "task zone id auto insert export import", Help: "任务", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case LEVEL, SCORE:
|
||||
m.Push(arg[0], "1", "2", "3", "4", "5")
|
||||
case mdb.TYPE:
|
||||
m.Push(arg[0], ONCE, STEP, WEEK)
|
||||
default:
|
||||
mdb.HashInputs(m, arg)
|
||||
}
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.ZoneInsert(m, arg[:2], BEGIN_TIME, m.Time(), STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg[2:])
|
||||
}},
|
||||
|
@ -2,10 +2,10 @@ package team
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
)
|
||||
|
||||
const TODO = "todo"
|
||||
@ -14,7 +14,6 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
TODO: {Name: "todo hash list create export import", Help: "待办", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { mdb.HashInputs(m, arg).Cmdy(TASK, mdb.INPUTS, arg) }},
|
||||
mdb.CREATE: {Name: "create zone name text"},
|
||||
cli.START: {Name: "start type=once,step,week", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(TASK, mdb.INSERT, m.OptionSimple("zone,type,name,text"))
|
||||
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
||||
|
14
misc.go
14
misc.go
@ -337,7 +337,19 @@ func MergeActions(list ...Any) Actions {
|
||||
case string:
|
||||
base[CTX_INIT] = &Action{Hand: func(m *Message, arg ...string) {
|
||||
m.Search(from, func(p *Context, s *Context, key string, cmd *Command) {
|
||||
MergeActions(base, cmd.Actions)
|
||||
for k, v := range cmd.Actions {
|
||||
func(k string) {
|
||||
if h, ok := base[k]; !ok {
|
||||
base[k] = &Action{Name: v.Name, Help: v.Help, Hand: func(m *Message, arg ...string) {
|
||||
m.Cmdy(from, k, arg)
|
||||
}}
|
||||
} else if h.Hand == nil {
|
||||
h.Hand = func(m *Message, arg ...string) {
|
||||
m.Cmdy(from, k, arg)
|
||||
}
|
||||
}
|
||||
} (k)
|
||||
}
|
||||
m.target.Merge(m.target)
|
||||
})
|
||||
}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user