package wiki
import (
"strings"
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/ssh"
kit "github.com/shylinux/toolkits"
)
func _spark_show(m *ice.Message, name, text string, arg ...string) {
if name == "" {
_wiki_template(m, SPARK, name, text, arg...)
return
}
prompt := kit.Select(name+"> ", m.Conf(SPARK, kit.Keym(ssh.PROMPT, name)))
m.Echo(`
`, name)
for _, l := range strings.Split(text, "\n") {
m.Echo("
")
m.Echo("")
m.Echo("").Echo(l).Echo("")
m.Echo("
")
}
m.Echo("
")
}
const (
PROMPT = "prompt"
)
const SPARK = "spark"
func init() {
Index.Merge(&ice.Context{
Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
arg := kit.Simple(args...)
if len(arg) == 1 && arg[0] != kit.SSH_BREAK {
arg = []string{kit.SSH_SHELL, arg[0]}
}
list := []string{kit.Format(``, arg[0])}
for _, l := range strings.Split(strings.Join(arg[1:], "\n"), "\n") {
switch list = append(list, "
"); arg[0] {
case kit.SSH_SHELL:
list = append(list, "")
default:
list = append(list, "")
}
list = append(list, "", l, "")
list = append(list, "
")
}
list = append(list, "
")
return strings.Join(list, "")
})
}},
SPARK: {Name: "spark [name] text", Help: "段落", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 {
m.Echo(`