1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-27 17:58:29 +08:00
This commit is contained in:
harveyshao 2022-07-09 20:13:21 +08:00
parent 0f848feb53
commit 34ffc9bf73
195 changed files with 714 additions and 682 deletions

View File

@ -91,10 +91,10 @@ const (
const ROLE = "role"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
ROLE: {Name: ROLE, Help: "角色", Value: kit.Data(mdb.SHORT, mdb.NAME)},
}, Commands: map[string]*ice.Command{
ROLE: {Name: "role role auto insert", Help: "角色", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
ROLE: {Name: "role role auto insert", Help: "角色", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Rich(ROLE, nil, kit.Dict(mdb.NAME, TECH, BLACK, kit.Dict(), WHITE, kit.Dict()))
m.Rich(ROLE, nil, kit.Dict(mdb.NAME, VOID, WHITE, kit.Dict(), BLACK, kit.Dict()))

View File

@ -70,12 +70,12 @@ const (
const SESS = "sess"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SESS: {Name: SESS, Help: "会话", Value: kit.Data(
mdb.SHORT, "uniq", mdb.FIELD, "time,hash,userrole,username,usernick,ip,ua", mdb.EXPIRE, "720h",
)},
}, Commands: map[string]*ice.Command{
SESS: {Name: "sess hash auto prunes", Help: "会话", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
SESS: {Name: "sess hash auto prunes", Help: "会话", Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create username", Help: "创建"},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...)

View File

@ -53,12 +53,12 @@ const (
const TOTP = "totp"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
TOTP: {Name: TOTP, Help: "令牌", Value: kit.Data(
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,secret,period,number", mdb.LINK, "otpauth://totp/%s?secret=%s",
)},
}, Commands: map[string]*ice.Command{
TOTP: {Name: "totp name auto create", Help: "令牌", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
TOTP: {Name: "totp name auto create", Help: "令牌", Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create name=hi secret period=30 number=6", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
if m.Option(SECRET) == "" { // 创建密钥
m.Option(SECRET, _totp_gen(kit.Int64(m.Option(PERIOD))))
@ -67,7 +67,7 @@ func init() {
m.Cmd(mdb.INSERT, TOTP, "", mdb.HASH, m.OptionSimple(mdb.NAME, SECRET, PERIOD, NUMBER))
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m.Spawn(), arg...).Tables(func(value map[string]string) {
mdb.HashSelect(m.Spawn(), arg...).Tables(func(value ice.Maps) {
if len(arg) > 0 {
m.OptionFields(mdb.DETAIL)
}

View File

@ -114,12 +114,12 @@ const (
const USER = "user"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
USER: {Name: USER, Help: "用户", Value: kit.Data(
mdb.SHORT, USERNAME, mdb.FIELD, "time,userrole,username,usernick,userzone",
)},
}, Commands: map[string]*ice.Command{
USER: {Name: "user username auto create", Help: "用户", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
USER: {Name: "user username auto create", Help: "用户", Actions: ice.MergeAction(ice.Actions{
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
if arg[0] == USER {
_user_search(m, arg[1], kit.Select("", arg, 2))

View File

@ -101,12 +101,12 @@ const (
const DAEMON = "daemon"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
DAEMON: {Name: DAEMON, Help: "守护进程", Value: kit.Data(
nfs.PATH, ice.USR_LOCAL_DAEMON, mdb.FIELD, "time,hash,status,pid,cmd,dir,env",
)},
}, Commands: map[string]*ice.Command{
DAEMON: {Name: "daemon hash auto start prunes", Help: "守护进程", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
DAEMON: {Name: "daemon hash auto start prunes", Help: "守护进程", Actions: ice.MergeAction(ice.Actions{
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.PRUNES, DAEMON, "", mdb.HASH, mdb.CACHE_CLEAR_ON_EXIT, ice.TRUE)
}},
@ -125,7 +125,7 @@ func init() {
}},
STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
m.OptionFields(m.Config(mdb.FIELD))
m.Cmd(mdb.SELECT, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH)).Table(func(index int, value map[string]string, head []string) {
m.Cmd(mdb.SELECT, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH)).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(mdb.MODIFY, DAEMON, "", mdb.HASH, m.OptionSimple(mdb.HASH), STATUS, STOP)
m.Cmdy(SYSTEM, KILL, value[PID])
})
@ -134,7 +134,7 @@ func init() {
}
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Set(ctx.ACTION).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m, arg...).Set(ctx.ACTION).Table(func(index int, value ice.Maps, head []string) {
switch value[STATUS] {
case START:
m.PushButton(RESTART, STOP)

View File

@ -26,8 +26,8 @@ const FOREVER = "forever"
func init() {
const SERVE = "serve"
const RESTART = "restart"
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
FOREVER: {Name: "forever auto", Help: "启动", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
FOREVER: {Name: "forever auto", Help: "启动", Actions: ice.Actions{
RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) {
_forever_kill(m, "INT")
}},

View File

@ -28,8 +28,8 @@ const (
const MIRRORS = "mirrors"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
MIRRORS: {Name: "mirrors cli auto", Help: "软件镜像", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
MIRRORS: {Name: "mirrors cli auto", Help: "软件镜像", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Go(func() {
m.Sleep("1s")

View File

@ -129,8 +129,8 @@ const (
const QRCODE = "qrcode"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
QRCODE: {Name: "qrcode text@key fg@key bg@key size auto", Help: "二维码", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
QRCODE: {Name: "qrcode text@key fg@key bg@key size auto", Help: "二维码", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
ice.AddRender(ice.RENDER_QRCODE, func(m *ice.Message, cmd string, args ...ice.Any) string {
return m.Cmd(QRCODE, kit.Simple(args...)).Result()

View File

@ -74,7 +74,7 @@ func _runtime_hostinfo(m *ice.Message) {
m.Push("uptime", kit.Split(m.Cmdx(SYSTEM, "uptime"), ice.FS)[0])
}
func _runtime_diskinfo(m *ice.Message) {
m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", ice.SP, ice.NL).Table(func(index int, value map[string]string, head []string) {
m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", ice.SP, ice.NL).Table(func(index int, value ice.Maps, head []string) {
if strings.HasPrefix(value["Filesystem"], "/dev") {
m.Push("", value, head)
}
@ -151,10 +151,10 @@ const (
const RUNTIME = "runtime"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
RUNTIME: {Name: RUNTIME, Help: "运行环境", Value: kit.Dict()},
}, Commands: map[string]*ice.Command{
RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,bootinfo,diskinfo,env,file,route auto", Help: "运行环境", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,bootinfo,diskinfo,env,file,route auto", Help: "运行环境", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(RUNTIME, MAXPROCS, "1")
_runtime_init(m)

View File

@ -147,10 +147,10 @@ const (
const SYSTEM = "system"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SYSTEM: {Name: SYSTEM, Help: "系统命令", Value: kit.Data(mdb.FIELD, "time,id,cmd")},
}, Commands: map[string]*ice.Command{
SYSTEM: {Name: "system cmd run", Help: "系统命令", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
SYSTEM: {Name: "system cmd run", Help: "系统命令", Actions: ice.Actions{
nfs.FIND: {Name: "find", Help: "查找", Hand: func(m *ice.Message, arg ...string) {
m.Echo(_system_find(m, arg[0], arg[1:]...))
}},

View File

@ -72,14 +72,17 @@ func _command_search(m *ice.Message, kind, name, text string) {
})
}
func CmdAction(args ...ice.Any) map[string]*ice.Action {
return map[string]*ice.Action{ice.CTX_INIT: mdb.AutoConfig(args...),
func CmdAction(args ...ice.Any) ice.Actions {
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...),
COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
if !m.PodCmd(COMMAND, arg) {
m.Cmdy(COMMAND, arg)
}
}},
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 3 && arg[1] == "action" && arg[2] == "config" && arg[3] == "reset" {
m.Cmd("config", "reset", arg[0])
}
if m.Right(arg) && !m.PodCmd(arg) {
m.Cmdy(arg)
}
@ -99,8 +102,8 @@ const (
const COMMAND = "command"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Prefix(COMMAND))
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, COMMAND)

View File

@ -99,10 +99,10 @@ const (
const CONFIG = "config"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
CONFIG: {Name: CONFIG, Help: "配置", Value: kit.Data(nfs.PATH, ice.VAR_CONF)},
}, Commands: map[string]*ice.Command{
CONFIG: {Name: "config key auto reset", Help: "配置", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
CONFIG: {Name: "config key auto reset", Help: "配置", Actions: ice.Actions{
SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
_config_save(m, arg[0], arg[1:]...)
}},

View File

@ -38,15 +38,15 @@ func Inputs(m *ice.Message, field string) bool {
const CONTEXT = "context"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
CONTEXT: {Name: "context name=web action=context,command,config key auto spide", Help: "模块", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
CONTEXT: {Name: "context name=web action=context,command,config key auto spide", Help: "模块", Actions: ice.MergeAction(ice.Actions{
"spide": {Name: "spide", Help: "架构图", Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 || arg[1] == CONTEXT { // 模块列表
m.Cmdy(CONTEXT, kit.Select(ice.ICE, arg, 0), CONTEXT)
m.Display("/plugin/story/spide.js?prefix=spide", "root", kit.Select(ice.ICE, arg, 0), "split", ice.PT)
} else if index := kit.Keys(arg[1]); strings.HasSuffix(index, arg[2]) { // 命令列表
m.Cmdy(CONTEXT, index, COMMAND).Table(func(i int, value map[string]string, head []string) {
m.Cmdy(CONTEXT, index, COMMAND).Table(func(i int, value ice.Maps, head []string) {
m.Push("file", arg[1])
})

View File

@ -12,7 +12,7 @@ import (
const MESSAGE = "message"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
Index.Merge(&ice.Context{Commands: ice.Commands{
MESSAGE: {Name: "message", Help: "消息", Hand: func(m *ice.Message, arg ...string) {
t := reflect.TypeOf(m)
for i := 0; i < t.NumMethod(); i++ {

View File

@ -11,7 +11,7 @@ func _event_listen(m *ice.Message, event string, cmd string) {
m.Cmdy(mdb.INSERT, EVENT, "", mdb.ZONE, event, ice.CMD, cmd)
}
func _event_action(m *ice.Message, event string, arg ...string) {
mdb.ZoneSelect(m, event).Table(func(index int, value map[string]string, head []string) {
mdb.ZoneSelect(m, event).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(kit.Split(value[ice.CMD]), event, arg).Cost(EVENT, event, ice.ARG, arg)
})
}
@ -19,10 +19,10 @@ func _event_action(m *ice.Message, event string, arg ...string) {
const EVENT = "event"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
EVENT: {Name: EVENT, Help: "事件流", Value: kit.Data(mdb.SHORT, EVENT, mdb.FIELD, "time,id,cmd")},
}, Commands: map[string]*ice.Command{
EVENT: {Name: "event event id auto listen", Help: "事件流", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
EVENT: {Name: "event event id auto listen", Help: "事件流", Actions: ice.MergeAction(ice.Actions{
LISTEN: {Name: "listen event cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
_event_listen(m, m.Option(EVENT), m.Option(ice.CMD))
}},

View File

@ -45,7 +45,7 @@ func (f *Frame) Close(m *ice.Message, arg ...string) bool {
const GDB = "gdb"
var Index = &ice.Context{Name: GDB, Help: "事件模块", Commands: map[string]*ice.Command{
var Index = &ice.Context{Name: GDB, Help: "事件模块", Commands: ice.Commands{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Load(TIMER)
}},

View File

@ -12,10 +12,10 @@ import (
const ROUTINE = "routine"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
ROUTINE: {Name: ROUTINE, Help: "协程池", Value: kit.Data(mdb.SHORT, "time,hash,status,fileline")},
}, Commands: map[string]*ice.Command{
ROUTINE: {Name: "routine hash auto prunes", Help: "协程池", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
ROUTINE: {Name: "routine hash auto prunes", Help: "协程池", Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create fileline status", Help: "创建"},
mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
m.OptionFields(m.Config(mdb.SHORT))

View File

@ -21,7 +21,7 @@ func _signal_listen(m *ice.Message, s int, arg ...string) {
}
}
func _signal_action(m *ice.Message, arg ...string) {
mdb.HashSelect(m.Spawn(), arg...).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(kit.Split(value[ice.CMD]))
})
}
@ -45,12 +45,12 @@ const (
const SIGNAL = "signal"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SIGNAL: {Name: SIGNAL, Help: "信号器", Value: kit.Data(
mdb.SHORT, SIGNAL, mdb.FIELD, "time,signal,name,cmd", nfs.PATH, path.Join(ice.VAR_RUN, "ice.pid"),
)},
}, Commands: map[string]*ice.Command{
SIGNAL: {Name: "signal signal auto listen", Help: "信号器", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
SIGNAL: {Name: "signal signal auto listen", Help: "信号器", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
if log.LogDisable {
return // 禁用日志

View File

@ -41,12 +41,12 @@ const (
const TIMER = "timer"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
TIMER: {Name: TIMER, Help: "定时器", Value: kit.Data(
mdb.FIELD, "time,hash,delay,interval,order,next,cmd", TICK, "1s",
)},
}, Commands: map[string]*ice.Command{
TIMER: {Name: "timer hash id auto create action prunes", Help: "定时器", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
TIMER: {Name: "timer hash id auto create action prunes", Help: "定时器", Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create delay=10ms interval=10s order=3 cmd=runtime", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.INSERT, TIMER, "", mdb.HASH, DELAY, "10ms", INTERVAL, "10m", ORDER, 1, NEXT, m.Time(m.Option(DELAY)), arg)
}},

View File

@ -385,10 +385,10 @@ const (
const MATRIX = "matrix"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data()},
}, Commands: map[string]*ice.Command{
MATRIX: {Name: "matrix hash npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
MATRIX: {Name: "matrix hash npage text auto", Help: "魔方矩阵", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
// _lex_load(m.Load())
}},

View File

@ -101,9 +101,9 @@ const (
const SPLIT = "split"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SPLIT: {Name: "split", Help: "解析", Value: kit.Data()},
}, Commands: map[string]*ice.Command{
}, Commands: ice.Commands{
SPLIT: {Name: "split path key auto", Help: "解析", Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
m.Cmdy(nfs.DIR, arg)

View File

@ -94,7 +94,7 @@ const (
SHOW = "show"
)
var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: map[string]*ice.Config{
var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: ice.Configs{
FILE: {Name: FILE, Help: "日志文件", Value: kit.Dict(
BENCH, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "bench.log"), mdb.LIST, []string{}),
WATCH, kit.Dict(nfs.PATH, path.Join(ice.VAR_LOG, "watch.log"), mdb.LIST, []string{
@ -122,7 +122,7 @@ var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: map[string]
}),
)},
SHOW: {Name: SHOW, Help: "日志分流", Value: kit.Dict()},
}, Commands: map[string]*ice.Command{
}, Commands: ice.Commands{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
if log.LogDisable {
return // 禁用日志

View File

@ -8,10 +8,10 @@ import (
const ENGINE = "engine"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
ENGINE: {Name: ENGINE, Help: "引擎", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")},
}, Commands: map[string]*ice.Command{
ENGINE: {Name: "engine type name text auto", Help: "引擎", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
ENGINE: {Name: "engine type name text auto", Help: "引擎", Actions: ice.MergeAction(ice.Actions{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))

View File

@ -138,7 +138,7 @@ func _hash_prunes(m *ice.Message, prefix, chain string, arg ...string) {
}
m.Push(key, val, fields)
})
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
_hash_delete(m, prefix, chain, HASH, value[HASH])
})
}
@ -151,22 +151,36 @@ func AutoConfig(args ...ice.Any) *ice.Action {
cs[m.CommandKey()] = &ice.Config{Value: kit.Data(args...)}
m.Load(m.CommandKey())
}
if cs := m.Target().Commands; cs[m.CommandKey()] == nil || cs[m.CommandKey()].Meta[CREATE] != nil {
return
}
inputs := []ice.Any{}
kit.Fetch(kit.Split(m.Config(FIELD)), func(i int, k string) {
switch k {
case TIME, HASH:
case TIME, HASH, ID:
return
}
inputs = append(inputs, k)
})
m.Design(CREATE, "创建", inputs...)
cs := m.Target().Commands
if cs[m.CommandKey()] == nil {
return
}
m.Debug("what %v %v", m.CommandKey(), cs[m.CommandKey()].Actions[INSERT])
if cs[m.CommandKey()].Actions[INSERT] != nil {
if cs[m.CommandKey()].Meta[INSERT] == nil {
m.Design(INSERT, "添加", append([]ice.Any{ZONE}, inputs...)...)
}
m.Debug("what %v %v", m.CommandKey(), cs[m.CommandKey()].Actions[INSERT])
} else if cs[m.CommandKey()].Actions[CREATE] != nil {
if cs[m.CommandKey()].Meta[CREATE] == nil {
m.Design(CREATE, "创建", inputs...)
}
m.Debug("what %v %v", m.CommandKey(), cs[m.CommandKey()].Actions[INSERT])
}
}}
}
func HashAction(args ...ice.Any) map[string]*ice.Action {
func HashAction(args ...ice.Any) ice.Actions {
_key := func(m *ice.Message) string {
if m.Config(HASH) == UNIQ {
return HASH
@ -176,7 +190,7 @@ func HashAction(args ...ice.Any) map[string]*ice.Action {
}
return kit.Select(HASH, m.Config(SHORT))
}
return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...),
return ice.Actions{ice.CTX_INIT: AutoConfig(args...),
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(INPUTS, m.PrefixKey(), "", HASH, arg)
}},
@ -206,7 +220,7 @@ func HashAction(args ...ice.Any) map[string]*ice.Action {
}},
}
}
func HashActionStatus(args ...ice.Any) map[string]*ice.Action {
func HashActionStatus(args ...ice.Any) ice.Actions {
list := HashAction(args...)
list[PRUNES] = &ice.Action{Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
m.OptionFields(m.Config(FIELD))
@ -228,7 +242,7 @@ func HashSelect(m *ice.Message, arg ...string) *ice.Message {
m.StatusTimeCount()
return m
}
func HashPrunes(m *ice.Message, cb func(map[string]string) bool) *ice.Message {
func HashPrunes(m *ice.Message, cb func(ice.Maps) bool) *ice.Message {
_key := func(m *ice.Message) string {
if m.Config(HASH) == UNIQ {
return HASH
@ -236,7 +250,7 @@ func HashPrunes(m *ice.Message, cb func(map[string]string) bool) *ice.Message {
return kit.Select(HASH, m.Config(SHORT))
}
expire := kit.Time(kit.Select(m.Time("-72h"), m.Option(EXPIRE)))
m.Cmd(m.CommandKey()).Table(func(index int, value map[string]string, head []string) {
m.Cmd(m.CommandKey()).Table(func(index int, value ice.Maps, head []string) {
if kit.Time(value[TIME]) > expire {
return
}

View File

@ -133,8 +133,8 @@ func _list_prunes(m *ice.Message, prefix, chain string, arg ...string) {
const LIST = "list"
func ListAction(args ...ice.Any) map[string]*ice.Action {
return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...),
func ListAction(args ...ice.Any) ice.Actions {
return ice.Actions{ice.CTX_INIT: AutoConfig(args...),
INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(INPUTS, m.PrefixKey(), "", LIST, arg)
}},

View File

@ -145,7 +145,7 @@ func NextPageLimit(m *ice.Message, total string, arg ...string) {
const MDB = "mdb"
var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*ice.Command{
var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {}},
INSERT: {Name: "insert key sub type arg...", Help: "添加", Hand: func(m *ice.Message, arg ...string) {

View File

@ -8,10 +8,10 @@ import (
const PLUGIN = "plugin"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
PLUGIN: {Name: PLUGIN, Help: "插件", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")},
}, Commands: map[string]*ice.Command{
PLUGIN: {Name: "plugin type name text auto", Help: "插件", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
PLUGIN: {Name: "plugin type name text auto", Help: "插件", Actions: ice.Actions{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))

View File

@ -8,10 +8,10 @@ import (
const RENDER = "render"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
RENDER: {Name: RENDER, Help: "渲染", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")},
}, Commands: map[string]*ice.Command{
RENDER: {Name: "render type name text auto", Help: "渲染", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
RENDER: {Name: "render type name text auto", Help: "渲染", Actions: ice.Actions{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))

View File

@ -8,10 +8,10 @@ import (
const SEARCH = "search"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SEARCH: {Name: SEARCH, Help: "搜索", Value: kit.Data(SHORT, TYPE, FIELD, "time,type,name,text")},
}, Commands: map[string]*ice.Command{
SEARCH: {Name: "search type name text auto", Help: "搜索", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
SEARCH: {Name: "search type name text auto", Help: "搜索", Actions: ice.Actions{
CREATE: {Name: "create type name text", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Option(NAME, kit.Select(m.Option(TYPE), m.Option(NAME)))
m.Option(TYPE, kit.Ext(m.Option(TYPE)))

View File

@ -41,8 +41,8 @@ func _zone_select(m *ice.Message, prefix, chain, zone string, id string) {
cb(key, value)
case func(ice.Map):
cb(value)
case func(map[string]string):
res := map[string]string{}
case func(ice.Maps):
res := ice.Maps{}
for k, v := range value {
res[k] = kit.Format(v)
}
@ -108,7 +108,7 @@ func _zone_import(m *ice.Message, prefix, chain, file string) {
head, _ := r.Read()
count := 0
list := map[string]string{}
list := ice.Maps{}
zkey := kit.Select(head[0], m.OptionFields())
for {
@ -145,10 +145,10 @@ func _zone_import(m *ice.Message, prefix, chain, file string) {
const ZONE = "zone"
func ZoneAction(args ...ice.Any) map[string]*ice.Action {
func ZoneAction(args ...ice.Any) ice.Actions {
_zone := func(m *ice.Message) string { return kit.Select(ZONE, m.Config(SHORT)) }
return map[string]*ice.Action{ice.CTX_INIT: AutoConfig(args...),
return ice.Actions{ice.CTX_INIT: AutoConfig(args...),
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(ALIAS, arg[0])))
@ -177,7 +177,7 @@ func ZoneAction(args ...ice.Any) map[string]*ice.Action {
REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(DELETE, m.PrefixKey(), "", HASH, m.OptionSimple(_zone(m)), arg)
}},
INSERT: {Name: "insert zone type=go name=hi text=hello", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
INSERT: {Name: "insert", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 {
arg = m.OptionSimple(_zone(m), m.Config(FIELD))
}

View File

@ -167,7 +167,7 @@ const (
const CAT = "cat"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
CAT: {Name: CAT, Help: "文件", Value: kit.Data(
SOURCE, kit.Dict(
HTML, ice.TRUE, CSS, ice.TRUE, JS, ice.TRUE, GO, ice.TRUE, SH, ice.TRUE, CSV, ice.TRUE, JSON, ice.TRUE,
@ -176,8 +176,8 @@ func init() {
"py", ice.TRUE,
),
)},
}, Commands: map[string]*ice.Command{
CAT: {Name: "cat path auto", Help: "文件", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
CAT: {Name: "cat path auto", Help: "文件", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.RENDER, mdb.CREATE, m.CommandKey(), m.PrefixKey())
}},

View File

@ -86,7 +86,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
continue
case nil:
default:
m.Error(true, ice.ErrNotImplement)
m.Error(true, "what: %v: %v", ice.ErrNotImplement, cb)
}
for _, field := range fields {
@ -191,7 +191,7 @@ func _dir_list(m *ice.Message, root string, name string, level int, deep bool, d
}
func _dir_search(m *ice.Message, kind, name string) {
msg := _dir_list(m.Spawn(), PWD, "", 0, true, TYPE_BOTH, nil, kit.Split("time,type,name"))
msg.Table(func(index int, value map[string]string, head []string) {
msg.Table(func(index int, value ice.Maps, head []string) {
if !strings.Contains(value[mdb.NAME], name) {
return
}
@ -235,10 +235,10 @@ const (
const DIR = "dir"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
DIR: {Name: DIR, Help: "目录", Value: kit.Data()},
}, Commands: map[string]*ice.Command{
DIR: {Name: "dir path field... auto upload", Help: "目录", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
DIR: {Name: "dir path field... auto upload", Help: "目录", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.RENDER, mdb.CREATE, m.CommandKey(), m.PrefixKey())
}},

View File

@ -9,7 +9,7 @@ import (
const FIND = "find"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
Index.Merge(&ice.Context{Commands: 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))

View File

@ -5,7 +5,7 @@ import ice "shylinux.com/x/icebergs"
const GREP = "grep"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
Index.Merge(&ice.Context{Commands: ice.Commands{
GREP: {Name: "grep path word auto", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
m.Option("cmd_dir", arg[0])
m.Split(m.Cmdx("cli.system", GREP, "--exclude=.[a-z]*", "--exclude-dir=.[a-z]*", "-rni", arg[1]), "file:line:text", ":")

View File

@ -92,7 +92,7 @@ const COPY = "copy"
const LINK = "link"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
Index.Merge(&ice.Context{Commands: ice.Commands{
DEFS: {Name: "defs file text...", Help: "默认", Hand: func(m *ice.Message, arg ...string) {
_defs_file(m, arg[0], arg[1:]...)
}},

View File

@ -36,12 +36,12 @@ func _tail_count(m *ice.Message, name string) string {
const TAIL = "tail"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
TAIL: {Name: TAIL, Help: "日志流", Value: kit.Data(
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,id,file,text",
)},
}, Commands: map[string]*ice.Command{
TAIL: {Name: "tail name id auto page filter:text create", Help: "日志流", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
TAIL: {Name: "tail name id auto page filter:text create", Help: "日志流", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Richs(TAIL, "", mdb.FOREACH, func(key string, value ice.Map) {
value, _ = kit.GetMeta(value), m.Option(mdb.HASH, key)
@ -66,7 +66,7 @@ func init() {
m.Fields(len(kit.Slice(arg, 0, 2)), "time,name,count,file", m.Config(mdb.FIELD))
m.OptionPage(kit.Slice(arg, 2)...)
mdb.ZoneSelect(m.Spawn(), arg...).Table(func(index int, value map[string]string, head []string) {
mdb.ZoneSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, head []string) {
if strings.Contains(value[mdb.TEXT], m.Option(ice.CACHE_FILTER)) {
m.Push("", value, head)
}

View File

@ -15,8 +15,8 @@ import (
const TAR = "tar"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
TAR: {Name: "tar file path auto", Help: "打包", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: 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])

View File

@ -32,12 +32,12 @@ const (
const TRASH = "trash"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
TRASH: {Name: TRASH, Help: "回收站", Value: kit.Data(
mdb.SHORT, FROM, mdb.FIELD, "time,hash,file,from", PATH, ice.VAR_TRASH,
)},
}, Commands: map[string]*ice.Command{
TRASH: {Name: "trash hash auto prunes", Help: "回收站", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
TRASH: {Name: "trash hash auto prunes", Help: "回收站", Actions: ice.MergeAction(ice.Actions{
mdb.REVERT: {Name: "revert", Help: "恢复", Hand: func(m *ice.Message, arg ...string) {
os.Rename(m.Option(FILE), m.Option(FROM))
m.Cmd(mdb.DELETE, TRASH, "", mdb.HASH, m.OptionSimple(mdb.HASH))
@ -54,7 +54,7 @@ func init() {
m.Cmd(mdb.DELETE, TRASH, "", mdb.HASH, m.OptionSimple(mdb.HASH))
}},
mdb.PRUNES: {Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
mdb.HashPrunes(m, func(value map[string]string) bool {
mdb.HashPrunes(m, func(value ice.Maps) bool {
os.Remove(value[FILE])
return false
})

View File

@ -259,15 +259,15 @@ const (
)
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SOURCE: {Name: SOURCE, Help: "加载脚本", Value: kit.Data()},
PROMPT: {Name: PROMPT, Help: "命令提示", Value: kit.Data(
PS1, []ice.Any{"\033[33;44m", mdb.COUNT, "[", mdb.TIME, "]", "\033[5m", TARGET, "\033[0m", "\033[44m", ">", "\033[0m ", "\033[?25h", "\033[32m"},
PS2, []ice.Any{mdb.COUNT, " ", TARGET, "> "},
)},
}, Commands: map[string]*ice.Command{
}, Commands: ice.Commands{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {}},
SOURCE: {Name: "source file", Help: "脚本解析", Action: ice.MergeAction(map[string]*ice.Action{
SOURCE: {Name: "source file", Help: "脚本解析", Actions: ice.MergeAction(ice.Actions{
"repeat": {Name: "repeat", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(SCREEN, m.Option(mdb.TEXT))
m.ProcessInner()

View File

@ -77,12 +77,12 @@ const (
const CLIENT = "client"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
CLIENT: {Name: CLIENT, Help: "客户端", Value: kit.Data(
mdb.FIELD, "time,hash,status,type,name,host,port,error,nread,nwrite",
)},
}, Commands: map[string]*ice.Command{
CLIENT: {Name: "client hash auto prunes", Help: "客户端", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
CLIENT: {Name: "client hash auto prunes", Help: "客户端", Actions: ice.MergeAction(ice.Actions{
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
m.Richs(CLIENT, "", mdb.FOREACH, func(key string, value ice.Map) {
kit.Value(value, kit.Keym(STATUS), CLOSE)
@ -93,7 +93,7 @@ func init() {
_client_dial(m, arg...)
}},
}, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == OPEN))
})
}},

View File

@ -73,14 +73,14 @@ const (
const HOST = "host"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
HOST: {Name: HOST, Help: "主机", Value: kit.Data(
aaa.BLACK, kit.Data(mdb.SHORT, mdb.TEXT), aaa.WHITE, kit.Data(mdb.SHORT, mdb.TEXT),
)},
}, Commands: map[string]*ice.Command{
HOST: {Name: "host name auto", Help: "主机", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
HOST: {Name: "host name auto", Help: "主机", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(HOST).Table(func(index int, value map[string]string, head []string) {
m.Cmd(HOST).Table(func(index int, value ice.Maps, head []string) {
m.Cmd(HOST, aaa.WHITE, value[aaa.IP])
})
}},

View File

@ -46,10 +46,10 @@ const (
const PORT = "port"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
PORT: {Name: PORT, Help: "端口", Value: kit.Data(BEGIN, 10000, CURRENT, 10000, END, 20000)},
}, Commands: map[string]*ice.Command{
PORT: {Name: "port port path auto", Help: "端口", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
PORT: {Name: "port port path auto", Help: "端口", Actions: ice.Actions{
aaa.RIGHT: {Name: "right", Help: "分配", Hand: func(m *ice.Message, arg ...string) {
m.Echo(_port_right(m, arg...))
}},
@ -62,7 +62,7 @@ func init() {
if len(arg) == 0 {
current := kit.Int(m.Config(BEGIN))
m.Option(nfs.DIR_ROOT, ice.USR_LOCAL_DAEMON)
m.Cmd(nfs.DIR, nfs.PWD, nfs.DIR_CLI_FIELDS).Tables(func(value map[string]string) {
m.Cmd(nfs.DIR, nfs.PWD, nfs.DIR_CLI_FIELDS).Tables(func(value ice.Maps) {
bin := m.Cmd(nfs.DIR, path.Join(value[nfs.PATH], ice.BIN), nfs.DIR_CLI_FIELDS).Append(nfs.PATH)
if bin == "" {
bin = m.Cmd(nfs.DIR, path.Join(value[nfs.PATH], "sbin"), nfs.DIR_CLI_FIELDS).Append(nfs.PATH)

View File

@ -85,12 +85,12 @@ const (
const SERVER = "server"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data(
mdb.FIELD, "time,hash,status,type,name,host,port,error,nconn",
)},
}, Commands: map[string]*ice.Command{
SERVER: {Name: "server hash auto prunes", Help: "服务器", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
SERVER: {Name: "server hash auto prunes", Help: "服务器", Actions: ice.MergeAction(ice.Actions{
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
m.Richs(SERVER, "", mdb.FOREACH, func(key string, value ice.Map) {
kit.Value(value, kit.Keym(STATUS), CLOSE)
@ -101,7 +101,7 @@ func init() {
_server_listen(m, arg...)
}},
}, mdb.HashActionStatus()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
m.PushButton(kit.Select("", mdb.REMOVE, value[STATUS] == CLOSE))
})
}},

View File

@ -46,7 +46,7 @@ func _serve_udp(m *ice.Message, host, port string) {
}
if remote, err := net.ResolveUDPAddr("udp4", kit.Format("%s:%s", msg.Option(tcp.HOST), msg.Option(tcp.PORT))); err == nil {
m.Cmd(BROAD).Table(func(index int, value map[string]string, head []string) {
m.Cmd(BROAD).Table(func(index int, value ice.Maps, head []string) {
m.Debug("broad %v to %v", kit.Format(value), kit.Format(remote))
s.WriteToUDP([]byte(m.Spawn(value).FormatMeta()), remote)
})
@ -69,8 +69,8 @@ func _broad_search(m *ice.Message, kind, name, text string, arg ...string) {
const BROAD = "broad"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
BROAD: {Name: "broad hash auto", Help: "广播", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
BROAD: {Name: "broad hash auto", Help: "广播", Actions: ice.MergeAction(ice.Actions{
SERVE: {Name: "broad port=9020", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
_serve_udp(m, m.Cmd(tcp.HOST).Append("ip"), m.Option(tcp.PORT))
}},

View File

@ -41,7 +41,7 @@ func _cache_save(m *ice.Message, kind, name, text string, arg ...string) { // fi
m.Push(mdb.DATA, h)
}
func _cache_watch(m *ice.Message, key, file string) {
mdb.HashSelect(m.Spawn(), key).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m.Spawn(), key).Table(func(index int, value ice.Maps, head []string) {
if value[nfs.FILE] == "" {
m.Cmdy(nfs.SAVE, file, value[mdb.TEXT])
} else {
@ -135,13 +135,13 @@ const (
const CACHE = "cache"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
CACHE: {Name: CACHE, Help: "缓存池", Value: kit.Data(
mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,size,type,name,text",
mdb.STORE, ice.VAR_DATA, nfs.PATH, ice.VAR_FILE, mdb.FSIZE, "200000",
mdb.LIMIT, "50", mdb.LEAST, "30",
)},
}, Commands: map[string]*ice.Command{
}, Commands: ice.Commands{
"/cache/": {Name: "/cache/", Help: "缓存池", Hand: func(m *ice.Message, arg ...string) {
m.Richs(CACHE, nil, arg[0], func(key string, value ice.Map) {
if kit.Format(value[nfs.FILE]) == "" {
@ -151,7 +151,7 @@ func init() {
}
})
}},
CACHE: {Name: "cache hash auto", Help: "缓存池", Action: ice.MergeAction(map[string]*ice.Action{
CACHE: {Name: "cache hash auto", Help: "缓存池", Actions: ice.MergeAction(ice.Actions{
WATCH: {Name: "watch key file", Help: "释放", Hand: func(m *ice.Message, arg ...string) {
_cache_watch(m, arg[0], arg[1])
}},

View File

@ -15,7 +15,7 @@ import (
)
func _dream_list(m *ice.Message) *ice.Message {
return m.Cmdy(nfs.DIR, m.Config(nfs.PATH), "time,size,name").Table(func(index int, value map[string]string, head []string) {
return m.Cmdy(nfs.DIR, m.Config(nfs.PATH), "time,size,name").Table(func(index int, value ice.Maps, head []string) {
if m.Richs(SPACE, nil, value[mdb.NAME], func(key string, val ice.Map) {
m.Push(mdb.TYPE, val[mdb.TYPE])
m.Push(cli.STATUS, cli.START)
@ -102,8 +102,8 @@ const (
const DREAM = "dream"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
DREAM: {Name: "dream name path auto start", Help: "梦想家", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
DREAM: {Name: "dream name path auto start", Help: "梦想家", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Config("miss", _dream_miss)
}},
@ -143,7 +143,7 @@ func init() {
}, Hand: func(m *ice.Message, arg ...string) {
if start := 0; len(arg) == 0 {
_dream_list(m).SetAppend(mdb.TEXT)
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
if value[cli.STATUS] != cli.START {
m.Push(mdb.TEXT, "")
return
@ -170,7 +170,7 @@ func init() {
m.Option(nfs.DIR_ROOT, path.Join(m.Config(nfs.PATH), arg[0]))
m.Cmdy(nfs.CAT, arg[1:])
}},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
DREAM: {Name: DREAM, Help: "梦想家", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_WORK, "miss", _dream_miss)},
}})
}

View File

@ -19,7 +19,7 @@ func _route_travel(m *ice.Message, route string) {
return // 避免循环
}
m.Cmd(SPACE, val[mdb.NAME], ROUTE).Table(func(index int, value map[string]string, head []string) {
m.Cmd(SPACE, val[mdb.NAME], ROUTE).Table(func(index int, value ice.Maps, head []string) {
m.Push(mdb.TYPE, value[mdb.TYPE])
m.Push(ROUTE, kit.Keys(val[mdb.NAME], value[ROUTE]))
})
@ -32,7 +32,7 @@ func _route_travel(m *ice.Message, route string) {
})
}
func _route_list(m *ice.Message) {
m.Table(func(index int, value map[string]string, field []string) {
m.Table(func(index int, value ice.Maps, field []string) {
m.PushAnchor(value[ROUTE], m.MergePod(value[ROUTE]))
switch value[mdb.TYPE] {
@ -47,7 +47,7 @@ func _route_list(m *ice.Message) {
// 网卡信息
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
m.Cmd(tcp.HOST).Table(func(index int, value map[string]string, head []string) {
m.Cmd(tcp.HOST).Table(func(index int, value ice.Maps, head []string) {
m.Push(mdb.TYPE, MYSELF)
m.Push(ROUTE, ice.Info.NodeName)
m.PushAnchor(value[aaa.IP], kit.Format("%s://%s:%s", u.Scheme, value[aaa.IP], u.Port()))
@ -64,10 +64,10 @@ func _route_list(m *ice.Message) {
const ROUTE = "route"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
ROUTE: {Name: ROUTE, Help: "路由器", Value: kit.Data(mdb.SHORT, ROUTE)},
}, Commands: map[string]*ice.Command{
ROUTE: {Name: "route route ctx cmd auto invite spide", Help: "路由器", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
ROUTE: {Name: "route route ctx cmd auto invite spide", Help: "路由器", Actions: ice.Actions{
aaa.INVITE: {Name: "invite", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(SPACE, m.Option(ROUTE), SPACE, aaa.INVITE, arg)
m.ProcessInner()
@ -106,13 +106,13 @@ func init() {
}
} else if len(arg) == 1 || arg[1] == "" { // 模块列表
m.Cmd(SPACE, arg[0], ctx.CONTEXT, ice.ICE).Table(func(index int, value map[string]string, head []string) {
m.Cmd(SPACE, arg[0], ctx.CONTEXT, ice.ICE).Table(func(index int, value ice.Maps, head []string) {
m.Push(ice.CTX, kit.Keys(value["ups"], value[mdb.NAME]))
m.Push("", value, kit.List(ice.CTX_STATUS, ice.CTX_STREAM, mdb.HELP))
})
} else if len(arg) == 2 || arg[2] == "" { // 命令列表
m.Cmd(SPACE, arg[0], ctx.CONTEXT, arg[1], ctx.COMMAND).Table(func(index int, value map[string]string, head []string) {
m.Cmd(SPACE, arg[0], ctx.CONTEXT, arg[1], ctx.COMMAND).Table(func(index int, value ice.Maps, head []string) {
m.Push(ice.CMD, value[mdb.KEY])
m.Push("", value, kit.List(mdb.NAME, mdb.HELP))
})

View File

@ -275,7 +275,7 @@ const (
const SERVE = "serve"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SERVE: {Name: SERVE, Help: "服务器", Value: kit.Data(
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,status,name,port,dev",
tcp.LOCALHOST, ice.TRUE, aaa.BLACK, kit.Dict(), aaa.WHITE, kit.Dict(
@ -294,8 +294,8 @@ func init() {
nfs.REPOS, "https://shylinux.com/x/intshell", nfs.BRANCH, nfs.MASTER,
), ice.REQUIRE, ".ish/pluged",
)},
}, Commands: map[string]*ice.Command{
SERVE: {Name: "serve name auto start spide", Help: "服务器", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
SERVE: {Name: "serve name auto start spide", Help: "服务器", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
cli.NodeInfo(m, WORKER, ice.Info.PathName)
AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
@ -321,7 +321,7 @@ func init() {
})
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(SERVE).Table(func(index int, value map[string]string, head []string) {
m.Cmd(SERVE).Table(func(index int, value ice.Maps, head []string) {
m.Done(value[cli.STATUS] == tcp.START)
})
}},

View File

@ -122,12 +122,12 @@ const (
const SHARE = "share"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SHARE: {Name: SHARE, Help: "共享链", Value: kit.Data(
mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,userrole,username,river,storm,type,name,text",
)},
}, Commands: map[string]*ice.Command{
SHARE: {Name: "share hash auto prunes", Help: "共享链", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
SHARE: {Name: "share hash auto prunes", Help: "共享链", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
ice.AddRender(ice.RENDER_DOWNLOAD, func(msg *ice.Message, cmd string, args ...ice.Any) string {
list := []string{}

View File

@ -220,8 +220,8 @@ func _space_search(m *ice.Message, kind, name, text string, arg ...string) {
if name != "" {
return
}
m.Cmd(SERVE, ice.OptionFields("")).Table(func(index int, val map[string]string, head []string) {
m.Cmd(tcp.HOST, ice.OptionFields("")).Table(func(index int, value map[string]string, head []string) {
m.Cmd(SERVE, ice.OptionFields("")).Table(func(index int, val ice.Maps, head []string) {
m.Cmd(tcp.HOST, ice.OptionFields("")).Table(func(index int, value ice.Maps, head []string) {
m.PushSearch(kit.SimpleKV("", MYSELF, value[mdb.NAME], kit.Format("http://%s:%s", value[aaa.IP], val[tcp.PORT])))
})
})
@ -289,14 +289,14 @@ const (
const SPACE = "space"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SPACE: {Name: SPACE, Help: "空间站", Value: kit.Data(
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text",
BUFFER, kit.Dict("r", ice.MOD_BUFS, "w", ice.MOD_BUFS),
REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000), TIMEOUT, kit.Dict("c", "180s"),
)},
}, Commands: map[string]*ice.Command{
SPACE: {Name: "space name cmd auto invite", Help: "空间站", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
SPACE: {Name: "space name cmd auto invite", Help: "空间站", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Conf(SPACE, mdb.HASH, "")
}},
@ -327,7 +327,7 @@ func init() {
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) < 2 { // 节点列表
if mdb.HashSelect(m, arg...); len(arg) == 0 {
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
switch value[mdb.TYPE] {
case MASTER:
m.PushAnchor(value[mdb.NAME], m.Cmd(SPIDE, value[mdb.NAME], ice.OptionFields("")).Append("client.url"))

View File

@ -127,8 +127,8 @@ func _spide_list(m *ice.Message, arg ...string) {
_spide_save(m, cache, save, uri, res)
})
}
func _spide_body(m *ice.Message, method string, arg ...string) (io.Reader, map[string]string, []string) {
head := map[string]string{}
func _spide_body(m *ice.Message, method string, arg ...string) (io.Reader, ice.Maps, []string) {
head := ice.Maps{}
body, ok := m.Optionv(SPIDE_BODY).(io.Reader)
if !ok && len(arg) > 0 && method != SPIDE_GET {
if len(arg) == 1 {
@ -216,7 +216,7 @@ func _spide_part(m *ice.Message, arg ...string) (io.Reader, string) {
}
return buf, mp.FormDataContentType()
}
func _spide_head(m *ice.Message, req *http.Request, head map[string]string, value ice.Map) {
func _spide_head(m *ice.Message, req *http.Request, head ice.Maps, value ice.Map) {
m.Info("%s %s", req.Method, req.URL)
kit.Fetch(value[SPIDE_HEADER], func(key string, value string) {
req.Header.Set(key, value)
@ -331,6 +331,7 @@ const (
ContentFORM = "application/x-www-form-urlencoded"
ContentJSON = "application/json"
ContentHTML = "text/html"
ContentCSS = "text/css"
ContentPNG = "image/png"
)
const (
@ -353,10 +354,10 @@ const (
const SPIDE = "spide"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SPIDE: {Name: SPIDE, Help: "蜘蛛侠", Value: kit.Data(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,client.name,client.url", LOGHEADERS, ice.FALSE)},
}, Commands: map[string]*ice.Command{
SPIDE: {Name: "spide client.name action=raw,msg,save,cache method=GET,PUT,POST,DELETE url format=form,part,json,data,file arg run create", Help: "蜘蛛侠", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
SPIDE: {Name: "spide client.name action=raw,msg,save,cache method=GET,PUT,POST,DELETE url format=form,part,json,data,file arg run create", Help: "蜘蛛侠", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
conf := m.Confm(cli.RUNTIME, "conf")
m.Cmd(SPIDE, mdb.CREATE, ice.OPS, kit.Select("http://127.0.0.1:9020", conf["ctx_ops"]))
@ -382,21 +383,21 @@ func init() {
_spide_list(m, arg...)
}},
SPIDE_GET: {Name: "GET url key value run", Help: "蜘蛛侠", Action: map[string]*ice.Action{
SPIDE_GET: {Name: "GET url key value run", Help: "蜘蛛侠", Actions: ice.Actions{
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, m.OptionSimple(CLIENT_NAME))
}},
}, Hand: func(m *ice.Message, arg ...string) {
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(SPIDE, ice.DEV, SPIDE_RAW, SPIDE_GET, arg[0], arg[1:]))))
}},
SPIDE_POST: {Name: "POST url key value run", Help: "蜘蛛侠", Action: map[string]*ice.Action{
SPIDE_POST: {Name: "POST url key value run", Help: "蜘蛛侠", Actions: ice.Actions{
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, m.OptionSimple(CLIENT_NAME))
}},
}, Hand: func(m *ice.Message, arg ...string) {
m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(SPIDE, ice.DEV, SPIDE_RAW, SPIDE_POST, arg[0], arg[1:]))))
}},
SPIDE_DELETE: {Name: "DELETE url key value run", Help: "蜘蛛侠", Action: map[string]*ice.Action{
SPIDE_DELETE: {Name: "DELETE url key value run", Help: "蜘蛛侠", Actions: ice.Actions{
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, m.OptionSimple(CLIENT_NAME))
}},

View File

@ -162,13 +162,13 @@ const (
const STORY = "story"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
STORY: {Name: "story", Help: "故事会", Value: kit.Dict(
mdb.META, kit.Dict(mdb.SHORT, DATA),
HEAD, kit.Data(mdb.SHORT, STORY),
)},
}, Commands: map[string]*ice.Command{
STORY: {Name: "story story auto", Help: "故事会", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
STORY: {Name: "story story auto", Help: "故事会", Actions: ice.Actions{
WRITE: {Name: "write type name text arg...", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
_story_write(m, arg[0], arg[1], arg[2], arg[3:]...)
}},
@ -260,7 +260,7 @@ func _story_pull(m *ice.Message, arg ...string) {
pull := end
var first ice.Map
for begin != "" && begin != end {
if m.Cmd(SPIDE, arg[2], "msg", "/story/pull", "begin", begin, "end", end).Table(func(index int, value map[string]string, head []string) {
if m.Cmd(SPIDE, arg[2], "msg", "/story/pull", "begin", begin, "end", end).Table(func(index int, value ice.Maps, head []string) {
if m.Richs(CACHE, nil, value["data"], nil) == nil {
m.Log(ice.LOG_IMPORT, "%v: %v", value["data"], value["save"])
if node := kit.UnMarshal(value["save"]); kit.Format(kit.Value(node, "file")) != "" {
@ -404,7 +404,7 @@ func _story_commit(m *ice.Message, arg ...string) {
arg[2] = m.Cmdx(STORY, "add", "submit", arg[2], "hostname,username")
// 节点信息
menu := map[string]string{}
menu := ice.Maps{}
for i := 3; i < len(arg); i++ {
menu[arg[i]] = m.Cmdx(STORY, INDEX, arg[i])
}

View File

@ -344,10 +344,10 @@ const (
const MATRIX = "matrix"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
MATRIX: {Name: MATRIX, Help: "魔方矩阵", Value: kit.Data(mdb.SHORT, mdb.NAME)},
}, Commands: map[string]*ice.Command{
MATRIX: {Name: "matrix name npage text auto", Help: "魔方矩阵", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
MATRIX: {Name: "matrix name npage text auto", Help: "魔方矩阵", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _yac_load(m) }},
mdb.CREATE: {Name: "create name=shy nlang=32 ncell=32", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
mat := NewMatrix(m, kit.Int(kit.Select("32", m.Option(NLANG))), kit.Int(kit.Select("32", m.Option(NCELL))))

View File

@ -16,7 +16,7 @@ type frame struct {
pos int
key string
skip bool
data map[string]string
data ice.Maps
}
type stack struct {
fs []*frame
@ -24,7 +24,7 @@ type stack struct {
}
func (s *stack) push(f *frame) *stack {
f.data = map[string]string{}
f.data = ice.Maps{}
s.fs = append(s.fs, f)
return s
}
@ -95,8 +95,8 @@ func _exp_true(m *ice.Message, arg string) bool {
const SCRIPT = "script"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
SCRIPT: {Name: "script name npage text auto create", Help: "脚本解析", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
SCRIPT: {Name: "script name npage text auto create", Help: "脚本解析", Actions: ice.Actions{
mdb.CREATE: {Name: "create name=shy text=etc/yac.txt", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(MATRIX, mdb.CREATE, m.Option(mdb.NAME))
if buf, err := ioutil.ReadFile(m.Option(mdb.TEXT)); err == nil {
@ -206,7 +206,7 @@ func init() {
m.Option("stack", stack)
m.Cmdy(MATRIX, PARSE, arg[0], arg[1], arg[2], func(nhash string, hash int, word []string, begin int, stream *lex.Stream) (int, []string) {
m.Option("stream", stream)
if _, ok := m.Target().Commands[SCRIPT].Action[nhash]; ok && stack.can_run(nhash) {
if _, ok := m.Target().Commands[SCRIPT].Actions[nhash]; ok && stack.can_run(nhash) {
msg := m.Cmd(SCRIPT, nhash, word, ice.Option{"begin", begin})
return hash, msg.Resultv()
}

View File

@ -26,7 +26,7 @@ func _action_key(m *ice.Message, arg ...string) string {
return kit.Keys(mdb.HASH, kit.Select(m.Option(RIVER), arg, 0), STORM, mdb.HASH, kit.Select(m.Option(STORM), arg, 1))
}
func _action_list(m *ice.Message, river, storm string) {
m.Cmdy(STORM, storm, ice.Option{ice.MSG_RIVER, river}).Table(func(index int, value map[string]string, head []string) {
m.Cmdy(STORM, storm, ice.Option{ice.MSG_RIVER, river}).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(m.Space(kit.Select(m.Option(ice.POD), value[ice.POD])), ctx.COMMAND, kit.Keys(value[ice.CTX], value[ice.CMD]))
})
}
@ -146,8 +146,8 @@ const (
const ACTION = "action"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range []string{
"web.chat.meet.miss",

View File

@ -51,10 +51,10 @@ func _cmd_file(m *ice.Message, arg ...string) bool {
const CMD = "cmd"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
CMD: {Name: CMD, Help: "命令", Value: kit.Data(mdb.SHORT, "type", nfs.PATH, nfs.PWD)},
}, Commands: map[string]*ice.Command{
"/cmd/": {Name: "/cmd/", Help: "命令", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
"/cmd/": {Name: "/cmd/", Help: "命令", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, "shy", mdb.NAME, "web.wiki.word")
m.Cmdy(CMD, mdb.CREATE, mdb.TYPE, "svg", mdb.NAME, "web.wiki.draw")
@ -84,7 +84,7 @@ func init() {
m.RenderDownload(path.Join(m.Config(nfs.PATH), path.Join(arg...))) // 文件
}
}},
CMD: {Name: "cmd path auto upload up home", Help: "命令", Action: ice.MergeAction(map[string]*ice.Action{
CMD: {Name: "cmd path auto upload up home", Help: "命令", Actions: ice.MergeAction(ice.Actions{
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
m.Upload(path.Join(m.Config(nfs.PATH), strings.TrimPrefix(path.Dir(m.R.URL.Path), "/cmd")))
}},

View File

@ -25,13 +25,13 @@ func _div_parse(m *ice.Message, text string) string {
const DIV = "div"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
DIV: {Name: "div", Help: "定制", Value: kit.Data(
mdb.FIELD, "time,hash,type,name,text", nfs.PATH, ice.USR_PUBLISH,
nfs.TEMPLATE, _div_template,
)},
}, Commands: map[string]*ice.Command{
"/div/": {Name: "/div/", Help: "定制", Action: ice.MergeAction(ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
}, Commands: ice.Commands{
"/div/": {Name: "/div/", Help: "定制", Actions: ice.MergeAction(ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
switch p := path.Join(arg...); kit.Ext(kit.Select("", p)) {
case nfs.HTML:
m.RenderDownload(p)
@ -45,7 +45,7 @@ func init() {
m.RenderCmd(m.PrefixKey(), p)
}
}},
DIV: {Name: "div hash auto import", Help: "定制", Action: ice.MergeAction(map[string]*ice.Action{
DIV: {Name: "div hash auto import", Help: "定制", Actions: ice.MergeAction(ice.Actions{
lex.SPLIT: {Name: "split name=hi text", Help: "生成", Hand: func(m *ice.Message, arg ...string) {
h := m.Cmdx(DIV, mdb.CREATE, m.OptionSimple(mdb.NAME), mdb.TEXT, _div_parse(m, m.Option(mdb.TEXT)))
m.ProcessRewrite(mdb.HASH, h)

View File

@ -11,12 +11,12 @@ import (
const FILES = "files"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
FILES: {Name: FILES, Help: "文件夹", Value: kit.Data(
mdb.SHORT, mdb.DATA, mdb.FIELD, "time,hash,type,name,size,data",
)},
}, Commands: map[string]*ice.Command{
FILES: {Name: "files hash auto upload", Help: "文件夹", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
FILES: {Name: "files hash auto upload", Help: "文件夹", Actions: ice.MergeAction(ice.Actions{
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
if len(up) < 2 {
@ -27,7 +27,7 @@ func init() {
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...)
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
link := web.SHARE_CACHE + value[mdb.DATA]
if m.PushDownload(mdb.LINK, value[mdb.NAME], link); len(arg) > 0 && kit.ExtIsImage(value[mdb.NAME]) {
m.PushImages("image", link)

View File

@ -14,10 +14,10 @@ const (
const FOOTER = "footer"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
FOOTER: {Name: FOOTER, Help: "状态栏", Value: kit.Dict(LEGAL, kit.List(`<a href="mailto:shylinuxc@gmail.com">shylinuxc@gmail.com</a>`))},
}, Commands: map[string]*ice.Command{
web.P(FOOTER): {Name: "/footer", Help: "状态栏", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
web.P(FOOTER): {Name: "/footer", Help: "状态栏", Actions: ice.MergeAction(ice.Actions{
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
if m.Cmdy(arg); m.Result(1) == ice.ErrNotFound {
m.Set(ice.MSG_RESULT).Cmdy(cli.SYSTEM, arg)

View File

@ -10,8 +10,8 @@ import (
const GRANT = "grant"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
GRANT: {Name: "grant space id auto insert", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
GRANT: {Name: "grant space id auto insert", Help: "授权", Actions: ice.MergeAction(ice.Actions{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
switch arg[0] {
case web.SPACE:

View File

@ -20,6 +20,12 @@ func _header_agent(m *ice.Message, arg ...string) {
}
}
func _header_check(m *ice.Message, arg ...string) bool {
if m.Option(web.SHARE) != "" {
m.Cmd(web.SHARE, m.Option(web.SHARE), ice.OptionFields("")).Tables(func(value ice.Maps) {
m.Option(ice.MSG_USERNAME, value["username"])
m.Option(ice.MSG_USERROLE, value["userrole"])
})
}
if m.Option(ice.MSG_USERNAME) != "" {
return true
}
@ -49,7 +55,6 @@ func _header_users(m *ice.Message, key string, arg ...string) {
const (
TITLE = "title"
TOPIC = "topic"
MENUS = "menus"
TRANS = "trans"
AGENT = "agent"
@ -59,9 +64,9 @@ const (
const HEADER = "header"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(aaa.LOGIN, kit.List("登录", "扫码"))},
}, Commands: map[string]*ice.Command{
}, Commands: ice.Commands{
web.WEB_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
switch arg[0] {
case "/header":
@ -75,7 +80,7 @@ func init() {
}
m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg)
}},
web.P(HEADER): {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{
web.P(HEADER): {Name: "/header", Help: "标题栏", Actions: ice.Actions{
AGENT: {Name: "agent", Help: "宿主应用", Hand: func(m *ice.Message, arg ...string) {
_header_agent(m, arg...)
}},

View File

@ -8,8 +8,8 @@ import (
const INFO = "info"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
INFO: {Name: "info auto", Help: "信息", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
INFO: {Name: "info auto", Help: "信息", Actions: ice.Actions{
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.MODIFY, RIVER, "", mdb.HASH, mdb.HASH, m.Option(ice.MSG_RIVER), arg)
}},

View File

@ -15,7 +15,7 @@ func distance(lat1, long1, lat2, long2 float64) float64 {
long2 = long2 * math.Pi / 180
return 2 * 6371 * math.Asin(math.Sqrt(math.Pow(math.Sin(math.Abs(lat1-lat2)/2), 2)+math.Cos(lat1)*math.Cos(lat2)*math.Pow(math.Sin(math.Abs(long1-long2)/2), 2)))
}
func _trans(arg []string, tr map[string]string) {
func _trans(arg []string, tr ice.Maps) {
for i := 0; i < len(arg)-1; i += 2 {
arg[i] = kit.Select(arg[i], tr[arg[i]])
}
@ -32,12 +32,12 @@ const (
const LOCATION = "location"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
LOCATION: {Name: LOCATION, Help: "地理位置", Value: kit.Data(
mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,type,name,text,longitude,latitude",
)},
}, Commands: map[string]*ice.Command{
LOCATION: {Name: "location hash auto getLocation", Help: "地理位置", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
LOCATION: {Name: "location hash auto getLocation", Help: "地理位置", Actions: ice.MergeAction(ice.Actions{
OPENLOCATION: {Name: "location", Help: "地图"},
GETLOCATION: {Name: "location create", Help: "打卡"},
mdb.CREATE: {Name: "create type=text name text latitude longitude", Help: "添加"},

View File

@ -12,12 +12,12 @@ const (
const MISS = "miss"
func init() {
Index.Register(&ice.Context{Name: MEET, Help: "遇见", Configs: map[string]*ice.Config{
Index.Register(&ice.Context{Name: MEET, Help: "遇见", Configs: ice.Configs{
MISS: {Name: MISS, Help: "miss", Value: kit.Data(
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,照片,性别,年龄,身高,体重,籍贯,户口,学历,学校,职业,公司,年薪,资产,家境",
)},
}, Commands: map[string]*ice.Command{
"monkey": {Name: "monkey total=888 count=9 run", Help: "猴子开箱子", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
"monkey": {Name: "monkey total=888 count=9 run", Help: "猴子开箱子", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create name 照片 性别 年龄 身高 体重 籍贯 户口 学历 学校 职业 公司 年薪 资产 家境", Help: "添加"},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
total := kit.Int(arg[0])
@ -38,11 +38,11 @@ func init() {
}
m.StatusTimeCount()
}},
MISS: {Name: "miss name auto create", Help: "资料", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Action: ice.MergeAction(map[string]*ice.Action{
MISS: {Name: "miss name auto create", Help: "资料", Meta: kit.Dict("_trans", kit.Dict("name", "姓名")), Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create name 照片 性别 年龄 身高 体重 籍贯 户口 学历 学校 职业 公司 年薪 资产 家境", Help: "添加"},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
msg := m.Spawn()
mdb.HashSelect(msg, arg...).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(msg, arg...).Table(func(index int, value ice.Maps, head []string) {
value["照片"] = ice.Render(m, ice.RENDER_IMAGES, value["照片"], kit.Select("100", "400", msg.FieldsIsDetail()))
m.Push(m.OptionFields(), value, kit.Split(msg.OptionFields()))
})

View File

@ -12,8 +12,8 @@ import (
const NODE = "node"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
NODE: {Name: "node pod ctx cmd auto insert invite", Help: "设备", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
NODE: {Name: "node pod ctx cmd auto insert invite", Help: "设备", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Watch(web.DREAM_START, m.PrefixKey())
m.Watch(web.SPACE_START, m.PrefixKey())
@ -51,7 +51,7 @@ func init() {
if len(arg) == 0 {
m.OptionFields("time,type,name,share")
m.Cmdy(mdb.SELECT, RIVER, _river_key(m, NODE), mdb.HASH)
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
m.PushAnchor(value[mdb.NAME], m.MergeURL2("/chat/pod/"+kit.Keys(m.Option(ice.POD), value[mdb.NAME])))
})
m.RenameAppend("name", "pod")

View File

@ -55,8 +55,8 @@ const (
)
const OAUTH = "oauth"
var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string]*ice.Command{
OAUTH: {Name: "oauth hash auto prunes", Help: "权限", Action: ice.MergeAction(map[string]*ice.Action{
var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: ice.Commands{
OAUTH: {Name: "oauth hash auto prunes", Help: "权限", Actions: ice.MergeAction(ice.Actions{
CHECK: {Name: "check scope domain", Help: "检查", Hand: func(m *ice.Message, arg ...string) {
m.Echo(_merge_url(m, kit.Select(ice.Info.Make.Domain, m.Option(web.DOMAIN)), APPLY, m.OptionSimple(SCOPE), REDIRECT_URI, _merge_url(m, "", REPLY)))
}},
@ -77,11 +77,11 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string
}},
})},
APPLY: {Name: "apply hash auto create prunes", Help: "申请", Action: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,username,scope,redirect_uri")},
REPLY: {Name: "reply hash auto create prunes", Help: "授权", Action: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,offer")},
OFFER: {Name: "offer hash auto create prunes", Help: "访问", Action: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")},
APPLY: {Name: "apply hash auto create prunes", Help: "申请", Actions: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,username,scope,redirect_uri")},
REPLY: {Name: "reply hash auto create prunes", Help: "授权", Actions: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,offer")},
OFFER: {Name: "offer hash auto create prunes", Help: "访问", Actions: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")},
web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Action: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) {
web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) {
if m.Option(REDIRECT_URI) == "" {
m.RenderStatusBadRequest() // 参数错误
@ -89,7 +89,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string
m.RenderCmd(m.Prefix(OAUTH), APPLY)
}
}},
web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Action: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) {
web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) {
if m.Option(OFFER) == "" {
m.RenderStatusBadRequest() // 参数错误
@ -109,9 +109,9 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: map[string
}
}},
AUTHORIZE: {Name: "authorize hash auto create prunes", Help: "认证", Action: mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,redirect_uri")},
TOKEN: {Name: "token hash auto create prunes", Help: "授权", Action: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,used,state,scope,redirect_uri")},
ACCESS: {Name: "access hash auto create prunes", Help: "访问", Action: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")},
AUTHORIZE: {Name: "authorize hash auto create prunes", Help: "认证", Actions: mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,redirect_uri")},
TOKEN: {Name: "token hash auto create prunes", Help: "授权", Actions: mdb.HashAction(mdb.EXPIRE, "72h", mdb.FIELD, "time,hash,used,state,scope,redirect_uri")},
ACCESS: {Name: "access hash auto create prunes", Help: "访问", Actions: mdb.HashAction(mdb.EXPIRE, "720h", mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")},
web.P(AUTHORIZE): {Name: "/authorize state scope client_id redirect_uri", Help: "认证", Hand: func(m *ice.Message, arg ...string) {
if m.Option(CLIENT_ID) == "" || m.Option(REDIRECT_URI) == "" {

View File

@ -10,8 +10,8 @@ import (
const OCEAN = "ocean"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
OCEAN: {Name: "ocean username auto insert invite", Help: "用户", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
OCEAN: {Name: "ocean username auto insert invite", Help: "用户", Actions: ice.Actions{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(aaa.USER, ice.OptionFields(aaa.USERNAME, aaa.USERNICK, aaa.USERZONE))
}},
@ -24,7 +24,7 @@ func init() {
}, Hand: func(m *ice.Message, arg ...string) {
m.Fields(len(arg), "time,username")
m.Cmdy(mdb.SELECT, RIVER, _river_key(m, OCEAN), mdb.HASH, aaa.USERNAME, arg)
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
msg := m.Cmd(aaa.USER, value[aaa.USERNAME])
m.Push(aaa.USERNICK, msg.Append(aaa.USERNICK))
m.PushImages(aaa.AVATAR, msg.Append(aaa.AVATAR), kit.Select("60", "240", m.FieldsIsDetail()))

View File

@ -11,12 +11,12 @@ import (
const PASTE = "paste"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
PASTE: {Name: PASTE, Help: "粘贴", Value: kit.Data(
mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,type,name,text",
)},
}, Commands: map[string]*ice.Command{
PASTE: {Name: "paste hash auto getClipboardData", Help: "粘贴", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
PASTE: {Name: "paste hash auto getClipboardData", Help: "粘贴", Actions: ice.MergeAction(ice.Actions{
"getClipboardData": {Name: "getClipboardData", Help: "粘贴", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(PASTE, mdb.CREATE, arg)
}},

View File

@ -16,10 +16,10 @@ import (
const POD = "pod"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
POD: {Name: POD, Help: "节点", Value: kit.Data()},
}, Commands: map[string]*ice.Command{
"/pod/": {Name: "/pod/", Help: "节点", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
"/pod/": {Name: "/pod/", Help: "节点", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
}},
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {

View File

@ -53,8 +53,8 @@ func _river_list(m *ice.Message) {
const RIVER = "river"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
RIVER: {Name: "river hash auto create", Help: "群组", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
RIVER: {Name: "river hash auto create", Help: "群组", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(nfs.TEMPLATE, _river_template) }},
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
switch m.Option(ctx.ACTION) {

View File

@ -15,21 +15,21 @@ func init() {
JOIN = "join"
QUIT = "quit"
)
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
ROOM: {Name: "room", Help: "room", Value: kit.Data(
mdb.SHORT, "zone", mdb.FIELD, "time,id,type,name,text",
)},
JOIN: {Name: "join", Help: "join", Value: kit.Data(
mdb.SHORT, "space", mdb.FIELD, "time,hash,username,socket",
)},
}, Commands: map[string]*ice.Command{
ROOM: {Name: "room zone id auto", Help: "room", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
ROOM: {Name: "room zone id auto", Help: "room", Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create zone", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(mdb.ZONE))
}},
mdb.INSERT: {Name: "insert zone type=hi name=hello text=world", Help: "发送", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.ZONE, m.Option(mdb.ZONE), arg[2:])
m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, ice.Option{"fields", "time,space"}).Table(func(index int, value map[string]string, head []string) {
m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, ice.Option{"fields", "time,space"}).Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(web.SPACE, value[web.SPACE], "toast", m.Option("text"), m.Option("name"))
})
}},
@ -51,7 +51,7 @@ func init() {
m.Action(mdb.INSERT, JOIN)
}
}},
JOIN: {Name: "join space zone auto", Help: "join", Action: ice.MergeAction(map[string]*ice.Action{
JOIN: {Name: "join space zone auto", Help: "join", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
// m.Watch(web.SPACE_START, m.PrefixKey())
}},

View File

@ -11,14 +11,14 @@ import (
const SCAN = "scan"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
SCAN: {Name: SCAN, Help: "扫码", Value: kit.Data(
mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,type,name,text",
)},
}, Commands: map[string]*ice.Command{
}, Commands: ice.Commands{
SCAN: {Name: "scan hash auto scanQRCode scanQRCode0", Help: "扫码", Meta: kit.Dict(
ice.Display("scan.js"),
), Action: ice.MergeAction(map[string]*ice.Action{
), Actions: ice.MergeAction(ice.Actions{
"scanQRCode0": {Name: "scan create", Help: "本机扫码"},
"scanQRCode": {Name: "scan create", Help: "扫码"},
mdb.CREATE: {Name: "create type=text name=hi text:textarea=hi", Help: "添加"},

View File

@ -10,8 +10,8 @@ import (
const SEARCH = "search"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
web.P(SEARCH): {Name: "/search", Help: "搜索引擎", Action: ctx.CmdAction(mdb.SHORT, mdb.NAME), Hand: func(m *ice.Message, arg ...string) {
Index.Merge(&ice.Context{Commands: ice.Commands{
web.P(SEARCH): {Name: "/search", Help: "搜索引擎", Actions: ctx.CmdAction(mdb.SHORT, mdb.NAME), Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(m.Space(m.Option(ice.POD)), mdb.SEARCH, arg).StatusTimeCount()
}},
}})

View File

@ -12,7 +12,7 @@ import (
const SSO = "sso"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
Index.Merge(&ice.Context{Commands: ice.Commands{
"/sso": {Name: "/sso", Help: "登录", Hand: func(m *ice.Message, arg ...string) {
if m.Option(ice.MSG_USERNAME) == "" {
m.RenderIndex(web.SERVE, ice.VOLCANOS)

View File

@ -14,8 +14,8 @@ func _storm_key(m *ice.Message, key ...ice.Any) string {
const STORM = "storm"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
STORM: {Name: "storm hash id auto insert create", Help: "应用", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
STORM: {Name: "storm hash id auto insert create", Help: "应用", Actions: ice.Actions{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
if ctx.Inputs(m, arg[0]) {
return
@ -81,7 +81,7 @@ func init() {
if m.Copy(msg); len(arg) > 1 { // 命令插件
m.ProcessField(arg[0], arg[1], ice.RUN)
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
m.Cmdy(m.Space(value[ice.POD]), ctx.CONTEXT, value[ice.CTX], ctx.COMMAND, value[ice.CMD])
})
} else {

View File

@ -18,8 +18,8 @@ const (
)
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
TRANS: {Name: "trans from to auto", Help: "传输", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
TRANS: {Name: "trans from to auto", Help: "传输", Actions: ice.MergeAction(ice.Actions{
SEND: {Name: "send", Help: "发送", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, kit.Select(nfs.PWD, m.Option("to_path")),
m.MergeURL2(path.Join(web.SHARE_LOCAL, m.Option("from_path")), ice.POD, m.Option(FROM),

View File

@ -156,7 +156,7 @@ func _website_render(m *ice.Message, w http.ResponseWriter, r *http.Request, kin
return true
}
func _website_search(m *ice.Message, kind, name, text string, arg ...string) {
m.Cmd(m.PrefixKey(), ice.OptionFields("")).Table(func(index int, value map[string]string, head []string) {
m.Cmd(m.PrefixKey(), ice.OptionFields("")).Table(func(index int, value ice.Maps, head []string) {
m.PushSearch(value, mdb.TEXT, m.MergeWebsite(value[nfs.PATH]))
})
}
@ -168,11 +168,11 @@ const (
const WEBSITE = "website"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
WEBSITE: {Name: "website", Help: "网站", Value: kit.Data(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path,type,name,text")},
}, Commands: map[string]*ice.Command{
"/website/": {Name: "/website/", Help: "网站", Action: ice.MergeAction(map[string]*ice.Action{}, ctx.CmdAction())},
WEBSITE: {Name: "website path auto create import", Help: "网站", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
"/website/": {Name: "/website/", Help: "网站", Actions: ice.MergeAction(ice.Actions{}, ctx.CmdAction())},
WEBSITE: {Name: "website path auto create import", Help: "网站", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.RENDER, mdb.CREATE, nfs.IML, m.PrefixKey())
m.Cmd(mdb.ENGINE, mdb.CREATE, nfs.IML, m.PrefixKey())
@ -250,7 +250,7 @@ func init() {
})
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m, arg...).Table(func(index int, value ice.Maps, head []string) {
m.PushAnchor(m.MergeWebsite(value[nfs.PATH]))
})
if len(arg) == 0 {

View File

@ -164,8 +164,8 @@ func init() {
const AUTOGEN = "autogen"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
AUTOGEN: {Name: "autogen path auto create binpack script relay", Help: "生成", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
AUTOGEN: {Name: "autogen path auto create binpack script relay", Help: "生成", Actions: ice.Actions{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
switch arg[0] {
case cli.MAIN:

View File

@ -61,8 +61,8 @@ const (
const BENCH = "bench"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
BENCH: {Name: "bench zone id auto insert", Help: "性能压测", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
BENCH: {Name: "bench zone id auto insert", Help: "性能压测", Actions: ice.MergeAction(ice.Actions{
mdb.INSERT: {Name: "insert zone=some type=http,redis name=demo text='http://localhost:9020' nconn=3 nreqs=10", Help: "添加"},
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
switch m.Option(mdb.TYPE) {

View File

@ -31,7 +31,7 @@ func _binpack_dir(m *ice.Message, f *os.File, dir string) {
m.Option(nfs.DIR_DEEP, true)
m.Option(nfs.DIR_TYPE, nfs.CAT)
m.Cmd(nfs.DIR, nfs.PWD).Sort(nfs.PATH).Tables(func(value map[string]string) {
m.Cmd(nfs.DIR, nfs.PWD).Sort(nfs.PATH).Tables(func(value ice.Maps) {
switch path.Base(value[nfs.PATH]) {
case "go.mod", "go.sum", "binpack.go", "version.go":
return
@ -54,7 +54,7 @@ func _binpack_can(m *ice.Message, f *os.File, dir string) {
fmt.Fprintln(f, _binpack_file(m, path.Join(dir, k), ice.PS+k))
}
for _, k := range []string{LIB, PAGE, PANEL, PLUGIN, "publish/client/nodejs/"} {
m.Cmd(nfs.DIR, k).Sort(nfs.PATH).Tables(func(value map[string]string) {
m.Cmd(nfs.DIR, k).Sort(nfs.PATH).Tables(func(value ice.Maps) {
fmt.Fprintln(f, _binpack_file(m, path.Join(dir, value[nfs.PATH]), ice.PS+value[nfs.PATH]))
})
}
@ -67,8 +67,8 @@ func _binpack_ctx(m *ice.Message, f *os.File) {
const BINPACK = "binpack"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
if kit.FileExists(path.Join(ice.USR_VOLCANOS, ice.PROTO_JS)) {
m.Cmd(BINPACK, mdb.REMOVE)
@ -134,7 +134,7 @@ func init() {
}
`)
fmt.Fprintln(f, ` pack := map[string]string{`)
fmt.Fprintln(f, ` pack := ice.Maps{`)
defer fmt.Fprintln(f, ` }`)
if kit.FileExists(ice.USR_VOLCANOS) && kit.FileExists(ice.USR_INTSHELL) && m.Option(ice.MSG_USERPOD) == "" {
@ -153,7 +153,7 @@ func init() {
fmt.Fprintln(f, _binpack_file(m, ice.README_MD))
fmt.Fprintln(f)
m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(nfs.PATH)).Tables(func(value map[string]string) {
m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(nfs.PATH)).Tables(func(value ice.Maps) {
if s, e := os.Stat(value[nfs.PATH]); e == nil {
if s.IsDir() {
_binpack_dir(m, f, value[nfs.PATH])

View File

@ -48,8 +48,8 @@ const (
const C = "c"
func init() {
Index.Register(&ice.Context{Name: C, Help: "系统", Commands: map[string]*ice.Command{
C: {Name: C, Help: "系统", Action: ice.MergeAction(map[string]*ice.Action{
Index.Register(&ice.Context{Name: C, Help: "系统", Commands: ice.Commands{
C: {Name: C, Help: "系统", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} {
for _, k := range []string{H, C, CC} {
@ -79,7 +79,7 @@ func init() {
// _go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2])
}},
}, PlugAction())},
MAN: {Name: MAN, Help: "手册", Action: ice.MergeAction(map[string]*ice.Action{
MAN: {Name: MAN, Help: "手册", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range []string{mdb.SEARCH, mdb.RENDER, mdb.PLUGIN} {
for _, k := range []string{MAN1, MAN2, MAN3, MAN8} {
@ -102,7 +102,7 @@ func init() {
}
}},
}, PlugAction())},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
C: {Name: C, Help: "系统", Value: kit.Data(PLUG, kit.Dict(
SPLIT, kit.Dict("space", " ", "operator", "{[(.,:;!|<>)]}"),
PREFIX, kit.Dict("//", COMMENT, "/* ", COMMENT, "* ", COMMENT), PREPARE, kit.Dict(

View File

@ -15,8 +15,8 @@ import (
const CASE = "case"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
CASE: {Name: "case dev zone id auto", Help: "用例", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
CASE: {Name: "case dev zone id auto", Help: "用例", Actions: ice.MergeAction(ice.Actions{
mdb.CREATE: {Name: "create name address", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(web.SPIDE, mdb.CREATE, arg)
}},
@ -25,7 +25,7 @@ func init() {
cli.CHECK: {Name: "check", Help: "检查", Hand: func(m *ice.Message, arg ...string) {
if m.ProcessInner(); len(arg) > 0 {
success := 0
m.Cmd(m.PrefixKey(), arg[0]).Tables(func(value map[string]string) {
m.Cmd(m.PrefixKey(), arg[0]).Tables(func(value ice.Maps) {
m.Push(mdb.TIME, m.Time())
m.Push(mdb.ID, value[mdb.ID])
if err := m.Cmdx(m.PrefixKey(), cli.CHECK, value); err == ice.OK {
@ -75,7 +75,7 @@ func init() {
m.PushAction(ice.RUN, cli.CHECK)
}
}},
"test": {Name: "test path func auto run case", Help: "测试用例", Action: map[string]*ice.Action{
"test": {Name: "test path func auto run case", Help: "测试用例", Actions: ice.Actions{
"run": {Name: "run", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
// cli.Follow(m, "run", func() {
m.Option(cli.CMD_DIR, kit.Select(path.Dir(arg[0]), arg[0], strings.HasSuffix(arg[0], "/")))
@ -87,7 +87,7 @@ func init() {
if strings.HasSuffix(arg[0], "/") {
msg.Option(cli.CMD_DIR, arg[0])
msg.Split(msg.Cmdx(cli.SYSTEM, "grep", "-r", "func Test.*(", nfs.PWD), "file:line", ":", "\n")
msg.Tables(func(value map[string]string) {
msg.Tables(func(value ice.Maps) {
if strings.HasPrefix(strings.TrimSpace(value["line"]), "//") {
return
}

View File

@ -41,12 +41,12 @@ const (
const COMPILE = "compile"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
COMPILE: {Name: COMPILE, Help: "编译", Value: kit.Data(nfs.PATH, ice.USR_PUBLISH,
cli.ENV, kit.Dict("GOPROXY", "https://goproxy.cn,direct", "GOPRIVATE", "shylinux.com,github.com", "CGO_ENABLED", "0"),
)},
}, Commands: map[string]*ice.Command{
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack relay install", Help: "编译", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack relay install", Help: "编译", Actions: ice.Actions{
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, `.*\.go$`)).Sort(nfs.PATH)
}},

View File

@ -9,8 +9,8 @@ import (
const FAVOR = "favor"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
FAVOR: {Name: "favor zone id auto insert", Help: "收藏夹", Actions: ice.MergeAction(ice.Actions{
mdb.INSERT: {Name: "insert zone=数据结构 type=go name=hi text=hello path file line", Help: "添加"},
INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) {
m.ProcessCommand(INNER, m.OptionSplit("path,file,line"), arg...)

View File

@ -53,10 +53,10 @@ func _go_help(m *ice.Message, key string) {
}
}
func _go_find(m *ice.Message, key string, dir string) {
m.Cmd(nfs.FIND, dir, key).Tables(func(value map[string]string) { m.PushSearch(nfs.LINE, 1, value) })
m.Cmd(nfs.FIND, dir, key).Tables(func(value ice.Maps) { m.PushSearch(nfs.LINE, 1, value) })
}
func _go_grep(m *ice.Message, key string, dir string) {
m.Cmd(nfs.GREP, dir, key).Tables(func(value map[string]string) { m.PushSearch(value) })
m.Cmd(nfs.GREP, dir, key).Tables(func(value ice.Maps) { m.PushSearch(value) })
}
var _cache_mods = map[string]*ice.Message{}
@ -177,8 +177,8 @@ func _mod_show(m *ice.Message, file string) {
)
block := ""
require := map[string]string{}
replace := map[string]string{}
require := ice.Maps{}
replace := ice.Maps{}
m.Cmd(nfs.CAT, file, func(ls []string, line string) {
switch {
case strings.HasPrefix(line, MODULE):
@ -223,7 +223,7 @@ const SUM = "sum"
const GODOC = "godoc"
func init() {
Index.Register(&ice.Context{Name: GO, Help: "后端", Commands: map[string]*ice.Command{
Index.Register(&ice.Context{Name: GO, Help: "后端", Commands: ice.Commands{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.SEARCH, mdb.CREATE, GODOC, m.Prefix(GO))
m.Cmd(mdb.ENGINE, mdb.CREATE, GO, m.Prefix(GO))
@ -234,20 +234,20 @@ func init() {
m.Cmd(mdb.PLUGIN, mdb.CREATE, k, m.Prefix(k))
}
}},
GODOC: {Name: "godoc", Help: "文档", Action: ice.MergeAction(map[string]*ice.Action{
GODOC: {Name: "godoc", Help: "文档", Actions: ice.MergeAction(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
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: ice.MergeAction(map[string]*ice.Action{
SUM: {Name: "sum", Help: "版本", Actions: ice.MergeAction(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _sum_show(m, path.Join(arg[2], arg[1])) }},
mdb.ENGINE: {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{
MOD: {Name: "mod", Help: "模块", Actions: ice.MergeAction(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _mod_show(m, path.Join(arg[2], arg[1])) }},
}, PlugAction())},
GO: {Name: "go", Help: "后端", Action: ice.MergeAction(map[string]*ice.Action{
GO: {Name: "go", Help: "后端", Actions: ice.MergeAction(ice.Actions{
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if arg[0] == GO {
_go_tags(m, kit.Select(cli.MAIN, arg, 1))
@ -259,7 +259,7 @@ func init() {
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _go_exec(m, arg...) }},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _go_show(m, arg...) }},
}, PlugAction())},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
MOD: {Name: MOD, Help: "模块", Value: kit.Data(PLUG, kit.Dict(
PREFIX, kit.Dict("//", COMMENT), PREPARE, kit.Dict(
KEYWORD, kit.Simple("go", "module", "require", "replace", "=>"),

View File

@ -68,8 +68,8 @@ func LoadPlug(m *ice.Message, language ...string) {
})
}
}
func PlugAction() map[string]*ice.Action {
return map[string]*ice.Action{
func PlugAction() ice.Actions {
return ice.Actions{
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Config(PLUG)) }},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }},
@ -98,8 +98,8 @@ const (
const INNER = "inner"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
INNER: {Name: "inner path=src/@key file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict(ice.DisplayLocal("")), Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
INNER: {Name: "inner path=src/@key file=main.go line=1 auto", Help: "源代码", Meta: kit.Dict(ice.DisplayLocal("")), Actions: ice.MergeAction(ice.Actions{
mdb.PLUGIN: {Name: "plugin", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" {
m.Echo(kit.Select("{}", m.Config(kit.Keys(PLUG, arg[0]))))
@ -117,7 +117,7 @@ func init() {
m.Option(nfs.DIR_ROOT, arg[2])
m.Option(cli.CMD_DIR, kit.Path(arg[2]))
m.Cmdy(mdb.SEARCH, arg[0], arg[1], arg[2])
m.Cmd(FAVOR, arg[1], ice.OptionFields("")).Tables(func(value map[string]string) {
m.Cmd(FAVOR, arg[1], ice.OptionFields("")).Tables(func(value ice.Maps) {
if p := path.Join(value[nfs.PATH], value[nfs.FILE]); strings.HasPrefix(p, m.Option(nfs.PATH)) {
m.Push(nfs.FILE, strings.TrimPrefix(p, m.Option(nfs.PATH)))
m.Push(nfs.LINE, value[nfs.LINE])
@ -197,7 +197,7 @@ func init() {
}
m.Set(ice.MSG_STATUS)
}},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
INNER: {Name: "inner", Help: "源代码", Value: kit.Data(
EXEC, kit.Dict("py", []string{"python"}),
PLUG, kit.Dict(

View File

@ -105,7 +105,7 @@ func _install_spawn(m *ice.Message, arg ...string) {
if m.Option(INSTALL) == "" && kit.FileExists(kit.Path(source, "_install")) {
m.Option(INSTALL, "_install")
}
m.Cmd(nfs.DIR, path.Join(source, m.Option(INSTALL))).Tables(func(value map[string]string) {
m.Cmd(nfs.DIR, path.Join(source, m.Option(INSTALL))).Tables(func(value ice.Maps) {
m.Cmd(cli.SYSTEM, "cp", "-r", strings.TrimSuffix(value[nfs.PATH], ice.PS), target+ice.PS)
})
}
@ -127,7 +127,7 @@ func _install_start(m *ice.Message, arg ...string) {
}
}
func _install_stop(m *ice.Message, arg ...string) {
m.Cmd(cli.DAEMON).Tables(func(value map[string]string) {
m.Cmd(cli.DAEMON).Tables(func(value ice.Maps) {
if value[cli.PID] == m.Option(cli.PID) {
m.Cmd(cli.DAEMON, cli.STOP, kit.Dict(mdb.HASH, value[mdb.HASH]))
}
@ -137,12 +137,12 @@ func _install_stop(m *ice.Message, arg ...string) {
func _install_service(m *ice.Message, arg ...string) {
arg = kit.Split(path.Base(arg[0]), "-.")[:1]
m.Fields(len(arg[1:]), "time,port,status,pid,cmd,dir")
m.Cmd(mdb.SELECT, cli.DAEMON, "", mdb.HASH).Tables(func(value map[string]string) {
m.Cmd(mdb.SELECT, cli.DAEMON, "", mdb.HASH).Tables(func(value ice.Maps) {
if strings.Contains(value[ice.CMD], path.Join(ice.BIN, arg[0])) {
m.Push("", value, kit.Split(m.OptionFields()))
}
})
m.Set(tcp.PORT).Tables(func(value map[string]string) { m.Push(tcp.PORT, path.Base(value[nfs.DIR])) })
m.Set(tcp.PORT).Tables(func(value ice.Maps) { m.Push(tcp.PORT, path.Base(value[nfs.DIR])) })
m.StatusTimeCount()
}
@ -152,12 +152,12 @@ const (
const INSTALL = "install"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
INSTALL: {Name: INSTALL, Help: "安装", Value: kit.Data(
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,path,link", nfs.PATH, ice.USR_INSTALL,
)},
}, Commands: map[string]*ice.Command{
INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Actions: ice.MergeAction(ice.Actions{
web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
_install_download(m)
}},
@ -204,8 +204,8 @@ func init() {
}})
}
func InstallAction(args ...ice.Any) map[string]*ice.Action {
return map[string]*ice.Action{ice.CTX_INIT: mdb.AutoConfig(args...),
func InstallAction(args ...ice.Any) ice.Actions {
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...),
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(INSTALL, web.DOWNLOAD, m.Config(nfs.SOURCE))
}},

View File

@ -51,8 +51,8 @@ const JSON = "json"
const NODE = "node"
func init() {
Index.Register(&ice.Context{Name: JS, Help: "前端", Commands: map[string]*ice.Command{
JS: {Name: "js", Help: "前端", Action: ice.MergeAction(map[string]*ice.Action{
Index.Register(&ice.Context{Name: JS, Help: "前端", Commands: ice.Commands{
JS: {Name: "js", Help: "前端", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} {
m.Cmd(cmd, mdb.CREATE, JSON, m.PrefixKey())
@ -83,12 +83,12 @@ func init() {
_go_grep(m, kit.Select(cli.MAIN, arg, 1), arg[2])
}},
}, PlugAction())},
NODE: {Name: "node auto download", Help: "前端", Action: map[string]*ice.Action{
NODE: {Name: "node auto download", Help: "前端", Actions: ice.Actions{
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(INSTALL, m.Config(nfs.SOURCE))
}},
}},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
NODE: {Name: NODE, Help: "前端", Value: kit.Data(
nfs.SOURCE, "https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz",
)},

View File

@ -22,10 +22,10 @@ func init() {
LOGIN_OAUTH = "https://github.com/login/oauth/"
API_GITHUB = "https://api.github.com/"
)
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
OAUTH: {Name: OAUTH, Help: "授权", Value: kit.Data(mdb.FIELD, "time,hash,code,access_token,scope,token_type")},
}, Commands: map[string]*ice.Command{
OAUTH: {Name: "oauth hash auto", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
OAUTH: {Name: "oauth hash auto", Help: "授权", Actions: ice.MergeAction(ice.Actions{
ctx.CONFIG: {Name: "config client_id client_secret redirect_uri", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
m.ConfigOption(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI)
}},
@ -77,7 +77,7 @@ func init() {
m.Debug("what %v", m.FormatMeta())
}
}},
"/oauth": {Name: "/oauth", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
"/oauth": {Name: "/oauth", Help: "授权", Actions: ice.MergeAction(ice.Actions{}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Option(CODE) != "" {
m.RenderCmd(m.PrefixKey(), m.Cmdx(m.PrefixKey(), mdb.CREATE, m.OptionSimple(CODE)))
}

View File

@ -24,12 +24,12 @@ const (
const PPROF = "pprof"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
PPROF: {Name: PPROF, Help: "性能分析", Value: kit.Data(
mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,text,file", PPROF, kit.List(GO, "tool", PPROF),
)},
}, Commands: map[string]*ice.Command{
PPROF: {Name: "pprof zone id auto", Help: "性能分析", Action: ice.MergeAction(map[string]*ice.Action{
}, Commands: ice.Commands{
PPROF: {Name: "pprof zone id auto", Help: "性能分析", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
if p := r.URL.Path; strings.HasPrefix(p, "/debug") {
@ -44,7 +44,7 @@ func init() {
case BINNARY:
m.Cmdy(nfs.DIR, ice.BIN, nfs.DIR_CLI_FIELDS).RenameAppend(nfs.PATH, BINNARY)
case SERVICE:
m.Cmd(web.SPIDE).Tables(func(value map[string]string) {
m.Cmd(web.SPIDE).Tables(func(value ice.Maps) {
m.Push(SERVICE, kit.MergeURL2(value["client.url"], "/debug/pprof/profile"))
})
}
@ -73,7 +73,7 @@ func init() {
return
}
m.Tables(func(value map[string]string) {
m.Tables(func(value ice.Maps) {
m.PushDownload(mdb.LINK, "pprof.pd.gz", value[nfs.FILE])
m.PushButton(web.SERVE)
})

View File

@ -60,10 +60,10 @@ const (
const PUBLISH = "publish"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data(nfs.PATH, ice.USR_PUBLISH, ice.CONTEXTS, _contexts)},
}, Commands: map[string]*ice.Command{
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell export", Help: "发布", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell export", Help: "发布", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Config(nfs.PATH))
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey())

View File

@ -26,8 +26,8 @@ func _py_main_script(m *ice.Message, arg ...string) {
const PY = nfs.PY
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
PY: {Name: "py path auto", Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
PY: {Name: "py path auto", Help: "脚本", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.ENGINE, mdb.CREATE, PY, m.PrefixKey())
m.Cmd(mdb.RENDER, mdb.CREATE, PY, m.PrefixKey())
@ -48,7 +48,7 @@ func init() {
m.Option(nfs.DIR_REG, ".*.(py)$")
m.Cmdy(nfs.DIR, arg)
}},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
PY: {Name: PY, Help: "脚本", Value: kit.Data(PLUG, kit.Dict(
SPLIT, kit.Dict(SPACE, " ", OPERATE, "{[(.,;!|<>)]}"),
PREFIX, kit.Dict("#!", COMMENT, "# ", COMMENT), SUFFIX, kit.Dict(" {", COMMENT),

View File

@ -58,8 +58,8 @@ func _sh_exec(m *ice.Message, arg ...string) {
const SH = nfs.SH
func init() {
Index.Register(&ice.Context{Name: SH, Help: "命令", Commands: map[string]*ice.Command{
SH: {Name: "sh path auto", Help: "命令", Action: ice.MergeAction(map[string]*ice.Action{
Index.Register(&ice.Context{Name: SH, Help: "命令", Commands: ice.Commands{
SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Name: "_init", Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} {
m.Cmd(cmd, mdb.CREATE, m.CommandKey(), m.PrefixKey())
@ -92,7 +92,7 @@ func init() {
m.Option(nfs.DIR_REG, ".*.(sh)$")
m.Cmdy(nfs.DIR, arg)
}},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
SH: {Name: SH, Help: "命令", Value: kit.Data(PLUG, kit.Dict(
SPLIT, kit.Dict(SPACE, " ", OPERATE, "{[(.,;!|<>)]}"),
PREFIX, kit.Dict("#!", COMMENT, "# ", COMMENT), SUFFIX, kit.Dict(" {", COMMENT),

View File

@ -34,8 +34,8 @@ func _shy_exec(m *ice.Message, arg ...string) {
const SHY = "shy"
func init() {
Index.Register(&ice.Context{Name: SHY, Help: "脚本", Commands: map[string]*ice.Command{
SHY: {Name: "shy path auto", Help: "脚本", Action: ice.MergeAction(map[string]*ice.Action{
Index.Register(&ice.Context{Name: SHY, Help: "脚本", Commands: ice.Commands{
SHY: {Name: "shy path auto", Help: "脚本", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
for _, cmd := range []string{mdb.SEARCH, mdb.ENGINE, mdb.RENDER, mdb.PLUGIN} {
m.Cmd(cmd, mdb.CREATE, SHY, m.PrefixKey())
@ -61,7 +61,7 @@ func init() {
}
m.Cmdy("web.wiki.word", arg)
}},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
SHY: {Name: SHY, Help: "脚本", Value: kit.Data(PLUG, kit.Dict(
mdb.RENDER, kit.Dict(),
PREFIX, kit.Dict("# ", COMMENT), PREPARE, kit.Dict(

View File

@ -13,8 +13,8 @@ import (
const TEMPLATE = "template"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
TEMPLATE: {Name: "template name auto", Help: "模板", Action: ice.MergeAction(map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
TEMPLATE: {Name: "template name auto", Help: "模板", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
for _, _template := range _template_list {
m.Cmd(TEMPLATE, mdb.CREATE, kit.SimpleKV(kit.Format(_template[0]), _template[1:]...))

View File

@ -16,14 +16,14 @@ import (
const UPGRADE = "upgrade"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
UPGRADE: {Name: UPGRADE, Help: "升级", Value: kit.Dict(mdb.HASH, kit.Dict(
nfs.TARGET, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, "bin", nfs.FILE, "ice.bin")),
nfs.SOURCE, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, "tar", nfs.FILE, "contexts.src.tar.gz")),
nfs.BINARY, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, "tar", nfs.FILE, "contexts.bin.tar.gz")),
))},
}, Commands: map[string]*ice.Command{
UPGRADE: {Name: "upgrade item=target,source,binary run restart", Help: "升级", Action: map[string]*ice.Action{
}, Commands: ice.Commands{
UPGRADE: {Name: "upgrade item=target,source,binary run restart", Help: "升级", Actions: ice.Actions{
cli.RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) {
m.Sleep("1s").Go(func() { m.Cmd(ice.EXIT, 1) })
}},

View File

@ -145,8 +145,8 @@ func _vimer_go_complete(m *ice.Message, name string, arg ...string) *ice.Message
const VIMER = "vimer"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Meta: kit.Dict(ice.DisplayLocal("", INNER)), Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Meta: kit.Dict(ice.DisplayLocal("", INNER)), Actions: ice.Actions{
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
m.Option(nfs.CONTENT, kit.Select(_vimer_defs(m, kit.Ext(m.Option(nfs.FILE))), m.Option(nfs.CONTENT)))
m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))

View File

@ -48,7 +48,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
m.Option(nfs.DIR_PACK, true)
m.Option(nfs.DIR_TYPE, nfs.CAT)
// m.Cmd(nfs.DIR, ice.SRC).Tables(func(value map[string]string) {
// m.Cmd(nfs.DIR, ice.SRC).Tables(func(value ice.Maps) {
// if kit.Ext(value[nfs.PATH]) == JS {
// fmt.Fprintln(js, `_can_name = "`+path.Join("/require", ice.Info.Make.Module, value[nfs.PATH])+`"`)
// fmt.Fprintln(js, m.Cmdx(nfs.CAT, value[nfs.PATH]))
@ -57,7 +57,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
m.Option(nfs.DIR_ROOT, dir)
for _, k := range []string{LIB, PANEL, PLUGIN} {
m.Cmd(nfs.DIR, k).Tables(func(value map[string]string) {
m.Cmd(nfs.DIR, k).Tables(func(value ice.Maps) {
if kit.Ext(value[nfs.PATH]) == CSS {
fmt.Fprintln(css, m.Cmdx(nfs.CAT, value[nfs.PATH]))
fmt.Fprintln(js, `Volcanos.meta.cache["`+path.Join(ice.PS, value[nfs.PATH])+`"] = []`)
@ -66,7 +66,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
}
fmt.Fprintln(js)
for _, k := range []string{LIB, PANEL, PLUGIN} {
m.Cmd(nfs.DIR, k).Tables(func(value map[string]string) {
m.Cmd(nfs.DIR, k).Tables(func(value ice.Maps) {
if kit.Ext(value[nfs.PATH]) == JS {
fmt.Fprintln(js, `_can_name = "`+path.Join(ice.PS, value[nfs.PATH])+`"`)
fmt.Fprintln(js, m.Cmdx(nfs.CAT, value[nfs.PATH]))
@ -134,8 +134,8 @@ const DEVPACK = "devpack"
const WEBPACK = "webpack"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
WEBPACK: {Name: "webpack path auto create remove", Help: "打包", Action: map[string]*ice.Action{
Index.Merge(&ice.Context{Commands: ice.Commands{
WEBPACK: {Name: "webpack path auto create remove", Help: "打包", Actions: ice.Actions{
mdb.CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
_webpack_cache(m.Spawn(), _volcanos(m), true)
}},

View File

@ -27,8 +27,8 @@ func _website_url(m *ice.Message, file string) string {
const ZML = nfs.ZML
func init() {
Index.Register(&ice.Context{Name: ZML, Help: "网页", Commands: map[string]*ice.Command{
ZML: {Name: "zml", Help: "网页", Action: ice.MergeAction(map[string]*ice.Action{
Index.Register(&ice.Context{Name: ZML, Help: "网页", Commands: ice.Commands{
ZML: {Name: "zml", Help: "网页", Actions: ice.MergeAction(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(mdb.PLUGIN, mdb.CREATE, nfs.ZML, m.PrefixKey())
m.Cmd(mdb.RENDER, mdb.CREATE, nfs.ZML, m.PrefixKey())
@ -38,7 +38,7 @@ func init() {
m.EchoIFrame(_website_url(m, strings.TrimPrefix(path.Join(arg[2], arg[1]), SRC_WEBSITE)))
}},
}, PlugAction())},
}, Configs: map[string]*ice.Config{
}, Configs: ice.Configs{
ZML: {Name: ZML, Help: "网页", Value: kit.Data(PLUG, kit.Dict(PREFIX, kit.Dict("# ", COMMENT), PREPARE, kit.Dict(
KEYWORD, kit.Simple(
"head", "left", "main", "foot",

View File

@ -59,15 +59,15 @@ const (
const ASSET = "asset"
func init() {
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: ice.Configs{
ASSET: {Name: ASSET, Help: "资产", Value: kit.Data(
mdb.SHORT, ACCOUNT, mdb.FIELD, "time,id,type,amount,name,text",
mdb.ALIAS, kit.Dict(FROM, ACCOUNT, TO, ACCOUNT),
)},
}, Commands: map[string]*ice.Command{
}, Commands: ice.Commands{
ASSET: {Name: "asset account id auto spend trans bonus", Help: "资产", Meta: kit.Dict(
"_trans", kit.Dict(ACCOUNT, "账户", AMOUNT, "金额", FROM, "转出", TO, "转入", "time", "时间", "name", "商家", "text", "备注"),
), Action: ice.MergeAction(map[string]*ice.Action{
), Actions: ice.MergeAction(ice.Actions{
SPEND: {Name: "spend account name amount time@date text", Help: "支出", Hand: func(m *ice.Message, arg ...string) {
_sub_amount(m, arg)
_asset_insert(m, arg[1], kit.Simple(mdb.TYPE, "支出", arg[2:])...)
@ -82,7 +82,7 @@ func init() {
}},
CHECK: {Name: "check", Help: "核算", Hand: func(m *ice.Message, arg ...string) {
if m.Option(ACCOUNT) == "" {
m.Cmd(ASSET).Table(func(index int, value map[string]string, head []string) {
m.Cmd(ASSET).Table(func(index int, value ice.Maps, head []string) {
_asset_check(m, value[ACCOUNT])
})
m.ProcessRefresh30ms()
@ -98,7 +98,7 @@ func init() {
m.PushAction(CHECK)
m.SortIntR(AMOUNT)
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
amount += kit.Int(value[AMOUNT])
count += kit.Int(value[COUNT])
})
@ -106,7 +106,7 @@ func init() {
} else {
m.PushAction(mdb.PLUGIN)
m.Table(func(index int, value map[string]string, head []string) {
m.Table(func(index int, value ice.Maps, head []string) {
amount += kit.Int(value[AMOUNT])
count++
})

Some files were not shown because too many files have changed in this diff Show More