Documentation
¶
Overview ¶
Package interactive provides TTY-related helpers shared between the cli and strategy packages without inducing an import cycle (strategy cannot import cli).
Index ¶
Constants ¶
const EnvTestTTY = "ENTIRE_TEST_TTY"
EnvTestTTY is the env-var name for the force-interactive test override.
- EnvTestTTY=1 → CanPromptInteractively returns true.
- EnvTestTTY set to any other value → returns false.
- EnvTestTTY unset → real detection via testing.Testing(), agent sentinels, CI, then /dev/tty probe.
Variables ¶
This section is empty.
Functions ¶
func CanPromptInteractively ¶
func CanPromptInteractively() bool
CanPromptInteractively reports whether interactive confirmation prompts (huh forms, yes/no questions, etc.) can be shown. Returns false in CI, agent subprocesses that inherit a TTY but can't respond to prompts, and other environments without a controlling TTY.
Precedence (first match wins):
- EnvTestTTY=1 forces interactive ON; any other non-empty value forces OFF.
- testing.Testing() — `go test` runs default to OFF so in-process tests don't hang on developer terminals that happen to have a real /dev/tty. Subprocess tests must spawn via execx.NonInteractive (or set EnvTestTTY).
- Agent sentinels — vendor-set by agent subprocesses.
- CI=<non-empty-non-false> — de-facto CI convention.
- /dev/tty probe.
func IsTerminalWriter ¶
IsTerminalWriter reports whether w is an *os.File backed by a terminal. Use for deciding on color, pager, progress bars, or other writer-scoped TTY formatting. For "can I prompt the user?" use CanPromptInteractively.
func UnderTest ¶ added in v0.6.0
func UnderTest() bool
UnderTest reports whether the process is running in a test context — either inside `go test` (testing.Testing()) or with EnvTestTTY explicitly set. Use to skip operations that read from the real terminal (e.g. opening /dev/tty) even when CanPromptInteractively() returns true.
Types ¶
This section is empty.