diff --git a/base/ssh/ssh.go b/base/ssh/ssh.go index d56905ff..20f97b3f 100644 --- a/base/ssh/ssh.go +++ b/base/ssh/ssh.go @@ -175,8 +175,10 @@ func (f *Frame) change(m *ice.Message, ls []string) []string { func (f *Frame) alias(m *ice.Message, ls []string) []string { // 命令替换 if alias, ok := m.Optionv(ice.MSG_ALIAS).(map[string]interface{}); ok { - if a := kit.Simple(alias[ls[0]]); len(a) > 0 { - ls = append(append([]string{}, a...), ls[1:]...) + if len(ls) > 0 { + if a := kit.Simple(alias[ls[0]]); len(a) > 0 { + ls = append(append([]string{}, a...), ls[1:]...) + } } } return ls diff --git a/base/tcp/tcp.go b/base/tcp/tcp.go index b0ccff65..e6df76ce 100644 --- a/base/tcp/tcp.go +++ b/base/tcp/tcp.go @@ -1,10 +1,10 @@ package tcp import ( - "github.com/shylinux/icebergs" + ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/aaa" "github.com/shylinux/icebergs/base/cli" - "github.com/shylinux/toolkits" + kit "github.com/shylinux/toolkits" "bufio" "net" @@ -15,8 +15,8 @@ import ( func _port_list(m *ice.Message) string { return "" } -func _port_get(m *ice.Message) string { - current := kit.Int(m.Conf(PORT, "meta.current")) +func _port_get(m *ice.Message, begin string) string { + current := kit.Int(kit.Select(m.Conf(PORT, "meta.current"), begin)) end := kit.Int(m.Conf(PORT, "meta.end")) if current >= end { current = kit.Int(m.Conf(PORT, "meta.begin")) @@ -109,7 +109,10 @@ var Index = &ice.Context{Name: "tcp", Help: "通信模块", }}, PORT: {Name: "port", Help: "端口", Action: map[string]*ice.Action{ "get": {Name: "get", Help: "分配端口", Hand: func(m *ice.Message, arg ...string) { - m.Echo(_port_get(m)) + m.Echo(_port_get(m, "")) + }}, + "select": {Name: "select [begin]", Help: "分配端口", Hand: func(m *ice.Message, arg ...string) { + m.Echo(_port_get(m, kit.Select("", arg, 0))) }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _port_list(m) diff --git a/core/wiki/word.go b/core/wiki/word.go index d50dcec5..bdc07cfe 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -315,7 +315,13 @@ func init() { TITLE: {Name: TITLE, Help: "标题", Value: kit.Data("template", title)}, BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data("template", brief)}, REFER: {Name: REFER, Help: "参考", Value: kit.Data("template", refer)}, - SPARK: {Name: SPARK, Help: "段落", Value: kit.Data("template", spark)}, + SPARK: {Name: SPARK, Help: "段落", Value: kit.Data( + "template", spark, + "prompt", kit.Dict( + "shell", "$ ", + "mysql", "mysql> ", + ), + )}, CHART: {Name: CHART, Help: "图表", Value: kit.Data("template", chart, "suffix", ``)}, FIELD: {Name: FIELD, Help: "插件", Value: kit.Data("template", field)}, @@ -373,12 +379,13 @@ func init() { if len(arg) == 1 { arg = []string{"", arg[0]} } - if arg[0] == "shell" { + switch arg[0] { + case "shell", "mysql": arg[1] = strings.TrimSpace(arg[1]) - m.Echo(`