package gut

import (
	"bytes"
	"io"
)

var _ io.Writer = &Console{}

type Console struct {
	messages []string
}

func (c *Console) Write(p []byte) (int, error) {
	c.messages = append(c.messages, string(bytes.TrimRight(p, "\r\n")))
	if len(c.messages) > 1000 {
		c.messages = c.messages[1:]
	}
	return len(p), nil
}

func (c *Console) Messages() []string {
	return c.messages
}
