Table of Contents
Qalam is A terminal Styling library built for Go to make building cool-looking CLIs easier
The project still in early state it might have breaking changes in the future
There is Two Ways to use Qalam
- Using Styler
- Using BBcode format
go get github.com/iskaa02/qalam
import "github.com/iskaa02/qalam"
func main(){
s:=qalam.NewStyler().
Bold().
Italic().
Red()
// This will print bold italic red text to the terminal
s.Print("Hello world")
// Change background color
s.YellowBackground()
// use hex color as foreground color
s.Hex("#e28421")
// use hex color as background color
s.BackgroundHex("#e28421")
// Flip Foreground and background colors
s.Invert()
// Make Text blink
s.Blink()
}
Removing Styles
// You can remove any style added previously
s.Remove("bold","blink","bg#e28421")
reference code table below
import "github.com/iskaa02/qalam/bbcode"
func main(){
// this will output "a red text" with red in terminal
// you can use bbcode.Sprintf() if you don't want to print yet
bbcode.Printf("[red]a red %s[/red]","text")
}
bbcode.Printf("[b s]bold and strikethrough[/b s]")
outputs:
bold and strikethrough
bbcode.Printf("[b]bold only [i]bold and italic[/i][/b]")
outputs: bold only bold and italic
Code | Style |
---|---|
b/bold | bold text |
i/italic | italic text |
u/underline | underline text |
s/strikethrough | |
#hexcode | change the color |
bg#hexcode | change the background color |
red | change the color to red |
yellow | change the color to yellow |
magenta | change the color to magenta |
white | change the color to white |
black | change the color to black |
green | change the color to green |
cyan | change the color to cyan |
bg.(color) | change the background color to any color mentioned above |
import "github.com/iskaa02/qalam/gradient"
g,err:=gradient.NewGradient("cyan","red")
// if the passed colors are not valid an error is returned
// supports all css valid colors
if err != nil{
}
g.Print("Example gradient from Cyan to Red")
outputs the following
For more examples checkout gradient Readme
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
If you're on Windows, use Windows Terminal instead of cmd.exe.
Qalam in Arabic means pencil
Ismael Karim - ismael.karim000@gmail.com
Project Link: https://github.com/iskaa02/qalam