1
0
forked from x/icebergs
This commit is contained in:
harveyshao 2022-11-01 20:00:39 +08:00
parent ccea229435
commit 56576f958f
7 changed files with 25 additions and 35 deletions

View File

@ -139,7 +139,7 @@ func Save(m *ice.Message, arg ...string) *ice.Message {
for i, k := range arg {
arg[i] = m.Prefix(k)
}
return m.Cmd(CONFIG, ice.SAVE, m.Prefix(nfs.JSON), arg)
return m.Cmd(CONFIG, SAVE, m.Prefix(nfs.JSON), arg)
}
func Load(m *ice.Message, arg ...string) *ice.Message {
if len(arg) == 0 {
@ -150,7 +150,7 @@ func Load(m *ice.Message, arg ...string) *ice.Message {
for i, k := range arg {
arg[i] = m.Prefix(k)
}
return m.Cmd(CONFIG, ice.LOAD, m.Prefix(nfs.JSON), arg)
return m.Cmd(CONFIG, LOAD, m.Prefix(nfs.JSON), arg)
}
func ConfAction(args ...ice.Any) ice.Actions {
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...)}

View File

@ -158,7 +158,7 @@ func init() {
if p := path.Join(arg[0], up[1]); m.Option(ice.MSG_USERPOD) == "" {
m.Cmdy(CACHE, WATCH, up[0], p) // 本机文件
} else { // 下发文件
m.Cmdy(SPIDE, ice.DEV, ice.SAVE, p, SPIDE_GET, MergeURL2(m, path.Join(SHARE_CACHE, up[0])))
m.Cmdy(SPIDE, ice.DEV, nfs.SAVE, p, SPIDE_GET, MergeURL2(m, path.Join(SHARE_CACHE, up[0])))
}
}},
}, mdb.HashAction(mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,size,type,name,text,file")), Hand: func(m *ice.Message, arg ...string) {

31
conf.go
View File

@ -18,22 +18,10 @@ const (
FAILURE = "failure"
PROCESS = "process"
INIT = "init"
EXIT = "exit"
QUIT = "quit"
SAVE = "save"
LOAD = "load"
AUTO = "auto"
VIEW = "view"
HTTP = "http"
LIST = "list"
BACK = "back"
EXEC = "exec"
SHOW = "show"
PLAY = "play"
HELP = "help"
HTTP = "http"
BASE = "base"
CORE = "core"
@ -44,15 +32,15 @@ const (
OPS = "ops"
ICE = "ice"
ENV = "env"
RUN = "run"
ERR = "err"
POD = "pod"
CTX = "ctx"
CMD = "cmd"
ARG = "arg"
ENV = "env"
RUN = "run"
RES = "res"
ERR = "err"
)
const ( // MOD
MOD_DIR = 0750
@ -178,17 +166,16 @@ const ( // MSG
MSG_SOURCE = "_source"
MSG_TARGET = "_target"
MSG_HANDLE = "_handle"
MSG_DAEMON = "_daemon"
MSG_UPLOAD = "_upload"
MSG_ACTION = "_action"
MSG_STATUS = "_status"
MSG_ALIAS = "_alias"
MSG_SCRIPT = "_script"
MSG_OUTPUT = "_output"
MSG_ARGS = "_args"
MSG_UPLOAD = "_upload"
MSG_DAEMON = "_daemon"
MSG_ACTION = "_action"
MSG_STATUS = "_status"
MSG_PROCESS = "_process"
MSG_DISPLAY = "_display"
MSG_TOOLKIT = "_toolkit"

View File

@ -37,7 +37,7 @@ func _xterm_get(m *ice.Message, h string) _xterm {
m.Assert(h != "")
t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE)
mdb.HashModify(m, ice.VIEW, m.Option(ice.MSG_DAEMON))
mdb.HashModify(m, "view", m.Option(ice.MSG_DAEMON))
return mdb.HashTarget(m, h, func() ice.Any {
ls := kit.Split(kit.Select(nfs.SH, t))
cmd := exec.Command(cli.SystemFind(m, ls[0]), ls[1:]...)
@ -53,7 +53,7 @@ func _xterm_get(m *ice.Message, h string) _xterm {
buf := make([]byte, ice.MOD_BUFS)
for {
if n, e := tty.Read(buf); !m.Warn(e) && e == nil {
m.Option(ice.MSG_DAEMON, mdb.HashSelectField(m, h, ice.VIEW))
m.Option(ice.MSG_DAEMON, mdb.HashSelectField(m, h, "view"))
m.Option(mdb.TEXT, string(buf[:n]))
m.Debug("what %v", m.FormatMeta())
web.PushNoticeGrow(m)

View File

@ -93,7 +93,7 @@ func init() {
ice.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(arg[0], ice.RUN, arg[2:])
}},
ice.PLAY: {Name: "play", Help: "演示"},
"play": {Name: "play", Help: "演示"},
}, ctx.CmdAction(), mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 {
arg = append(arg, "src/")

10
exec.go
View File

@ -17,12 +17,9 @@ func (m *Message) TryCatch(msg *Message, silent bool, hand ...func(msg *Message)
case nil:
default:
fileline := m.FormatStack(2, 1)
m.Log(LOG_WARN, "catch: %s %s", e, fileline)
m.Log("chain", msg.FormatChain())
m.Log(LOG_WARN, "catch: %s %s", e, fileline)
m.Log("stack", msg.FormatStack(2, 100))
m.Log(LOG_WARN, "catch: %s %s", e, fileline)
m.Result(ErrWarn, e, " ", fileline)
m.Log(LOG_WARN, "catch: %s %s", e, fileline).Log("chain", msg.FormatChain())
m.Log(LOG_WARN, "catch: %s %s", e, fileline).Log("stack", msg.FormatStack(2, 100))
m.Log(LOG_WARN, "catch: %s %s", e, fileline).Result(ErrWarn, e, " ", fileline)
if len(hand) > 1 {
m.TryCatch(msg, silent, hand[1:]...)
} else if !silent {
@ -30,7 +27,6 @@ func (m *Message) TryCatch(msg *Message, silent bool, hand ...func(msg *Message)
}
}
}()
if len(hand) > 0 {
hand[0](msg)
}

View File

@ -51,6 +51,13 @@ func (f *Frame) Close(m *Message, arg ...string) bool {
return true
}
const (
INIT = "init"
HELP = "help"
EXIT = "exit"
QUIT = "quit"
)
var Index = &Context{Name: ICE, Help: "冰山模块", Configs: Configs{
HELP: {Value: kit.Data(INDEX, Info.Help)},
}, Commands: Commands{