Index | Files

package reformat

import ""

Package reformat provides a module that "wraps" an existing module and transforms it's output. This can be useful for adding extra formatting simple bar modules.

For example, a time module might use strftime-style format strings, which don't allow for colours or borders. You can add those using reformat:

t := localtime.New(...)
r := reformat.New(t).Format(func(o bar.Output) bar.Output {
  return o.Background("red").Padding(20)


Package Files


func Hide Uses

func Hide(in bar.Segments) bar.Output

Hide replaces all outputs with nil, hiding them from the bar.

func Original Uses

func Original(in bar.Segments) bar.Output

Original returns the original output unchanged.

func Texts Uses

func Texts(f func(string) string) func(bar.Segments) bar.Output

Texts reformats a module's output with just the text content as input.

type FormatFunc Uses

type FormatFunc = func(bar.Segments) bar.Output

FormatFunc takes the module's output and returns a modified version.

func EachSegment Uses

func EachSegment(f SegmentFunc) FormatFunc

EachSegment transforms each segment individually.

type Module Uses

type Module struct {
    // contains filtered or unexported fields

Module wraps a bar.Module with a re-formatting function.

func New Uses

func New(original bar.Module) *Module

New wraps an existing bar.Module, allowing the format to be changed before being sent to the bar.

func (*Module) Format Uses

func (m *Module) Format(f FormatFunc) *Module

Format sets the reformat function.

func (*Module) Stream Uses

func (m *Module) Stream(s bar.Sink)

Stream sets up the output pipeline to filter outputs when hidden.

type SegmentFunc Uses

type SegmentFunc func(*bar.Segment) *bar.Segment

SegmentFunc is a reformatting function at the segment level.

func SkipErrors Uses

func SkipErrors(f SegmentFunc) SegmentFunc

SkipErrors wraps a segment transformation function so that error segments pass through unchanged.

Package reformat imports 5 packages (graph). Updated 2018-11-25. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).