forked from x/icebergs
opt word.spark
This commit is contained in:
parent
9300ce5da4
commit
214744e5d9
@ -175,10 +175,12 @@ func (f *Frame) change(m *ice.Message, ls []string) []string {
|
|||||||
func (f *Frame) alias(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 alias, ok := m.Optionv(ice.MSG_ALIAS).(map[string]interface{}); ok {
|
||||||
|
if len(ls) > 0 {
|
||||||
if a := kit.Simple(alias[ls[0]]); len(a) > 0 {
|
if a := kit.Simple(alias[ls[0]]); len(a) > 0 {
|
||||||
ls = append(append([]string{}, a...), ls[1:]...)
|
ls = append(append([]string{}, a...), ls[1:]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ls
|
return ls
|
||||||
}
|
}
|
||||||
func (f *Frame) parse(m *ice.Message, line string) string {
|
func (f *Frame) parse(m *ice.Message, line string) string {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"bufio"
|
"bufio"
|
||||||
"net"
|
"net"
|
||||||
@ -15,8 +15,8 @@ import (
|
|||||||
func _port_list(m *ice.Message) string {
|
func _port_list(m *ice.Message) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
func _port_get(m *ice.Message) string {
|
func _port_get(m *ice.Message, begin string) string {
|
||||||
current := kit.Int(m.Conf(PORT, "meta.current"))
|
current := kit.Int(kit.Select(m.Conf(PORT, "meta.current"), begin))
|
||||||
end := kit.Int(m.Conf(PORT, "meta.end"))
|
end := kit.Int(m.Conf(PORT, "meta.end"))
|
||||||
if current >= end {
|
if current >= end {
|
||||||
current = kit.Int(m.Conf(PORT, "meta.begin"))
|
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{
|
PORT: {Name: "port", Help: "端口", Action: map[string]*ice.Action{
|
||||||
"get": {Name: "get", Help: "分配端口", Hand: func(m *ice.Message, arg ...string) {
|
"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) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_port_list(m)
|
_port_list(m)
|
||||||
|
@ -315,7 +315,13 @@ func init() {
|
|||||||
TITLE: {Name: TITLE, Help: "标题", Value: kit.Data("template", title)},
|
TITLE: {Name: TITLE, Help: "标题", Value: kit.Data("template", title)},
|
||||||
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data("template", brief)},
|
BRIEF: {Name: BRIEF, Help: "摘要", Value: kit.Data("template", brief)},
|
||||||
REFER: {Name: REFER, Help: "参考", Value: kit.Data("template", refer)},
|
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>`)},
|
CHART: {Name: CHART, Help: "图表", Value: kit.Data("template", chart, "suffix", `</svg>`)},
|
||||||
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data("template", field)},
|
FIELD: {Name: FIELD, Help: "插件", Value: kit.Data("template", field)},
|
||||||
@ -373,12 +379,13 @@ func init() {
|
|||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
arg = []string{"", arg[0]}
|
arg = []string{"", arg[0]}
|
||||||
}
|
}
|
||||||
if arg[0] == "shell" {
|
switch arg[0] {
|
||||||
|
case "shell", "mysql":
|
||||||
arg[1] = strings.TrimSpace(arg[1])
|
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") {
|
for _, l := range strings.Split(arg[1], "\n") {
|
||||||
m.Echo("<div>")
|
m.Echo("<div>")
|
||||||
m.Echo("$ ")
|
m.Echo(kit.Select("$ ", m.Conf(SPARK, kit.Keys("meta.prompt", arg[0]))))
|
||||||
m.Echo("<span>")
|
m.Echo("<span>")
|
||||||
m.Echo(l)
|
m.Echo(l)
|
||||||
m.Echo("</span>")
|
m.Echo("</span>")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user