Codebase list golang-github-vbauerster-mpb / d48e1f6 decor / any.go
d48e1f6

Tree @d48e1f6 (Download .tar.gz)

any.go @d48e1f6raw · history · blame

package decor

// Any decorator displays text, that can be changed during decorator's
// lifetime via provided DecorFunc.
//
//	`fn` DecorFunc callback
//
//	`wcc` optional WC config
func Any(fn DecorFunc, wcc ...WC) Decorator {
	return &any{initWC(wcc...), fn}
}

type any struct {
	WC
	fn DecorFunc
}

func (d *any) Decor(s Statistics) string {
	return d.FormatMsg(d.fn(s))
}