output

package
v0.0.0-...-b25413c Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OsPrinter = stdPrinter{OsInOut{}} //nolint:gochecknoglobals

Functions

func WithContext

func WithContext(ctx context.Context, p Printer) context.Context

Types

type InputOutput

type InputOutput interface {
	InOrStdin() io.Reader
	OutOrStdout() io.Writer
	ErrOrStderr() io.Writer
}

type OsInOut

type OsInOut struct{}

func (OsInOut) ErrOrStderr

func (o OsInOut) ErrOrStderr() io.Writer

func (OsInOut) InOrStdin

func (o OsInOut) InOrStdin() io.Reader

func (OsInOut) OutOrStdout

func (o OsInOut) OutOrStdout() io.Writer

type Printer

type Printer interface {
	Print(i ...any)
	Println(i ...any)
	Printf(format string, i ...any)

	PrintErr(i ...any)
	PrintErrln(i ...any)
	PrintErrf(format string, i ...any)

	InputOutput
}

func PrinterFrom

func PrinterFrom(ctx context.Context) Printer

type TestOutputs

type TestOutputs struct {
	Out, Err *bytes.Buffer
}

func (TestOutputs) ErrOrStderr

func (t TestOutputs) ErrOrStderr() io.Writer

func (TestOutputs) OutOrStdout

func (t TestOutputs) OutOrStdout() io.Writer

type TestPrinter

type TestPrinter struct {
	// contains filtered or unexported fields
}

func NewTestPrinter

func NewTestPrinter() TestPrinter

func NewTestPrinterWithAnswers

func NewTestPrinterWithAnswers(answers []string) TestPrinter

func NewTestPrinterWithInput

func NewTestPrinterWithInput(input io.Reader) TestPrinter

func (TestPrinter) Outputs

func (p TestPrinter) Outputs() TestOutputs

func (TestPrinter) Print

func (p TestPrinter) Print(i ...any)

func (TestPrinter) PrintErr

func (p TestPrinter) PrintErr(i ...any)

func (TestPrinter) PrintErrf

func (p TestPrinter) PrintErrf(format string, i ...any)

func (TestPrinter) PrintErrln

func (p TestPrinter) PrintErrln(i ...any)

func (TestPrinter) Printf

func (p TestPrinter) Printf(format string, i ...any)

func (TestPrinter) Println

func (p TestPrinter) Println(i ...any)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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