util: split Iprint() into Interactive()
This commit is contained in:
parent
873ed7bc6d
commit
93c59bba65
1 changed files with 5 additions and 1 deletions
|
|
@ -86,9 +86,13 @@ func HashOf(s string) string {
|
||||||
return fmt.Sprintf("%x", h.Sum(nil))
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Interactive() bool {
|
||||||
|
return term.IsTerminal(int(os.Stderr.Fd()))
|
||||||
|
}
|
||||||
|
|
||||||
// print only if interactive
|
// print only if interactive
|
||||||
func Iprint(format string, args ...any) {
|
func Iprint(format string, args ...any) {
|
||||||
if term.IsTerminal(int(os.Stderr.Fd())) {
|
if Interactive() {
|
||||||
fmt.Fprintf(os.Stderr, format, args...)
|
fmt.Fprintf(os.Stderr, format, args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue