forked from x/icebergs
opt word.spark
This commit is contained in:
parent
9300ce5da4
commit
214744e5d9
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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", `</svg>`)},
|
||||
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(`<div class="story" data-type="spark" data-name="shell" data-text="%s">`, arg[1])
|
||||
m.Echo(`<div class="story" data-type="spark" data-name="%s" data-text="%s">`, arg[0], arg[1])
|
||||
for _, l := range strings.Split(arg[1], "\n") {
|
||||
m.Echo("<div>")
|
||||
m.Echo("$ ")
|
||||
m.Echo(kit.Select("$ ", m.Conf(SPARK, kit.Keys("meta.prompt", arg[0]))))
|
||||
m.Echo("<span>")
|
||||
m.Echo(l)
|
||||
m.Echo("</span>")
|
||||
|
Loading…
x
Reference in New Issue
Block a user