1
0
forked from x/icebergs
This commit is contained in:
shaoying 2021-07-28 22:55:28 +08:00
parent 5554de740b
commit 51ce14e0c1
8 changed files with 13 additions and 19 deletions

View File

@ -83,7 +83,7 @@ func _exp_true(m *ice.Message, arg string) bool {
if arg == ice.TRUE { if arg == ice.TRUE {
return true return true
} }
if arg == "false" { if arg == ice.FALSE {
return false return false
} }
if n1, e1 := strconv.ParseInt(arg, 10, 64); e1 == nil { if n1, e1 := strconv.ParseInt(arg, 10, 64); e1 == nil {

View File

@ -36,8 +36,8 @@ const ( // DIR
USR_INTSHELL = "usr/intshell" USR_INTSHELL = "usr/intshell"
USR_INSTALL = "usr/install" USR_INSTALL = "usr/install"
USR_PUBLISH = "usr/publish" USR_PUBLISH = "usr/publish"
USR_LOCAL = "usr/local"
USR_LOCAL = "usr/local"
USR_LOCAL_WORK = "usr/local/work" USR_LOCAL_WORK = "usr/local/work"
USR_LOCAL_RIVER = "usr/local/river" USR_LOCAL_RIVER = "usr/local/river"
USR_LOCAL_IMAGE = "usr/local/image" USR_LOCAL_IMAGE = "usr/local/image"

View File

@ -98,8 +98,8 @@ func init() {
m.Cmdy(nfs.DIR, "./", "time,size,line,path,link") m.Cmdy(nfs.DIR, "./", "time,size,line,path,link")
}}, }},
ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) { ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
u := kit.ParseURL(m.Option(ice.MSG_USERWEB)) u := kit.ParseURL(m.ReplaceLocalhost(m.Option(ice.MSG_USERWEB)))
host := m.ReplaceLocalhost(u.Host) host := u.Host
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(host, ":"), 1))) m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(host, ":"), 1)))
m.Option("hostport", fmt.Sprintf("%s:%s", strings.Split(host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(host, ":"), 1))) m.Option("hostport", fmt.Sprintf("%s:%s", strings.Split(host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(host, ":"), 1)))

View File

@ -375,7 +375,7 @@ func _chart_show(m *ice.Message, kind, text string, arg ...string) {
m.Option("stroke-width", "2") m.Option("stroke-width", "2")
m.Option("font-family", "monospace") m.Option("font-family", "monospace")
// 扩展参数 // 扩展参数
m.Option("compact", "false") m.Option("compact", ice.FALSE)
m.Option("padding", "10") m.Option("padding", "10")
m.Option("marginx", "10") m.Option("marginx", "10")
m.Option("marginy", "10") m.Option("marginy", "10")

View File

@ -56,7 +56,7 @@ func (m *Message) Grows(prefix string, chain interface{}, match string, value st
limit := kit.Int(m.Option("cache.limit")) limit := kit.Int(m.Option("cache.limit"))
if begin := kit.Int(m.Option("cache.begin")); begin != 0 && limit > 0 { if begin := kit.Int(m.Option("cache.begin")); begin != 0 && limit > 0 {
count := kit.Int(m.Option("cache.count", kit.Int(kit.Value(cache, "meta.count")))) count := kit.Int(m.Option("cache.count", kit.Int(kit.Value(cache, kit.Keym("count")))))
if begin > 0 { if begin > 0 {
m.Option("cache.offend", count-begin-limit) m.Option("cache.offend", count-begin-limit)
} else { } else {

View File

@ -22,18 +22,15 @@ func (m *Message) TryCatch(msg *Message, safe bool, hand ...func(msg *Message))
m.Log(LOG_WARN, "catch: %s %s", e, fileline) m.Log(LOG_WARN, "catch: %s %s", e, fileline)
m.Log("stack", msg.Format("stack")) m.Log("stack", msg.Format("stack"))
m.Log(LOG_WARN, "catch: %s %s", e, fileline) m.Log(LOG_WARN, "catch: %s %s", e, fileline)
if len(hand) > 1 { if len(hand) > 1 { // 捕获异常
// 捕获异常
m.TryCatch(msg, safe, hand[1:]...) m.TryCatch(msg, safe, hand[1:]...)
} else if !safe { } else if !safe { // 抛出异常
// 抛出异常
m.Assert(e) m.Assert(e)
} }
} }
}() }()
if len(hand) > 0 { if len(hand) > 0 { // 运行函数
// 运行函数
hand[0](msg) hand[0](msg)
} }
return m return m

View File

@ -25,7 +25,7 @@ func (m *Message) log(level string, str string, arg ...interface{}) *Message {
return m // 禁用日志 return m // 禁用日志
} }
if str = strings.TrimSpace(kit.Format(str, arg...)); Log != nil { if str = strings.TrimSpace(kit.Format(str, arg...)); Log != nil {
Log(m, m.Format("prefix"), level, str) Log(m, m.Format(kit.MDB_PREFIX), level, str)
// 日志分流 // 日志分流
} }
if m.Option("_disable_log") == TRUE { if m.Option("_disable_log") == TRUE {

View File

@ -140,8 +140,7 @@ func (m *Message) Copy(msg *Message, arg ...string) *Message {
if m == nil { if m == nil {
return m return m
} }
if len(arg) > 0 { if len(arg) > 0 { // 精确复制
// 精确复制
for _, k := range arg[1:] { for _, k := range arg[1:] {
if kit.IndexOf(m.meta[arg[0]], k) == -1 { if kit.IndexOf(m.meta[arg[0]], k) == -1 {
m.meta[arg[0]] = append(m.meta[arg[0]], k) m.meta[arg[0]] = append(m.meta[arg[0]], k)
@ -151,8 +150,7 @@ func (m *Message) Copy(msg *Message, arg ...string) *Message {
return m return m
} }
// 复制选项 for _, k := range msg.meta[MSG_OPTION] { // 复制选项
for _, k := range msg.meta[MSG_OPTION] {
if kit.IndexOf(m.meta[MSG_OPTION], k) == -1 { if kit.IndexOf(m.meta[MSG_OPTION], k) == -1 {
m.meta[MSG_OPTION] = append(m.meta[MSG_OPTION], k) m.meta[MSG_OPTION] = append(m.meta[MSG_OPTION], k)
} }
@ -163,8 +161,7 @@ func (m *Message) Copy(msg *Message, arg ...string) *Message {
} }
} }
// 复制数据 for _, k := range msg.meta[MSG_APPEND] { // 复制数据
for _, k := range msg.meta[MSG_APPEND] {
if i := kit.IndexOf(m.meta[MSG_OPTION], k); i > -1 && len(m.meta[k]) > 0 { if i := kit.IndexOf(m.meta[MSG_OPTION], k); i > -1 && len(m.meta[k]) > 0 {
m.meta[k] = m.meta[k][:0] m.meta[k] = m.meta[k][:0]
} }