term

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package term decides what the CLI may do with the user's terminal: is a stream a TTY, may it carry color, may we prompt. Every package asks here instead of calling isatty itself, so NO_COLOR, CLICOLOR=0 and --no-color are honored everywhere at once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Color

func Color(w io.Writer) bool

Color reports whether w may carry ANSI color and styling.

func IsTerminal

func IsTerminal(w io.Writer) bool

IsTerminal reports whether w is a terminal. Writers that aren't files (test buffers, captured output) are not.

func NoColor

func NoColor() bool

NoColor reports whether color is switched off: --no-color, a non-empty NO_COLOR (https://no-color.org) or CLICOLOR=0.

func SetNoColor

func SetNoColor(v bool)

SetNoColor records --no-color.

func StderrIsTerminal

func StderrIsTerminal() bool

StderrIsTerminal reports whether progress, spinners and hints meant for a person may be written to stderr.

func StdinIsTerminal

func StdinIsTerminal() bool

StdinIsTerminal reports whether the CLI may prompt: stdin is a terminal.

Types

type Forced

type Forced struct{ io.Writer }

Forced marks a writer whose reader is known to be a terminal even though the writer itself isn't one, such as the stdin pipe of `less -R`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL