formatting

package
v0.3.0-8 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSON

type JSON struct{}

JSON renders a report result as JSON

func (*JSON) Write

func (*JSON) Write(
	writer io.Writer,
	result *report.Result,
) error

type PlainFormatStrategy

type PlainFormatStrategy struct{}

PlainFormatStrategy will format report text for file or plain output and will apply no styling to the text.

func (*PlainFormatStrategy) Bold

func (*PlainFormatStrategy) Bold(str string) string

Bold returns the original string with no modification.

func (*PlainFormatStrategy) Color

func (*PlainFormatStrategy) Color(str, colorStr string) string

Color returns the original string with no modification.

type RichANSIFormatStrategy

type RichANSIFormatStrategy struct{}

RichANSIFormatStrategy will format report text for an interactive terminal using ANSI escape codes for color and font style.

func (*RichANSIFormatStrategy) Bold

Bold wraps the provided string with the ANSI escape codes for bold text.

func (*RichANSIFormatStrategy) Color

func (*RichANSIFormatStrategy) Color(str, colorStr string) string

Color wraps the provided string with the ANSI escape codes for the given color.

type Text

type Text struct {
	FormatStrategy TextFormatStrategy
}

Text renders a report result as text, using a given format strategy

func (*Text) Write

func (text *Text) Write(
	writer io.Writer,
	result *report.Result,
) error

type TextFormatStrategy

type TextFormatStrategy interface {
	Bold(str string) string
	Color(str, color string) string
}

TextFormatStrategy describes what operations a particular format must implement.

type Writer

type Writer interface {
	Write(io.Writer, *report.Result) error
}

Writer represents an object than can render a ReportResult to an io.Writer (e.g. file, stdout)

Jump to

Keyboard shortcuts

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