1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
icebergs/base/ssh/render.go
2023-03-28 14:21:27 +08:00

28 lines
552 B
Go

package ssh
import (
"fmt"
"strings"
ice "shylinux.com/x/icebergs"
kit "shylinux.com/x/toolkits"
)
func Render(msg *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() { msg.Resultv(args) })
res = msg.Result()
case ice.RENDER_VOID:
return res
default:
if res = msg.Result(); res == "" {
res = msg.TableEcho().Result()
}
}
if fmt.Fprint(msg.O, res); !strings.HasSuffix(res, ice.NL) {
fmt.Fprint(msg.O, ice.NL)
}
return res
}