From 73d66b7c3721af0947f08064c530ca2fa6986202 Mon Sep 17 00:00:00 2001 From: shylinux Date: Mon, 24 Apr 2023 16:02:01 +0800 Subject: [PATCH] opt some --- base/ctx/config.go | 11 ++++++++++- base/gdb/signal.go | 2 +- base/nfs/cat.go | 2 +- core/code/binpack.go | 6 ++++-- misc/git/status.go | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/base/ctx/config.go b/base/ctx/config.go index 084fc6e4..c5c16030 100644 --- a/base/ctx/config.go +++ b/base/ctx/config.go @@ -95,7 +95,16 @@ func _config_only(v ice.Any, arg ...string) bool { if len(v) > len(arg) { return false } - for k := range v { + for k, v := range v { + if v, ok := v.(ice.Map); ok && len(v) == 0 { + continue + } else { + for k := range v { + if kit.IsIn(k, "important") && len(v) > 1 { + return false + } + } + } if kit.IndexOf(arg, k) == -1 { return false } diff --git a/base/gdb/signal.go b/base/gdb/signal.go index fd6f254d..20f9517f 100644 --- a/base/gdb/signal.go +++ b/base/gdb/signal.go @@ -71,7 +71,7 @@ func init() { KILL: {Name: "kill pid signal", Help: "结束", Hand: func(m *ice.Message, arg ...string) { _signal_process(m, m.Option(PID), syscall.Signal(kit.Int(kit.Select("9", m.Option(SIGNAL))))) }}, - }, mdb.HashAction(mdb.SHORT, SIGNAL, mdb.FIELD, "time,signal,name,cmd", mdb.ACTION, HAPPEN)), Hand: func(m *ice.Message, arg ...string) { + }, mdb.HashAction(mdb.SHORT, SIGNAL, mdb.FIELD, "time,signal,name,cmd", mdb.ACTION, HAPPEN), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Sort(SIGNAL) }}, }) diff --git a/base/nfs/cat.go b/base/nfs/cat.go index 3128ea5f..ae1a742d 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -131,7 +131,7 @@ func Template(m templateMessage, p string, arg ...ice.Any) string { return kit.Renders(kit.Format(TemplateText(m, p), arg...), m) } func TemplateText(m templateMessage, p string) string { - return strings.TrimSpace(m.Cmdx(CAT, path.Join(m.PrefixKey(), path.Base(p)), kit.Dict(DIR_ROOT, ice.SRC_TEMPLATE))) + return m.Cmdx(CAT, path.Join(m.PrefixKey(), path.Base(p)), kit.Dict(DIR_ROOT, ice.SRC_TEMPLATE)) } func IsSourceFile(m *ice.Message, ext string) bool { return mdb.Conf(m, Prefix(CAT), kit.Keym(SOURCE, ext)) == ice.TRUE diff --git a/core/code/binpack.go b/core/code/binpack.go index 871518b6..9f58ca29 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -10,6 +10,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" + "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" @@ -47,8 +48,9 @@ func _binpack_all(m *ice.Message) { if w, p, e := nfs.CreateFile(m, ice.SRC_BINPACK_GO); m.Assert(e) { defer w.Close() defer m.Echo(p) - fmt.Fprint(w, nfs.Template(m, ice.SRC_BINPACK_GO)) - defer fmt.Fprint(w, nfs.Template(m, "binpack_end.go")) + fmt.Fprintln(w, nfs.Template(m, ice.SRC_BINPACK_GO)) + defer fmt.Fprintln(w, nfs.Template(m, "binpack_end.go")) + defer fmt.Fprint(w, lex.TB) nfs.OptionFiles(m, nfs.DiskFile) for _, p := range []string{ice.USR_VOLCANOS, ice.USR_INTSHELL, ice.SRC} { _binpack_dir(m, w, p) diff --git a/misc/git/status.go b/misc/git/status.go index d0a34b9f..89b8db54 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -164,7 +164,7 @@ func init() { } m.Push(mdb.TEXT, strings.Join(text, ", ")) }}, - }, gdb.EventAction(web.DREAM_TABLES), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + }, gdb.EventAction(web.DREAM_TABLES), aaa.RoleAction(), mdb.ImportantDataAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == ctx.ACTION { m.Cmdy(REPOS, arg) } else if config, err := config.LoadConfig(config.GlobalScope); err == nil && config.User.Email == "" && mdb.Config(m, aaa.EMAIL) == "" {