term

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 2 Imported by: 4

Documentation

Overview

Package term implements a unified way to present output.

Index

Constants

This section is empty.

Variables

Predefined colors for use with Coloured.

Functions

This section is empty.

Types

type Basic

type Basic struct {
	Writer      io.Writer
	ErrorWriter io.Writer
	Verbose     bool
}

Basic writes messages to a writer. If an error writer is provided it is used for error messages.

func (Basic) Error

func (b Basic) Error(msg string)

Error writes error messages.

func (Basic) Info

func (b Basic) Info(msg string)

Info writes information messages.

func (Basic) Output

func (b Basic) Output(msg string)

Output writes general messages that are suppressed when not in verbose mode.

func (Basic) Warning

func (b Basic) Warning(msg string)

Warning writes warning messages.

type Colored

type Colored struct {
	OutputColor  *color.Color
	InfoColor    *color.Color
	WarningColor *color.Color
	ErrorColor   *color.Color
	Term         Term
}

Colored writer coloured messages to the underlying term.

func (Colored) Error

func (c Colored) Error(msg string)

Error writes error messages.

func (Colored) Info

func (c Colored) Info(msg string)

Info writes information messages.

func (Colored) Output

func (c Colored) Output(msg string)

Output writes general messages.

func (Colored) Warning

func (c Colored) Warning(msg string)

Warning writes warning messages.

type Prefixed

type Prefixed struct {
	OutputPrefix  string
	InfoPrefix    string
	WarningPrefix string
	ErrorPrefix   string
	Term          Term
}

Prefixed writes prefixed messages to the underlying term.

func (Prefixed) Error

func (p Prefixed) Error(msg string)

Error writes error messages.

func (Prefixed) Info

func (p Prefixed) Info(msg string)

Info writes information messages.

func (Prefixed) Output

func (p Prefixed) Output(msg string)

Output writes general messages.

func (Prefixed) Warning

func (p Prefixed) Warning(msg string)

Warning writes warning messages.

type Term

type Term interface {
	Output(msg string)
	Info(msg string)
	Warning(msg string)
	Error(msg string)
}

Term represents an object that can output to the terminal.

Jump to

Keyboard shortcuts

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