Skip to content

vinay03/chalk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chalk

Chalk is a Go Package which can be used for making terminal output more vibrant with text colors, text styles and background colors.

Mininum Requirements

Go v1.18

Documentation

Check out godoc for some example usage: http://godoc.org/github.com/vinay03/chalk

Syntax

chalk[.<TextColor>()][.<TextStyle>()][.<BackgroundColor>()]

Examples

1. Text Colors

package main
import (
	"github.com/vinay03/chalk"
)
func main() {
	chalk.Yellow().Println("Yellow-Text")
	chalk.Red().Println("Red-Text")
	chalk.GreenLight().Println("GreenLight-Text")
	chalk.Cyan().Println("Cyan-Text")
}

Output:

TextColors

More Text Colors
TextColor Syntax
Black chalk.Black()
BlackLight chalk.BlackLight()
Red chalk.Red()
RedLight chalk.RedLight()
Green chalk.Green()
GreenLight chalk.GreenLight()
Yellow chalk.Yellow()
YellowLight chalk.YellowLight()
Blue chalk.Blue()
BlueLight chalk.BlueLight()
Magenta chalk.Magenta()
MagentaLight chalk.MagentaLight()
Cyan chalk.Cyan()
CyanLight chalk.CyanLight()
White chalk.White()
WhiteLight chalk.WhiteLight()

2. Text Styles

package main
import (
	"github.com/vinay03/chalk"
)
func main() {
	chalk.Bold().Println("Bold-Text")
	chalk.Italic().Println("Italic-Text")
	chalk.Underline().Println("Underline-Text")
}

Output:

TextStyles

More Text Styles
Style Syntax
Bold chalk.Bold()
Dim chalk.Dim()
Italic chalk.Italic()
Underline chalk.Underline()
Inverse chalk.Inverse()
Hidden chalk.Hidden()
Strikethrough chalk.Strikethrough()

3. Background Colors

package main
import (
	"github.com/vinay03/chalk"
)
func main() {
	chalk.BgRed().Println("Text-on-Red-Background")
	chalk.BgMagenta().Println("Text-on-Magenta-Background")
	chalk.BgBlue().Println("Text-on-Blue-Background")
}

Output:

BackgroundColors

More Background Colors
Background-Color Syntax
Black chalk.BgBlack()
BlackLight chalk.BgBlackLight()
Red chalk.BgRed()
RedLight chalk.BgRedLight()
Green chalk.BgGreen()
GreenLight chalk.BgGreenLight()
Yellow chalk.BgYellow()
YellowLight chalk.BgYellowLight()
Blue chalk.BgBlue()
BlueLight chalk.BgBlueLight()
Magenta chalk.BgMagenta()
MagentaLight chalk.BgMagentaLight()
Cyan chalk.BgCyan()
CyanLight chalk.BgCyanLight()
White chalk.BgWhite()
WhiteLight chalk.BgWhiteLight()

4. Formatting Combinations

package main
import (
	"github.com/vinay03/chalk"
)
func main() {
	chalk.Black().Bold().BgRed().Println("Black-and-Bold-Text-on-Red-Background")
	chalk.Black().Italic().BgBlue().Println("Black-and-Italic-Text-on-Blue-Background")
}

Output:

FormattingCombinations

5. Pre-defined Format

package main
import (
	"github.com/vinay03/chalk"
)
func main() {
	SuccessFormatting := chalk.Green()
	SuccessFormatting.Println("Completed Successfully")
	ErrorFormatting := chalk.Red()
	ErrorFormatting.Println("Failed to execute. Try again!")
}

Output:

PredefinedFormats

6. Pre-formated Text

package main
import (
	"fmt"
	"github.com/vinay03/chalk"
)
func main() {
	SuccessMessagePrefix := chalk.Green().Bold().Sprint("SUCCESS :")
	fmt.Println(SuccessMessagePrefix, "Process completed successfully.")
}

Output:

PredefinedFormattedText

7. Wrap Formating

package main
import (
	"fmt"
	"github.com/vinay03/chalk"
)
func main() {
	fmt.Print(chalk.Green()) // Starts the formatting
	fmt.Println("All these lines ")
	fmt.Println("will be printed in ")
	fmt.Println("Green")
	fmt.Print(chalk.Reset()) // Resets all the formatting
}

Output:

WrapFormatting

More Examples

examples/examples.go

Source

Author

Vinay Jeurkar

   

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages