pager

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package pager selects and runs the user's configured terminal pager.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisabledByEnv

func DisabledByEnv() bool

DisabledByEnv reports whether NO_PAGER is set. Its value is intentionally ignored, so NO_PAGER=0 has the same disabling effect as NO_PAGER=1.

func ShouldPage

func ShouldPage(mode core.PagerMode, stdoutTerminal, image bool) bool

ShouldPage reports whether text should be sent through a pager.

func Stream

func Stream(src io.Reader, mode core.PagerMode, stdoutTerminal, image bool, dst io.Writer) error

Stream writes a response to dst, using a pager when the selected mode calls for one. It never invokes a shell. This keeps PAGER arguments data rather than executable shell syntax.

func StreamContext

func StreamContext(ctx context.Context, src io.Reader, mode core.PagerMode, stdoutTerminal, image bool, dst io.Writer) error

StreamContext is Stream with cancellation for the pager subprocess.

func WriteText

func WriteText(data []byte, mode core.PagerMode, stdoutTerminal bool) error

WriteText writes text directly or through the selected pager.

func WriteTextContext

func WriteTextContext(ctx context.Context, data []byte, mode core.PagerMode, stdoutTerminal bool) error

WriteTextContext is WriteText with a cancellation context for a pager process. It is used by metadata commands so Ctrl-C also terminates a blocked pager.

Types

type Command

type Command struct {
	Program string
	Args    []string
}

Command describes a pager executable and its arguments.

func CommandFromEnv

func CommandFromEnv(getenv func(string) string) Command

CommandFromEnv parses PAGER without invoking a shell. It keeps the legacy fallback behavior for callers that only need to inspect the selected command; StreamContext uses commandFromLookup so malformed user input is reported.

Jump to

Keyboard shortcuts

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