cprint: github.com/Kenshin/cprint Index | Files

package cprint

import "github.com/Kenshin/cprint"

Color Print(cp) is ANSI coloured text to the standard output by Golang. Vesion 0.0.1

Website https://github.com/kenshin/cprint, depends on https://github.com/daviddengcn/go-colortext

Copyright (c) 2014 Kenshin Wang <kenshin@ksria.com>

Index

Package Files

cp.go

Constants

const (
    DEFAULT = ""
    WARING  = "Waring"
    ERROR   = "Error"
    NOTICE  = "Notice"
)

Print flag, include:

- DEFAULT
- WARING
- ERROR
- NOTICE
const (
    None = iota
    Black
    Red
    Green
    Yellow
    Blue
    Magenta
    Cyan
    White
)

Color uint, include:

- None
- Black
- Red
- Green
- Yellow
- Blue
- Magenta
- Cyan
- White
const SPLIT = "%v"

Parse identifying

func Error Uses

func Error(flag, message string, err interface{})

ANSI coloured erro text to the standard output

flag   : Include 'Default', 'Waring', 'Error', 'Notice'
message: Print content
err    : Error content

For example:

Error(ERROR, "util/print.go an error has occurred. Error: ", err)

func P Uses

func P(flag string, message interface{}, args ...interface{})

ANSI coloured text to the standard output

flag   : Include 'Default', 'Waring', 'Error', 'Notice'
message: Print content
args   : Variable parameter, include string, CP type, when args last value is "\n", auto new line.

For example 1:

P(WARING, "Remote latest version %v = latest version %v.\n", param1, param2)

For example 2:

cp := CP{1, true, 2, true, localVersion}
P(DEFAULT, "Current version %v, publish data: ", cp, "2014-05-31")

For example 3:

P(DEFAULT, "Current version %v", localVersion, "\n")

type CP Uses

type CP struct {
    FgColor  int
    FgBright bool
    BgColor  int
    BgBright bool
    Value    string
}

Color Print

- FgColor : Foreground color
- FgBright: Foreground color is it bright?
- BgColor : Background color
- BgBright: Background color is it bright?
- Value   : Color Message

Package cprint imports 5 packages (graph) and is imported by 4 packages. Updated 2016-07-23. Refresh now. Tools for package owners.