mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt some
This commit is contained in:
parent
0499edfc47
commit
2fe1f52608
@ -133,7 +133,6 @@ func ZoneAction(fields ...string) map[string]*ice.Action {
|
||||
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
arg[0] = strings.TrimPrefix(arg[0], "extra.")
|
||||
arg[0] = kit.Select(arg[0], m.Config(kit.Keys(kit.MDB_ALIAS, arg[0])))
|
||||
m.Debug("what %v", arg[0])
|
||||
switch arg[0] {
|
||||
case ice.POD:
|
||||
m.Cmdy("route")
|
||||
@ -144,7 +143,6 @@ func ZoneAction(fields ...string) map[string]*ice.Action {
|
||||
case ice.ARG:
|
||||
|
||||
case _zone(m):
|
||||
m.Debug("what %v", arg[0])
|
||||
m.Cmdy(INPUTS, m.PrefixKey(), "", HASH, arg)
|
||||
default:
|
||||
m.Cmdy(INPUTS, m.PrefixKey(), "", ZONE, m.Option(_zone(m)), arg)
|
||||
|
@ -4,12 +4,11 @@ import (
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _task_scope(m *ice.Message, tz int, arg ...string) (time.Time, time.Time) {
|
||||
func _plan_scope(m *ice.Message, tz int, arg ...string) (time.Time, time.Time) {
|
||||
begin_time := time.Now()
|
||||
if len(arg) > 1 {
|
||||
begin_time, _ = time.ParseInLocation(ice.MOD_TIME, arg[1], time.Local)
|
||||
@ -45,7 +44,6 @@ func _plan_list(m *ice.Message, begin_time, end_time time.Time) *ice.Message {
|
||||
m.Fields(0, "begin_time,close_time,zone,id,level,status,score,type,name,text,extra")
|
||||
m.Option(kit.Keycb(mdb.SELECT), func(key string, fields []string, value, val map[string]interface{}) {
|
||||
begin, _ := time.ParseInLocation(ice.MOD_TIME, kit.Format(value[BEGIN_TIME]), time.Local)
|
||||
m.Debug("what %v %v", begin_time, begin)
|
||||
if begin_time.After(begin) || begin.After(end_time) {
|
||||
return
|
||||
}
|
||||
@ -76,15 +74,18 @@ func init() {
|
||||
}},
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Cmd(TASK, arg[0], arg[1])
|
||||
args := kit.Simple(kit.Keys(msg.Append("extra.pod"), msg.Append("extra.cmd")), arg[2:])
|
||||
if pod := msg.Append(kit.KeyExtra(ice.POD)); pod != "" {
|
||||
m.Option(ice.POD, pod)
|
||||
}
|
||||
args := kit.Simple(kit.Keys(msg.Append(kit.KeyExtra(ice.CTX)), msg.Append(kit.KeyExtra(ice.CMD))), arg[2:])
|
||||
if !m.PodCmd(args) {
|
||||
m.Cmdy(args)
|
||||
}
|
||||
}},
|
||||
}, TASK, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
begin_time, end_time := _task_scope(m, 8, arg...)
|
||||
}, TASK), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
begin_time, end_time := _plan_scope(m, 8, arg...)
|
||||
_plan_list(m, begin_time, end_time)
|
||||
m.PushPodCmd(PLAN, arg...)
|
||||
m.PushPodCmd(cmd, arg...)
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package team
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -64,16 +62,6 @@ func init() {
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
TASK: {Name: "task zone id auto insert export import", Help: "任务", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
if cli.Inputs(m, arg[0]) {
|
||||
return
|
||||
}
|
||||
if arg[0] == m.Conf(TASK, kit.Keym(kit.MDB_SHORT)) {
|
||||
m.Cmdy(mdb.INPUTS, m.Prefix(TASK), "", mdb.HASH, arg[0], arg[1:])
|
||||
return
|
||||
}
|
||||
m.Cmdy(mdb.INPUTS, m.Prefix(TASK), "", mdb.ZONE, m.Option(kit.MDB_ZONE), strings.TrimPrefix(arg[0], "extra."), arg[1:])
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.HASH, m.OptionSimple(kit.MDB_ZONE))
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.ZONE, m.Option(kit.MDB_ZONE),
|
||||
@ -87,19 +75,11 @@ func init() {
|
||||
mdb.DELETE: {Name: "delete", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_modify(m, STATUS, CANCEL)
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.DELETE, m.Prefix(TASK), "", mdb.HASH, m.OptionSimple(kit.MDB_ZONE))
|
||||
}},
|
||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.OptionFields(kit.MDB_ZONE, "time,id,type,name,text,level,status,score,begin_time,close_time,extra")
|
||||
m.Cmdy(mdb.EXPORT, m.Prefix(TASK), "", mdb.ZONE)
|
||||
m.ProcessRefresh30ms()
|
||||
}},
|
||||
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.OptionFields(kit.MDB_ZONE)
|
||||
m.Cmdy(mdb.IMPORT, m.Prefix(TASK), "", mdb.ZONE)
|
||||
m.ProcessRefresh30ms()
|
||||
}},
|
||||
|
||||
BEGIN: {Name: "begin", Help: "开始", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_modify(m, STATUS, PROCESS)
|
||||
@ -107,7 +87,7 @@ func init() {
|
||||
END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_modify(m, STATUS, FINISH)
|
||||
}},
|
||||
}, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
}, mdb.ZoneAction(), ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if mdb.ZoneSelect(m, arg...); len(arg) == 0 {
|
||||
m.PushAction(mdb.REMOVE)
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user