prism

package module
v0.0.0-...-3e2ead0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2018 License: MIT Imports: 2 Imported by: 1

README

Prism

💎 -> ❤️ 💛 💚 💙 💜

A golang library for colorizing terminal output

Installation

go get github.com/juanrgon/prism

Usage

Coloring Text

Prism lets you turn any string into a colored a string with the functions InRed, InGreen , InBlue, InYellow, InCyan, InMagenta, InBlack, and InWhite.

package main

import (
	"fmt"

	"github.com/juanrgon/prism"
)

func main() {
    r := prism.InRed("some red text")
    g := prism.InGreen("some green text")
    b := prism.InBlue("some blue text")
    fmt.Println(r, g, "and", b)
}

Coloring Background

Prism lets you change the background of any string with the functions OnRed, OnGreen, OnBlue, OnYellow, OnCyan, OnMagenta, OnBlack, and OnWhite.

package main

import (
	"fmt"

	"github.com/juanrgon/prism"
)

func main() {
    y := prism.OnYellow("some text on yellow")
    c := prism.OnCyan("some text on cyan")
    m := prism.OnMagenta("some text on magenta")
    fmt.Println(y, c, "and", m)
}

Bold Text

Prism lets you turn any string into a bold string with the function InBold

package main

import (
	"fmt"

	"github.com/juanrgon/prism"
)

func main() {
    b := prism.InBold("Very Important")
    fmt.Println(b)
}

Underlined Text

Prism lets you underline any string with the function Underlined

package main

import (
	"fmt"

	"github.com/juanrgon/prism"
)

func main() {
    u := prism.Underlined("Emphasized text")
    fmt.Println(u)
}

Combining Styles

The prism functions return a prism.DecoratedString type. This type has the above In* (e.g. InBlue), On* (e.g. OnGreen), InBold, and Underlined functions registered. This allows you to apply multiple stylings to a string.

package main

import (
	"fmt"

	"github.com/juanrgon/prism"
)

func main() {
    text := "A bold, black, underlined string on a yellow background"
    complex := prism.InBlack(text).OnYellow().InBold().Underlined()
    fmt.Println(complex)
}

For more examples see github.com/juangrgon/prism-examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DecoratedString

type DecoratedString string

DecoratedString is a string with methods for coloring

func InBlack

func InBlack(s string) DecoratedString

InBlack returns the input string with black text

func InBlue

func InBlue(s string) DecoratedString

InBlue returns the input string with blue text

func InBold

func InBold(s string) DecoratedString

InBold returns the input string in bold

func InCyan

func InCyan(s string) DecoratedString

InCyan returns the input string with cyan text

func InGreen

func InGreen(s string) DecoratedString

InGreen returns the input string with green text

func InMagenta

func InMagenta(s string) DecoratedString

InMagenta returns the input string with magenta text

func InRed

func InRed(s string) DecoratedString

InRed returns the input string with red text

func InWhite

func InWhite(s string) DecoratedString

InWhite returns the input string with white text

func InYellow

func InYellow(s string) DecoratedString

InYellow returns the input string with yellow text

func Inverted

func Inverted(s string) DecoratedString

InBold returns the input string in bold

func OnBlack

func OnBlack(s string) DecoratedString

OnBlack returns the input string with a black background

func OnBlue

func OnBlue(s string) DecoratedString

OnBlue returns the input string with a blue background

func OnCyan

func OnCyan(s string) DecoratedString

OnCyan returns the input string with a cyan background

func OnGreen

func OnGreen(s string) DecoratedString

OnGreen returns the input string with a green background

func OnMagenta

func OnMagenta(s string) DecoratedString

OnMagenta returns the input string with a magenta background

func OnRed

func OnRed(s string) DecoratedString

OnRed returns the input string with a red background

func OnWhite

func OnWhite(s string) DecoratedString

OnWhite returns the input string with a white background

func OnYellow

func OnYellow(s string) DecoratedString

OnYellow returns the input string with a yellow background

func Underlined

func Underlined(s string) DecoratedString

Underlined returns the input string underlined

func (DecoratedString) InBlack

func (ds DecoratedString) InBlack() DecoratedString

InBlack returns this DecoratedString with black text

func (DecoratedString) InBlue

func (ds DecoratedString) InBlue() DecoratedString

InBlue returns this DecoratedString with blue text

func (DecoratedString) InBold

func (ds DecoratedString) InBold() DecoratedString

InBold returns this DecoratedString in bold

func (DecoratedString) InCyan

func (ds DecoratedString) InCyan() DecoratedString

InCyan returns this DecoratedString with cyan text

func (DecoratedString) InGreen

func (ds DecoratedString) InGreen() DecoratedString

InGreen returns this DecoratedString with green text

func (DecoratedString) InMagenta

func (ds DecoratedString) InMagenta() DecoratedString

InMagenta returns this DecoratedString with magenta text

func (DecoratedString) InRed

func (ds DecoratedString) InRed() DecoratedString

InRed returns this DecoratedString with red text

func (DecoratedString) InWhite

func (ds DecoratedString) InWhite() DecoratedString

InWhite returns this DecoratedString with white text

func (DecoratedString) InYellow

func (ds DecoratedString) InYellow() DecoratedString

InYellow returns this DecoratedString with yellow text

func (DecoratedString) Inverted

func (ds DecoratedString) Inverted() DecoratedString

func (DecoratedString) OnBlack

func (ds DecoratedString) OnBlack() DecoratedString

OnBlack returns this decorated string with a black background

func (DecoratedString) OnBlue

func (ds DecoratedString) OnBlue() DecoratedString

OnBlue returns this DecoratedString with a blue background

func (DecoratedString) OnCyan

func (ds DecoratedString) OnCyan() DecoratedString

OnCyan returns this DecoratedString with a cyan background

func (DecoratedString) OnGreen

func (ds DecoratedString) OnGreen() DecoratedString

OnGreen returns this DecoratedString with a green background

func (DecoratedString) OnMagenta

func (ds DecoratedString) OnMagenta() DecoratedString

OnMagenta returns this DecoratedString with a magenta background

func (DecoratedString) OnRed

func (ds DecoratedString) OnRed() DecoratedString

OnRed returns this DecoratedString with a red background

func (DecoratedString) OnWhite

func (ds DecoratedString) OnWhite() DecoratedString

OnWhite returns this DecoratedString with a white background

func (DecoratedString) OnYellow

func (ds DecoratedString) OnYellow() DecoratedString

OnYellow returns this DecoratedString with a yellow background

func (DecoratedString) Underlined

func (ds DecoratedString) Underlined() DecoratedString

Underlined returns this DecoratedString underlined

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL