-
Notifications
You must be signed in to change notification settings - Fork 13
/
builder.go
33 lines (27 loc) · 858 Bytes
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package marker
import (
"github.com/fatih/color"
)
// MarkBuilder is a better and neater way to mark different patterns of the string
type MarkBuilder struct {
str string
}
// SetString sets the first parameter as the string that is going to be marked
func (m *MarkBuilder) SetString(str string) *MarkBuilder {
m.str = str
return m
}
// Mark marks the string with the matcher function and color
func (m *MarkBuilder) Mark(matcherFunc MatcherFunc, c *color.Color) *MarkBuilder {
m.str = Mark(m.str, matcherFunc, c)
return m
}
// MarkMany marks the string with a variable number of matcher functions and color
func (m *MarkBuilder) MarkMany(c *color.Color, matcherFuncs ...MatcherFunc) *MarkBuilder {
m.str = MarkMany(m.str, c, matcherFuncs...)
return m
}
// Build returns the marked string
func (m *MarkBuilder) Build() string {
return m.str
}