Documentation ¶
Overview ¶
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) })
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hide ¶
Hide replaces all outputs with nil, hiding them from the bar.
func Original ¶
Original returns the original output unchanged.
Types ¶
type FormatFunc ¶
FormatFunc takes the module's output and returns a modified version.
func EachSegment ¶
func EachSegment(f SegmentFunc) FormatFunc
EachSegment transforms each segment individually.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module wraps a bar.Module with a re-formatting function.
func New ¶
New wraps an existing bar.Module, allowing the format to be changed before being sent to the bar.
func (*Module) Format ¶
func (m *Module) Format(f FormatFunc) *Module
Format sets the reformat function.
type SegmentFunc ¶
SegmentFunc is a reformatting function at the segment level.
func SkipErrors ¶
func SkipErrors(f SegmentFunc) SegmentFunc
SkipErrors wraps a segment transformation function so that error segments pass through unchanged.