prettyprint

package
v2.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// SingleLine will show you only as much detail as fits on a single good line.
	SingleLine DetailLevel = "_sgl"
	// Medium is a small amount of detail, but that runs on more than one line. Most likely
	// it will be two lines long. I just didn't want to guarantee that.
	Medium = "_medium"
	// Full is the usual level of detail for a 'show' command. A nice, multi-line thing
	// that contains all the detail a normal person could ever need.
	Full = "_full"
)

Variables

View Source
var Funcs = templateFuncMap

Funcs is not for general usage, only while in transition to PrettyPrint.

Functions

func Run

func Run(wr io.Writer, templates string, templateToExecute string, object interface{}) error

Run is a convenience function for running templates with the standard prettyprint functions

func RunTests

func RunTests(t *testing.T, tests []Test)

RunTests runs the prettyprint tests provided. testName should be the name of the calling function (TestSomethingSomethingPrettyPrint normally)

Types

type DetailLevel

type DetailLevel string

DetailLevel allows us to specify how much detail we want included when we call PrettyPrint

type PrettyPrinter

type PrettyPrinter interface {
	PrettyPrint(wr io.Writer, detail DetailLevel) error
}

PrettyPrinter is the common interface used to output different entities in a user friendly way

type TemplateFragmentMapper

type TemplateFragmentMapper interface {
	MapTemplateFragment(templateFrag string) (strs []string, err error)
}

TemplateFragmentMapper is an interface that requires MapTemplateFragment to exist. The implementation of MapTemplateFragment should add "{{" and "}}" to the beginning and end of template fragment, and run it for each element in the receiver, collecting the output up into an array of strings.

type Test

type Test struct {
	Object   PrettyPrinter
	Detail   DetailLevel
	Expected string
}

Test represents a test that can be used with RunPrettyPrintTest - it's not for general use outside of testing.

Jump to

Keyboard shortcuts

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