Table of Contents
-
About The Project
- Getting Started
-
Usage
- BBcode Exmaples
- Gradient
- Contributing
- License
- Notes
- Contact
About The Project
Qalam is A terminal Styling library built for Go to make building cool-looking CLIs easier
IMPORTANT
The project still in early state it might have breaking changes in the future
(back to top)
Getting Started
There is Two Ways to use Qalam
- Using Styler
- Using BBcode format
Installation
go get github.com/iskaa02/qalam
Usage
With Styler
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")
}
(back to top)
BBcode Examples
Multiple styles
bbcode.Printf("[b s]bold and strikethrough[/b s]")
outputs:
bold and strikethrough
Composing styles
bbcode.Printf("[b]bold only [i]bold and italic[/i][/b]")
outputs:
bold only bold and italic
Code Table
Code |
Style |
b/bold |
bold text |
i/italic |
italic text |
u/underline |
underline text |
s/strikethrough |
strikethrough text |
#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 |
(back to top)
Gradient
Import
import "github.com/iskaa02/qalam/gradient"
Usage
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
(back to top)
Contributing
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
(back to top)
License
Distributed under the MIT License. See LICENSE.txt
for more information.
(back to top)
Notes
Windows Support
If you're on Windows, use Windows Terminal instead of cmd.exe.
What does the Qalam mean
Qalam in Arabic means pencil
Ismael Karim - ismael.karim000@gmail.com
Project Link: https://github.com/iskaa02/qalam
(back to top)