color

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 5 Imported by: 4

README

Color

Travis Status Github Status GoDoc

Color is a library for colouring things.

Usage

package main

import (
    "fmt"
    "runtime"

    "github.com/jpedro/color"
)

func main() {
    name := "green"
    text := "Runtime OS: %s"
    fmt.Println(color.Paint(name, text, runtime.GOOS))
}

Check the cli/color for your terminal needs.

Todos

  • Create fallback color
  • Add color groups. Now via color.Parse()
  • Add custom color painters. Now via color.NewColor()
  • Name all the 256 term colors

Documentation

Overview

Color is a library for colouring things.

Installation

Install the cli with:

go get github.com/jpedro/color/cli/color

Usage

Sample code:

package main

import (
    "fmt"

    "github.com/jpedro/color"
)

func main() {
    fmt.Println(color.Green("Hello %s!", "lush green"))
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blue added in v0.1.12

func Blue(text interface{}, args ...interface{}) string

Shortcut for color.Paint("blue", text)

func Cyan added in v0.1.12

func Cyan(text interface{}, args ...interface{}) string

Shortcut for color.Paint("cyan", text)

func Gray added in v0.1.15

func Gray(text interface{}, args ...interface{}) string

Shortcut for color.Paint("gray", text)

func Green added in v0.1.12

func Green(text interface{}, args ...interface{}) string

Shortcut for color.Paint("green", text)

func Magenta added in v0.1.12

func Magenta(text interface{}, args ...interface{}) string

Shortcut for color.Paint("magenta", text)

func Paint

func Paint(color string, text interface{}, args ...interface{}) string

Returns shell coloured output for text and args

func Pale added in v0.1.16

func Pale(text interface{}, args ...interface{}) string

Shortcut for color.Paint("pale", text)

func Parse added in v0.1.16

func Parse(text string, args ...interface{}) string

Returns a painted string with groups like `{green|this should be green}` replaced with `this should be green` in green color

func Red added in v0.1.12

func Red(text interface{}, args ...interface{}) string

Shortcut for color.Paint("red", text)

func Yellow added in v0.1.12

func Yellow(text interface{}, args ...interface{}) string

Shortcut for color.Paint("yellow", text)

Types

type Color added in v0.1.17

type Color struct {
	// contains filtered or unexported fields
}

func NewColor added in v0.1.17

func NewColor() *Color

func (*Color) Background added in v0.1.17

func (c *Color) Background(text string) *Color

Select a color for your background

func (*Color) Bold added in v0.1.17

func (c *Color) Bold() *Color

Turns the text bold

func (*Color) Foreground added in v0.1.17

func (c *Color) Foreground(text string) *Color

Select a color for your foreground

func (*Color) Paint added in v0.1.17

func (c *Color) Paint(text interface{}, args ...interface{}) string

Paints text and args according to its settings

func (*Color) Underline added in v0.1.17

func (c *Color) Underline() *Color

Turns the text underlined

Directories

Path Synopsis
cli
color Module

Jump to

Keyboard shortcuts

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