File: on_compete_or_on_abort.go

package info (click to toggle)
golang-github-vbauerster-mpb 8.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,044 kB
  • sloc: sh: 7; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package decor

// OnCompleteOrOnAbort wrap decorator.
// Displays provided message on complete or on abort event.
//
//	`decorator` Decorator to wrap
//	`message` message to display
func OnCompleteOrOnAbort(decorator Decorator, message string) Decorator {
	return OnComplete(OnAbort(decorator, message), message)
}

// OnCompleteMetaOrOnAbortMeta wrap decorator.
// Provided fn is supposed to wrap output of given decorator
// with meta information like ANSI escape codes for example.
// Primary usage intention is to set SGR display attributes.
//
//	`decorator` Decorator to wrap
//	`fn` func to apply meta information
func OnCompleteMetaOrOnAbortMeta(decorator Decorator, fn func(string) string) Decorator {
	return OnCompleteMeta(OnAbortMeta(decorator, fn), fn)
}