environment

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package environment owns CLI streams and terminal state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Streams

type Streams struct {
	Logger  *slog.Logger
	Command string
	In      io.Reader
	Out     io.Writer
	Err     io.Writer

	// InIsTerminal 标记 stdin 是否为交互终端;由根命令入口探测,测试可显式设置。
	// 非 TTY stdin 是管道/批处理输入的信号,命令据此选择输入分类。
	InIsTerminal bool

	// OutIsTerminal 标记 stdout 是否为交互终端;由根命令入口探测,测试可显式
	// 设置。非 TTY stdout 时默认输出稳定记录流(一行一个 ref/URI),TTY 时
	// 使用人类文本渲染。显式 --json/--ndjson 不受此标记影响。
	OutIsTerminal bool
}

Streams 保存调用方提供的标准输入、标准输出和错误输出。

func NewStreams

func NewStreams(in io.Reader, out, err io.Writer) *Streams

NewStreams 构造 Streams。

func (*Streams) Diagnostics

func (s *Streams) Diagnostics(level slog.Level) io.Writer

Diagnostics keeps stderr notes in the selected log format while preserving Err's identity.

func (*Streams) Failure

func (s *Streams) Failure(err error, attrs ...slog.Attr) error

Failure reports using the current stderr, including callers that replace streams after construction.

Jump to

Keyboard shortcuts

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