diff --git a/decor/on_abort.go b/decor/on_abort.go index 65a8d9d..f71928f 100644 --- a/decor/on_abort.go +++ b/decor/on_abort.go @@ -1,30 +1,21 @@ package decor var ( - _ Decorator = (*onAbortWrapper)(nil) - _ Wrapper = (*onAbortWrapper)(nil) + _ Decorator = onAbortWrapper{} + _ Wrapper = onAbortWrapper{} ) -// OnAbort returns decorator, which wraps provided decorator with sole -// purpose to display provided message on abort event. It has no effect -// if bar.Abort(drop bool) is called with true argument. +// OnAbort wrap decorator. +// Displays provided message on abort event. +// Has no effect if bar.Abort(true) is called. // // `decorator` Decorator to wrap -// -// `message` message to display on abort event +// `message` message to display func OnAbort(decorator Decorator, message string) Decorator { if decorator == nil { return nil } - d := &onAbortWrapper{ - Decorator: decorator, - msg: message, - } - if md, ok := decorator.(*mergeDecorator); ok { - d.Decorator, md.Decorator = md.Decorator, d - return md - } - return d + return onAbortWrapper{decorator, message} } type onAbortWrapper struct { @@ -32,13 +23,13 @@ msg string } -func (d *onAbortWrapper) Decor(s Statistics) string { +func (d onAbortWrapper) Decor(s Statistics) (string, int) { if s.Aborted { - return d.GetConf().FormatMsg(d.msg) + return d.Format(d.msg) } return d.Decorator.Decor(s) } -func (d *onAbortWrapper) Unwrap() Decorator { +func (d onAbortWrapper) Unwrap() Decorator { return d.Decorator }