package cowsay

// import "nmyk.io/cowsay"

Package Cowsay implements the functionality of the classic cowsay Perl script.

All classic cowfiles have been converted from the original Perl syntax into Go's text/template format in order to help spread ASCII art cow culture ever further into the computer systems of the world.

[cowsay]: https://en.wikipedia.org/wiki/Cowsay

VARIABLES

var (
    Default  = Mood{"oo", ""}
    Borg     = Mood{"==", ""}
    Greedy   = Mood{"$$", ""}
    Paranoid = Mood{"@@", ""}
    Stoned   = Mood{"**", "U "}
    Tired    = Mood{"--", ""}
    Wired    = Mood{"OO", ""}
    Youthful = Mood{"..", ""}
    Dead     = Mood{"xx", "U "}
)
var Cowfiles *template.Template

Cowfiles is associated with templates of all the builtin cowfiles.

FUNCTIONS

func Cowsay(s string)

Cowsay is provided for convenience. It is identical to Cow{}.Say. It prints the default cow speaking the input string to stdout, followed by a newline.

TYPES

type Cow struct {

    // Mood determines the appearance of the cow's eyes and tongue.
    Mood Mood

    // Width determines the wrap width of the text inside the speech
    // bubble. Setting Width < 0 results in no word wrap. A value of 0
    // will use the default width (40-ish).
    Width int

    // Has unexported fields.
}

Cow can be configured to say things in different ways.

func Load(path string) (Cow, error)

Load loads a cowfile from the provided path. Builtin cowfiles can be specified by either the basename, or basename with extension removed; e.g. Load("default") and Load("default.cow") both load the included default cowfile.

func (c Cow) Say(s string)

Say prints an ASCII art Cow speaking the input string to stdout, followed by a newline.

func (c Cow) Think(s string)

Think prints an ASCII art Cow thinking the input string to stdout, followed by a newline.

func (c Cow) Write(w io.Writer, s []byte, think bool) (int, error)

Write writes an ASCII art Cow speaking or thinking the input string to the provided io.Writer. If think == true, then the Cow will appear thinking; otherwise speaking.

type Mood struct {

    // Eyes contains a string representation of a Cow's eyes. The first two
    // runes of Eyes are used as .Eyes in cowfiles, and the rest is
    // ignored.  If uninitialized, "oo" will be used. If Eyes has a length
    // of 1, it will be right-padded with a space.
    Eyes string

    // Tongue contains a string representation of a Cow's tongue. The first
    // two runes of Tongue are used as .Tongue in cowfiles, and the rest is
    // ignored.  If uninitialized, "  " (two spaces) will be used. If
    // Tongue has a length of 1, it will be right-padded with a space.
    Tongue string
}

Mood determines the appearance of the Cow's eyes and tongue.