output/output.go (view raw)
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 34 35 | package output import ( "io" "github.com/fatih/color" ) type Output struct { Writer io.Writer fail, info, success *color.Color } func New(writer io.Writer) Output { return Output{ Writer: writer, fail: color.New(color.FgRed), info: color.New(), success: color.New(color.FgGreen), } } func (o Output) Fail(format string, args ...any) { o.fail.Fprintf(o.Writer, format, args...) } func (o Output) Info(format string, args ...any) { o.info.Fprintf(o.Writer, format, args...) } func (o Output) Success(format string, args ...any) { o.success.Fprintf(o.Writer, format, args...) } |