1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00
icebergs/base/ssh/render.go
2023-10-19 21:07:52 +08:00

33 lines
655 B
Go

package ssh
import (
"fmt"
"strings"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/lex"
kit "shylinux.com/x/toolkits"
)
func Render(m *ice.Message, cmd string, arg ...ice.Any) (res string) {
switch args := kit.Simple(arg...); cmd {
case ice.RENDER_RESULT:
kit.If(len(args) > 0, func() { m.Resultv(args) })
res = m.Result()
case ice.RENDER_VOID:
return res
default:
if res = m.Result(); res == "" {
if m.IsCliUA() {
res = m.TableEchoWithStatus().Result()
} else {
res = m.TableEcho().Result()
}
}
}
if fmt.Fprint(m.O, res); !strings.HasSuffix(res, lex.NL) {
fmt.Fprint(m.O, lex.NL)
}
return res
}