forked from x/icebergs
opt some
This commit is contained in:
parent
ccea229435
commit
56576f958f
@ -139,7 +139,7 @@ func Save(m *ice.Message, arg ...string) *ice.Message {
|
|||||||
for i, k := range arg {
|
for i, k := range arg {
|
||||||
arg[i] = m.Prefix(k)
|
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 {
|
func Load(m *ice.Message, arg ...string) *ice.Message {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
@ -150,7 +150,7 @@ func Load(m *ice.Message, arg ...string) *ice.Message {
|
|||||||
for i, k := range arg {
|
for i, k := range arg {
|
||||||
arg[i] = m.Prefix(k)
|
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 {
|
func ConfAction(args ...ice.Any) ice.Actions {
|
||||||
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...)}
|
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...)}
|
||||||
|
@ -158,7 +158,7 @@ func init() {
|
|||||||
if p := path.Join(arg[0], up[1]); m.Option(ice.MSG_USERPOD) == "" {
|
if p := path.Join(arg[0], up[1]); m.Option(ice.MSG_USERPOD) == "" {
|
||||||
m.Cmdy(CACHE, WATCH, up[0], p) // 本机文件
|
m.Cmdy(CACHE, WATCH, up[0], p) // 本机文件
|
||||||
} else { // 下发文件
|
} 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) {
|
}, 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
31
conf.go
@ -18,22 +18,10 @@ const (
|
|||||||
FAILURE = "failure"
|
FAILURE = "failure"
|
||||||
PROCESS = "process"
|
PROCESS = "process"
|
||||||
|
|
||||||
INIT = "init"
|
|
||||||
EXIT = "exit"
|
|
||||||
QUIT = "quit"
|
|
||||||
SAVE = "save"
|
|
||||||
LOAD = "load"
|
|
||||||
|
|
||||||
AUTO = "auto"
|
AUTO = "auto"
|
||||||
VIEW = "view"
|
HTTP = "http"
|
||||||
LIST = "list"
|
LIST = "list"
|
||||||
BACK = "back"
|
BACK = "back"
|
||||||
EXEC = "exec"
|
|
||||||
|
|
||||||
SHOW = "show"
|
|
||||||
PLAY = "play"
|
|
||||||
HELP = "help"
|
|
||||||
HTTP = "http"
|
|
||||||
|
|
||||||
BASE = "base"
|
BASE = "base"
|
||||||
CORE = "core"
|
CORE = "core"
|
||||||
@ -44,15 +32,15 @@ const (
|
|||||||
OPS = "ops"
|
OPS = "ops"
|
||||||
ICE = "ice"
|
ICE = "ice"
|
||||||
|
|
||||||
ENV = "env"
|
|
||||||
RUN = "run"
|
|
||||||
ERR = "err"
|
|
||||||
|
|
||||||
POD = "pod"
|
POD = "pod"
|
||||||
CTX = "ctx"
|
CTX = "ctx"
|
||||||
CMD = "cmd"
|
CMD = "cmd"
|
||||||
ARG = "arg"
|
ARG = "arg"
|
||||||
|
|
||||||
|
ENV = "env"
|
||||||
|
RUN = "run"
|
||||||
RES = "res"
|
RES = "res"
|
||||||
|
ERR = "err"
|
||||||
)
|
)
|
||||||
const ( // MOD
|
const ( // MOD
|
||||||
MOD_DIR = 0750
|
MOD_DIR = 0750
|
||||||
@ -178,17 +166,16 @@ const ( // MSG
|
|||||||
MSG_SOURCE = "_source"
|
MSG_SOURCE = "_source"
|
||||||
MSG_TARGET = "_target"
|
MSG_TARGET = "_target"
|
||||||
MSG_HANDLE = "_handle"
|
MSG_HANDLE = "_handle"
|
||||||
|
MSG_DAEMON = "_daemon"
|
||||||
|
MSG_UPLOAD = "_upload"
|
||||||
|
MSG_ACTION = "_action"
|
||||||
|
MSG_STATUS = "_status"
|
||||||
|
|
||||||
MSG_ALIAS = "_alias"
|
MSG_ALIAS = "_alias"
|
||||||
MSG_SCRIPT = "_script"
|
MSG_SCRIPT = "_script"
|
||||||
MSG_OUTPUT = "_output"
|
MSG_OUTPUT = "_output"
|
||||||
MSG_ARGS = "_args"
|
MSG_ARGS = "_args"
|
||||||
|
|
||||||
MSG_UPLOAD = "_upload"
|
|
||||||
MSG_DAEMON = "_daemon"
|
|
||||||
MSG_ACTION = "_action"
|
|
||||||
MSG_STATUS = "_status"
|
|
||||||
|
|
||||||
MSG_PROCESS = "_process"
|
MSG_PROCESS = "_process"
|
||||||
MSG_DISPLAY = "_display"
|
MSG_DISPLAY = "_display"
|
||||||
MSG_TOOLKIT = "_toolkit"
|
MSG_TOOLKIT = "_toolkit"
|
||||||
|
@ -37,7 +37,7 @@ func _xterm_get(m *ice.Message, h string) _xterm {
|
|||||||
m.Assert(h != "")
|
m.Assert(h != "")
|
||||||
|
|
||||||
t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE)
|
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 {
|
return mdb.HashTarget(m, h, func() ice.Any {
|
||||||
ls := kit.Split(kit.Select(nfs.SH, t))
|
ls := kit.Split(kit.Select(nfs.SH, t))
|
||||||
cmd := exec.Command(cli.SystemFind(m, ls[0]), ls[1:]...)
|
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)
|
buf := make([]byte, ice.MOD_BUFS)
|
||||||
for {
|
for {
|
||||||
if n, e := tty.Read(buf); !m.Warn(e) && e == nil {
|
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.Option(mdb.TEXT, string(buf[:n]))
|
||||||
m.Debug("what %v", m.FormatMeta())
|
m.Debug("what %v", m.FormatMeta())
|
||||||
web.PushNoticeGrow(m)
|
web.PushNoticeGrow(m)
|
||||||
|
@ -93,7 +93,7 @@ func init() {
|
|||||||
ice.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
ice.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(arg[0], ice.RUN, arg[2:])
|
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) {
|
}, ctx.CmdAction(), mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
arg = append(arg, "src/")
|
arg = append(arg, "src/")
|
||||||
|
10
exec.go
10
exec.go
@ -17,12 +17,9 @@ func (m *Message) TryCatch(msg *Message, silent bool, hand ...func(msg *Message)
|
|||||||
case nil:
|
case nil:
|
||||||
default:
|
default:
|
||||||
fileline := m.FormatStack(2, 1)
|
fileline := m.FormatStack(2, 1)
|
||||||
m.Log(LOG_WARN, "catch: %s %s", e, fileline)
|
m.Log(LOG_WARN, "catch: %s %s", e, fileline).Log("chain", msg.FormatChain())
|
||||||
m.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)
|
m.Log(LOG_WARN, "catch: %s %s", e, fileline).Result(ErrWarn, e, " ", fileline)
|
||||||
m.Log("stack", msg.FormatStack(2, 100))
|
|
||||||
m.Log(LOG_WARN, "catch: %s %s", e, fileline)
|
|
||||||
m.Result(ErrWarn, e, " ", fileline)
|
|
||||||
if len(hand) > 1 {
|
if len(hand) > 1 {
|
||||||
m.TryCatch(msg, silent, hand[1:]...)
|
m.TryCatch(msg, silent, hand[1:]...)
|
||||||
} else if !silent {
|
} else if !silent {
|
||||||
@ -30,7 +27,6 @@ func (m *Message) TryCatch(msg *Message, silent bool, hand ...func(msg *Message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if len(hand) > 0 {
|
if len(hand) > 0 {
|
||||||
hand[0](msg)
|
hand[0](msg)
|
||||||
}
|
}
|
||||||
|
7
init.go
7
init.go
@ -51,6 +51,13 @@ func (f *Frame) Close(m *Message, arg ...string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
INIT = "init"
|
||||||
|
HELP = "help"
|
||||||
|
EXIT = "exit"
|
||||||
|
QUIT = "quit"
|
||||||
|
)
|
||||||
|
|
||||||
var Index = &Context{Name: ICE, Help: "冰山模块", Configs: Configs{
|
var Index = &Context{Name: ICE, Help: "冰山模块", Configs: Configs{
|
||||||
HELP: {Value: kit.Data(INDEX, Info.Help)},
|
HELP: {Value: kit.Data(INDEX, Info.Help)},
|
||||||
}, Commands: Commands{
|
}, Commands: Commands{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user