util: split Iprint() into Interactive()

This commit is contained in:
Jeremy Baxter 2026-01-10 20:23:05 +13:00
parent 873ed7bc6d
commit 93c59bba65

View file

@ -86,9 +86,13 @@ func HashOf(s string) string {
return fmt.Sprintf("%x", h.Sum(nil))
}
func Interactive() bool {
return term.IsTerminal(int(os.Stderr.Fd()))
}
// print only if interactive
func Iprint(format string, args ...any) {
if term.IsTerminal(int(os.Stderr.Fd())) {
if Interactive() {
fmt.Fprintf(os.Stderr, format, args...)
}
}