6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-25 00:08:26 +00:00

Fix terminal detection and avoid colors when not a terminal

This commit is contained in:
James Mills 2022-03-24 01:41:59 +10:00
parent 6f9862e6f4
commit 4c9da17db6

@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/net/context"
"go.mills.io/saltyim"
@ -91,6 +92,10 @@ func read(me *saltyim.Addr, identity string, prehook, posthook string, args ...s
}()
for msg := range cli.Read(ctx, prehook, posthook) {
fmt.Println(saltyim.FormatMessage(msg))
if terminal.IsTerminal(syscall.Stdin) {
fmt.Println(saltyim.FormatMessage(msg))
} else {
fmt.Println(msg)
}
}
}