package cli import ( "io" "os" "golang.org/x/term" ) // isTTY reports whether r is attached to a terminal. In production the app // passes os.Stdin, which might be a tty. In tests a bytes.Buffer is supplied // and the type assertion fails, so we correctly treat it as non-tty. func isTTY(r io.Reader) bool { f, ok := r.(*os.File) if !ok { return false } return term.IsTerminal(int(f.Fd())) }