fmtc

package module
v0.0.0-...-7328069 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: MIT Imports: 6 Imported by: 0

README

fmtc

The fmtc overrides the print functions of the fmt package, but with the ability to color output in bash using HTML tags

Available text decoration tags
<b></b>               - make font Bold
<strong></strong>     - make font Bold
<u></u>               - make text Underlined
<dim></dim>           - make font Dim
<reverse></reverse>   - Reverse background and font color
<blink></blink>       - make text Blink (not working on Mint/Ubuntu)
<black></black>       - set font color Black (Dark)
<red></red>           - set font color Red
<green></green>       - set font color Green
<yellow></yellow>     - set font color Yellow
<blue></blue>         - set font color Blue
<magenta></magenta>   - set font color Magenta
<cyan></cyan>         - set font color Cyan
<grey></grey>         - set font color Grey (Smokey)
<white></white>       - set font color White
Available background colors tags:
<bg color="black"></bg> 	- black background color
<bg color="red"></bg> 		- red background color
<bg color="green"></bg> 	- green background color
<bg color="yellow"></bg> 	- yellow background color
<bg color="blue"></bg> 		- blue background color
<bg color="magenta"></bg> 	- magenta background color
<bg color="cyan"></bg> 		- cyan background color
<bg color="grey"></bg> 		- grey background color
<bg color="white"></bg> 	- white background color

<b_black></b_black> 		- black background color
<b_red></b_red>		 	- red background color
<b_green></b_green>		- green background color
<b_yellow></b_yellow>		- yellow background color
<b_blue></b_blue>		- blue background color
<b_magenta></b_magenta>		- magenta background color
<b_cyan></b_cyan>		- cyan background color
<b_grey></b_grey>		- grey background color
<b_white></b_white>		- white background color
Install:
go get github.com/Pronin1986/fmtc
Usage:
fmtc.Print(`<b>HELLO <blue>BLUE</blue> <bg color="green">TEXT</bg></b>`)
fmtc.Println(`<b>HELLO <blue>BLUE</blue> <bg color="green">TEXT</bg></b>`)
fmtc.Printf(`<b>%v <blue>%v</blue> <bg color="green">%v</bg></b>`, "HELLO", "BLUE", "TEXT")
got: = fmtc.Sprint(`<b>HELLO <blue>BLUE</blue> <bg color="green">TEXT</bg></b>`)
got = fmtc.Sprintln(`<b>HELLO <blue>BLUE</blue> <bg color="green">TEXT</bg></b>`)
got = fmtc.Sprintf(`<b>%v <blue>%v</blue> <bg color="green">%v</bg></b>`, "HELLO", "BLUE", "TEXT")
buf := new(bytes.Buffer)
fmtc.Fprint(buf, `<b>HELLO <blue>BLUE</blue> <bg color="green">TEXT</bg></b>`)
fmtc.Fprintln(buf, `<b>HELLO <blue>BLUE</blue> <bg color="green">TEXT</bg></b>`)
fmtc.Fprintf(buf, `<b>%v <blue>%v</blue> <bg color="green">%v</bg></b>`, "HELLO", "BLUE", "TEXT")

You have already decorated text for console output like a picture above:

UsageExampleResult

Example:
package main

import (
	"fmt"

	"github.com/Pronin1986/fmtc"
)

func main() {
	fmt.Println("HELLO WORLD")
	fmtc.Println("<b>HELLO <blue>WORLD</blue></b>")
}

ExampleResult

Documentation

Index

Constants

View Source
const (
	//CODERESET reset style after this code
	CODERESET = "\033[0m"
)

Variables

This section is empty.

Functions

func Fprint

func Fprint(w io.Writer, a ...interface{}) (n int, err error)

Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func Fprintf

func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)

Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.

func Fprintln

func Fprintln(w io.Writer, a ...interface{}) (n int, err error)

Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func Print

func Print(a ...interface{}) (n int, err error)

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func Printf

func Printf(format string, a ...interface{}) (n int, err error)

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func Println

func Println(a ...interface{}) (n int, err error)

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func Sprint

func Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func Sprintf

func Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func Sprintln

func Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

Types

This section is empty.

Jump to

Keyboard shortcuts

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