1
0
forked from x/icebergs
icebergs/base/ssh/render.go
2022-11-26 19:35:27 +08:00

30 lines
540 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:
if len(args) > 0 {
msg.Resultv(args)
}
res = msg.Result()
case ice.RENDER_VOID:
return res
default:
if res = msg.Result(); res == "" {
res = msg.Table().Result()
}
}
if fmt.Fprint(msg.O, res); !strings.HasSuffix(res, ice.NL) {
fmt.Fprint(msg.O, ice.NL)
}
return res
}