Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 774 Bytes

README.md

File metadata and controls

51 lines (36 loc) · 774 Bytes

Human

Renders just about anything as human-friendly as possible.

Primary use case is as a output formatter for CLIs tools.

Usage

var value any
str, err := human.Render(value)
var value any
err := human.Write(os.Stdout, value)
var value any
err := human.NewRenderer(os.Stdout).Render(value)

Custom rendering

Render functions should write a new-line at the end of the output.

Using the human.RenderHuman interface

type MyType struct {
    // ...
}

func (t *MyType) RenderHuman(io.Writer) error {
    // ...
}

Registering a type renderer

renderer := human.NewRenderer(os.Stdout)

RegisterTypeRenderer(renderer, func (io.Writer, b bool) error {
    // ...
})

var b bool
err := renderer.Render(b)