Skip to content

Pronin1986/fmtc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

fmtc overrides print functions of the fmt package and add ability to coloring the console output in the HTML-style

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages