Plugin - Accept format strings+data for AddLine

Most calls were being made from fmt.Sprintf() anyway, so it was clear
this required formatted input.
This commit is contained in:
Emmanuel BENOîT 2021-02-27 10:54:40 +01:00
parent a856b449a8
commit 31850c9901

View file

@ -58,17 +58,17 @@ func (p *Plugin) SetState(status Status, message string) {
}
// AddLine adds the specified string to the extra output text buffer.
func (p *Plugin) AddLine(line string) {
func (p *Plugin) AddLine(format string, data ...interface{}) {
if p.extraText == nil {
p.extraText = list.New()
}
p.extraText.PushBack(line)
p.extraText.PushBack(fmt.Sprintf(format, data...))
}
// AddLines add the specified `lines` to the output text.
func (p *Plugin) AddLines(lines []string) {
for _, line := range lines {
p.AddLine(line)
p.AddLine("%s", line)
}
}