From b196af799c82196b360aa792907316f76d16fe50 Mon Sep 17 00:00:00 2001 From: shylinux Date: Wed, 24 Aug 2022 07:59:55 +0800 Subject: [PATCH] opt some --- base/mdb/hash.go | 6 +++++- core/code/install.go | 2 ++ core/wiki/field.go | 3 +++ core/wiki/shell.go | 6 ++++++ misc/git/spide.go | 5 ++++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/base/mdb/hash.go b/base/mdb/hash.go index fbf48e9c..545e924a 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -223,7 +223,11 @@ func HashInputs(m *ice.Message, arg ...Any) *ice.Message { } func HashCreate(m *ice.Message, arg ...Any) string { msg := m.Spawn() - return m.Echo(msg.Cmdx(INSERT, m.PrefixKey(), "", HASH, HashArgs(msg, arg...))).Result() + args := HashArgs(msg, arg...) + if len(args) == 0 { + args = m.OptionSimple(m.Config(FIELD)) + } + return m.Echo(msg.Cmdx(INSERT, m.PrefixKey(), "", HASH, args)).Result() } func HashRemove(m *ice.Message, arg ...Any) *ice.Message { args := kit.Simple(arg) diff --git a/core/code/install.go b/core/code/install.go index d15b6896..0ac74fba 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -119,6 +119,8 @@ func _install_start(m *ice.Message, arg ...string) { switch cb := m.Optionv(PREPARE).(type) { case func(string) []string: args = append(args, cb(p)...) + case func(string, int): + cb(p, kit.Int(path.Base(p))) case func(string): cb(p) case nil: diff --git a/core/wiki/field.go b/core/wiki/field.go index f55ee944..1fd1bbfb 100644 --- a/core/wiki/field.go +++ b/core/wiki/field.go @@ -41,6 +41,9 @@ func _field_show(m *ice.Message, name, text string, arg ...string) { name = cmd.Help } }) + if len(meta) == 0 { + return + } if !aaa.Right(m.Spawn(), cmds[0]) { return } diff --git a/core/wiki/shell.go b/core/wiki/shell.go index 8637d0b7..021c5610 100644 --- a/core/wiki/shell.go +++ b/core/wiki/shell.go @@ -21,6 +21,12 @@ const SHELL = "shell" func init() { Index.Merge(&ice.Context{Commands: ice.Commands{ SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, arg ...string) { + if len(arg) == 1 { + m.Cmdy(SPARK, SHELL, arg) + } else { + m.Cmdy(SPARK, arg) + } + return arg = _name(m, arg) _shell_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...) }}, diff --git a/misc/git/spide.go b/misc/git/spide.go index 634501cd..1dfe87b3 100644 --- a/misc/git/spide.go +++ b/misc/git/spide.go @@ -108,7 +108,7 @@ func init() { } ctx.DisplayStory(m, "spide.js", mdb.FIELD, nfs.PATH, "root", arg[0]) - if len(arg) == 1 || !strings.HasSuffix(arg[1], arg[2]) { // 目录列表 + if len(arg) == 1 { // 目录列表 m.Option(nfs.DIR_DEEP, ice.TRUE) color := []string{cli.YELLOW, cli.BLUE, cli.CYAN, cli.RED} nfs.Dir(m, nfs.PATH).Tables(func(value ice.Maps) { @@ -116,6 +116,9 @@ func init() { }) return } + if arg[1] != arg[2] { + return + } // 语法解析 switch m.Option(cli.CMD_DIR, m.Option(nfs.DIR_ROOT)); kit.Ext(arg[1]) {