Skip to content

arsham/rainbow

Repository files navigation

Rainbow

PkgGoDev GitHub go.mod Go version Build Status Coverage Status Codacy Badge Go Report Card License

Tasty rainbows for your terminal like these:

Screenshot

This app was inspired by lolcats, but written in Go.

Table of Contents

  1. Installation
  2. Usage
  3. As library
  4. See Also
  5. License

Installation

You can download the latest binary from here, or you can compile from source:

go install github.com/arsham/rainbow@latest

Usage

You can pipe the text into the app in many ways. Choose one that is suitable for you:

# File contents:
rainbow < filename.txt

# Echo a string:
echo "Any quotes" | rainbow

# Here string:
rainbow <<END
Consectetur aliqua do quis sed
proident enim fugiat occaecat nisi
in deserunt culpa aliquip do excepteur.
END

# Output of a program:
ls -l | rainbow

As library

Light struct implements io.Reader and io.Writer:

import "github.com/arsham/rainbow/rainbow"
// ...
l := rainbow.Light{
    Reader: someReader, // to read from
    Writer: os.Stdout, // to write to
}
l.Paint() // will rainbow everything it reads from reader to writer.

If you want the rainbow to be random, you can seed it this way:

l := rainbow.Light{
    Reader: buf,
    Writer: os.Stdout,
    Seed:   rand.Int63n(256),
}

Or if you prefer io.Copy:

l := rainbow.Light{
    Writer: os.Stdout,
    Seed:   rand.Int63n(256),
}
io.Copy(l, someReader)

See Also

See also Figurine. It prints beautiful ASCII arts in FIGlet.

License

Use of this source code is governed by the Apache 2.0 license. License that can be found in the LICENSE file.

Please note that this was initially forked from glolcat, but I decided to rewrite it as the library is not maintained anymore.