qalam

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 1 Imported by: 1

README

Contributors Forks Stargazers Issues MIT License


✏️

Qalam

Easy Terminal styling using go

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. BBcode Exmaples
  5. Gradient
  6. Contributing
  7. License
  8. Notes
  9. Contact

About The Project

Example for what qalam can do

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

  1. Using Styler
  2. 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

With BBcode Format

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

gradient Example

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. 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


Contact

Ismael Karim - ismael.karim000@gmail.com

Project Link: https://github.com/iskaa02/qalam

(back to top)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStyler

func NewStyler() *styler.Styler

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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