forked from x/icebergs
opt some
This commit is contained in:
parent
1aec5bd434
commit
f32cff5473
@ -153,7 +153,7 @@ const (
|
|||||||
const ZONE = "zone"
|
const ZONE = "zone"
|
||||||
|
|
||||||
func ZoneAction(args ...ice.Any) ice.Actions {
|
func ZoneAction(args ...ice.Any) ice.Actions {
|
||||||
return ice.Actions{ice.CTX_INIT: AutoConfig(args...),
|
return ice.Actions{ice.CTX_INIT: AutoConfig(append([]ice.Any{SHORT, ZONE}, args)...),
|
||||||
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { ZoneInputs(m, arg) }},
|
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { ZoneInputs(m, arg) }},
|
||||||
CREATE: {Name: "create zone", Help: "创建", Hand: func(m *ice.Message, arg ...string) { ZoneCreate(m, arg) }},
|
CREATE: {Name: "create zone", Help: "创建", Hand: func(m *ice.Message, arg ...string) { ZoneCreate(m, arg) }},
|
||||||
REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { ZoneRemove(m, arg) }},
|
REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { ZoneRemove(m, arg) }},
|
||||||
|
@ -111,7 +111,7 @@ func PushPodCmd(m *ice.Message, cmd string, arg ...string) {
|
|||||||
if value[mdb.NAME] == ice.Info.HostName {
|
if value[mdb.NAME] == ice.Info.HostName {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
m.Cmd(SPACE, value[mdb.NAME], m.Prefix(cmd), arg).Table(func(index int, val ice.Maps, head []string) {
|
m.Cmd(SPACE, value[mdb.NAME], kit.Select(m.PrefixKey(), cmd), arg).Table(func(index int, val ice.Maps, head []string) {
|
||||||
val[ice.POD] = kit.Keys(value[mdb.NAME], val[ice.POD])
|
val[ice.POD] = kit.Keys(value[mdb.NAME], val[ice.POD])
|
||||||
m.Push("", val, head)
|
m.Push("", val, head)
|
||||||
})
|
})
|
||||||
|
@ -14,13 +14,13 @@ const EPIC = "epic"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
EPIC: {Name: "epic hash list create export import", Help: "史记", Actions: ice.MergeActions(ice.Actions{
|
EPIC: {Name: "epic hash list create export import", Help: "史记", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create time@date type name", Help: "创建"},
|
mdb.CREATE: {Name: "create time@date zone name"},
|
||||||
mdb.MODIFY: {Name: "modify hash time@date type name", Help: "编辑"},
|
mdb.MODIFY: {Name: "modify hash time@date zone name"},
|
||||||
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashSelect(m, arg...).SetAppend(mdb.TEXT).Tables(func(value ice.Maps) {
|
mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
|
||||||
if span := kit.Time(m.Time()) - kit.Time(value[mdb.TIME]); span > 0 {
|
if span := kit.Time(m.Time()) - kit.Time(value[mdb.TIME]); span > 0 {
|
||||||
m.Push(mdb.TEXT, kit.Format(`已经 <span style="font-size:24px;color:red">%v</span> 天<br>距 %s<br>`,
|
m.Push(mdb.TEXT, kit.Format(`已经 <span style="font-size:24px;color:red">%v</span> 天<br>距 %s<br>`,
|
||||||
int(time.Duration(span)/time.Hour/24)+1, kit.Split(value[mdb.TIME])[0],
|
int(time.Duration(span)/time.Hour/24), kit.Split(value[mdb.TIME])[0],
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
m.Push(mdb.TEXT, kit.Format(`还有 <span style="font-size:24px;color:green">%v</span> 天<br>距 %s<br>`,
|
m.Push(mdb.TEXT, kit.Format(`还有 <span style="font-size:24px;color:green">%v</span> 天<br>距 %s<br>`,
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -64,19 +65,25 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Actions: ice.MergeActions(ice.Actions{
|
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.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", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
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)
|
m.Cmdy(TASK, mdb.INSERT, arg)
|
||||||
}},
|
}},
|
||||||
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }},
|
mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.EXPORT: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.EXPORT) }},
|
m.Cmdy(TASK, mdb.MODIFY, arg)
|
||||||
mdb.IMPORT: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.IMPORT) }},
|
}},
|
||||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
ice.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(ice.POD, m.Option("task.pod"))
|
m.Option(ice.POD, m.Option("task.pod"))
|
||||||
if m.Option("task.pod", ""); ctx.PodCmd(m, m.PrefixKey(), ice.RUN, arg) {
|
if m.Option("task.pod", ""); ctx.PodCmd(m, m.PrefixKey(), ice.RUN, arg) {
|
||||||
return
|
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(m.CmdAppend(TASK, arg[0], arg[1], ctx.INDEX), 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) {
|
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
||||||
m.Cmdy(TASK, arg)
|
m.Cmdy(TASK, arg)
|
||||||
@ -84,7 +91,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
begin_time, end_time := _plan_scope(m, 8, kit.Slice(arg, 0, 2)...)
|
begin_time, end_time := _plan_scope(m, 8, kit.Slice(arg, 0, 2)...)
|
||||||
_plan_list(m, begin_time, end_time)
|
_plan_list(m, begin_time, end_time)
|
||||||
web.PushPodCmd(m, m.CommandKey(), arg...)
|
web.PushPodCmd(m, "", arg...)
|
||||||
|
ctx.Toolkit(m, TODO, TASK, EPIC)
|
||||||
ctx.DisplayLocal(m, "")
|
ctx.DisplayLocal(m, "")
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -58,14 +58,14 @@ const TASK = "task"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TASK: {Name: "task zone id auto insert export import", Help: "任务", Actions: ice.MergeActions(ice.Actions{
|
TASK: {Name: "task zone id auto insert export import", Help: "任务", Actions: ice.MergeActions(ice.Actions{
|
||||||
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) {
|
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:])
|
mdb.ZoneInsert(m, arg[:2], BEGIN_TIME, m.Time(), STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg[2:])
|
||||||
}},
|
}},
|
||||||
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, arg[0], arg[1], arg[2:]...) }},
|
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, arg[0], arg[1], arg[2:]...) }},
|
||||||
CANCEL: {Name: "cancal", Help: "取消", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, CANCEL) }},
|
CANCEL: {Name: "cancal", Help: "取消", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, CANCEL) }},
|
||||||
BEGIN: {Name: "begin", Help: "开始", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, PROCESS) }},
|
BEGIN: {Name: "begin", Help: "开始", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, PROCESS) }},
|
||||||
END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }},
|
END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }},
|
||||||
}, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "begin_time,close_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.ZoneAction(mdb.FIELD, "begin_time,close_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if mdb.ZoneSelect(m, arg...); len(arg) > 0 && arg[0] != "" {
|
if mdb.ZoneSelect(m, arg...); len(arg) > 0 && arg[0] != "" {
|
||||||
status := map[string]int{}
|
status := map[string]int{}
|
||||||
m.Tables(func(value ice.Maps) {
|
m.Tables(func(value ice.Maps) {
|
||||||
|
@ -13,17 +13,15 @@ const TODO = "todo"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TODO: {Name: "todo hash list create export import", Help: "待办", Actions: ice.MergeActions(ice.Actions{
|
TODO: {Name: "todo hash list create export import", Help: "待办", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { mdb.HashInputs(m, arg).Cmdy(TASK, mdb.INPUTS, arg) }},
|
||||||
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) {
|
||||||
mdb.CREATE: {Name: "create zone name text", Help: "创建"},
|
|
||||||
cli.START: {Name: "start type=once,step,week", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd(TASK, mdb.INSERT, m.OptionSimple("zone,type,name,text"))
|
m.Cmd(TASK, mdb.INSERT, m.OptionSimple("zone,type,name,text"))
|
||||||
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashSelect(m, arg...).PushAction(cli.START, mdb.REMOVE)
|
mdb.HashSelect(m, arg...).PushAction(cli.START, mdb.REMOVE)
|
||||||
web.PushPodCmd(m, m.CommandKey(), arg...)
|
web.PushPodCmd(m, "", arg...)
|
||||||
ctx.DisplayTableCard(m)
|
ctx.DisplayTableCard(m)
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
7
type.go
7
type.go
@ -535,9 +535,10 @@ func (m *Message) Commands(key string) *Command {
|
|||||||
func (m *Message) Actions(key string) *Action {
|
func (m *Message) Actions(key string) *Action {
|
||||||
return m._cmd.Actions[key]
|
return m._cmd.Actions[key]
|
||||||
}
|
}
|
||||||
func (m *Message) CmdAppend(arg ...string) string {
|
func (m *Message) CmdAppend(arg ...Any) string {
|
||||||
field := kit.Slice(arg, -1)[0]
|
args := kit.Simple(arg...)
|
||||||
return m._command(kit.Slice(arg, 0, -1), OptionFields(field)).Append(field)
|
field := kit.Slice(args, -1)[0]
|
||||||
|
return m._command(kit.Slice(args, 0, -1), OptionFields(field)).Append(field)
|
||||||
}
|
}
|
||||||
func (m *Message) CmdMap(arg ...string) map[string]map[string]string {
|
func (m *Message) CmdMap(arg ...string) map[string]map[string]string {
|
||||||
field, list := kit.Slice(arg, -1)[0], map[string]map[string]string{}
|
field, list := kit.Slice(arg, -1)[0], map[string]map[string]string{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user