console

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package console reports whether wb is attached to a human terminal.

wb is driven by AI agents and CI at least as often as by people. Neither has a terminal, neither can answer a prompt, and both give up after a deadline, so a command that waits for input it will never receive is indistinguishable from a crash. Every interactive affordance — live progress UIs, draining stdin, anything that assumes a human is watching — must therefore be gated on a real terminal rather than assumed, and must degrade to plain, terminating output when there is none.

Index

Constants

View Source
const EnvDisable = "WB_NON_INTERACTIVE"

EnvDisable names the environment variable that forces non-interactive behavior even when a terminal is present. Agents that allocate a pty (so that TTY detection alone would report a human) set it to opt out.

Variables

This section is empty.

Functions

func CommandEnv

func CommandEnv(base []string) []string

CommandEnv returns base extended with the settings above.

A GIT_SSH_COMMAND already present in base is left untouched: the user may have configured a specific key or proxy there, and silently replacing it would break their setup in a way that looks like an authentication failure.

func Disabled

func Disabled() bool

Disabled reports whether the environment forbids interactive behavior. Any value other than an explicit false ("0", "false") counts as set, so WB_NON_INTERACTIVE=1 and WB_NON_INTERACTIVE=true both work.

func Env

func Env() []string

Env returns the current process environment with the same settings applied.

func Interactive

func Interactive(out any, forced bool) bool

Interactive reports whether wb may use a terminal-only affordance on the given output stream: the stream must be a terminal, the caller must not have asked for non-interactive mode, and the environment must not forbid it.

func IsTerminal

func IsTerminal(stream any) bool

IsTerminal reports whether stream is an open terminal device.

It accepts any value so that callers holding an io.Reader or io.Writer can ask without a type switch of their own. Anything that is not an *os.File — a pipe, a bytes.Buffer, a test double, a nil interface — is never a terminal, which is the safe answer: it makes callers choose the non-blocking path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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