box

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MIT Imports: 3 Imported by: 2

README

Box CLI Maker 📦

go.dev reference Build Status Go Report Card

Box CLI Maker is a Highly Customized Terminal Box Creator.

Features

  • Make terminal box in 8️⃣ inbuilt different style
  • Custom Title Positions
  • Make your own Box style 📦
  • Align the text according to the need
  • Written in 🇬 🇴
  • Color Support (soon)

Installation

 go get github.com/Delta456/box-cli-maker

Usage

In main.go

package main

import (
 "github.com/Delta456/box-cli-maker" 
)

func main() {
    Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single" })
    Box.Print("Box CLI Maker", "It is a highly customized terminal Box Maker")
}

box.New(config Config) accepts a Config struct with following parameters.

  • Parameters
    • Px : Horizontal Padding
    • Py : Vertical Padding
    • ContentAlign : Align content in the Box i.e. Center, Left and Right
    • Type: Type of Box (listed down below)
    • TitlePos : Position of the Title i.e. Inside, Top and Bottom

box.Print(title, lines string) prints Box from the specified arguements.

  • Parameters
    • title : Title of the Box
    • lines : Content written inside the Box

box.Println(title, lines string) prints Box in a newline from the specified arguements.

  • Parameters
    • title : Title of the Box
    • lines : Content written inside the Box

box.String(title, lines string) string return string representation of Box.

  • Parameters
    • title : Title of the Box
    • lines : Content written inside the Box
Box Types
  • Single

single

  • Single Double

Single Double

  • Double

Double

  • Double Single

Double Single

  • Bold

Bold

  • Round

Round

  • Hidden

Hidden

  • Classic

Classic

Title Positions
  • Inside

Inside

  • Top

Top

  • Bottom

Bottom

Making custom Box

You can make your custom Box by using the inbuilt Box struct provided by the module.

type Box struct {
	TopRight    string // TopRight corner used for Symbols
	TopLeft     string // TopLeft corner used for Symbols
	Vertical    string // Symbols used for Vertical Bars
	BottomRight string // BottomRight corner used for Symbols
	BottomLeft  string // BotromLeft corner used for Symbols
	Horizontal  string // Symbols used for Horizontal Bars
	Con      Config // Configuration for the Box to be made
}
box := Box{TopRight: "*", TopLeft: "*", BottomRight: "*", BottomLeft: "*", Horizontal: "-", Vertical: "|", Con: Config{Px: 2, Py: 3, Type: "", TitlePos: "Inside"}}
box.Print("Custom Box", "This is a custom Box and it works well")

Output:

Custom

Note

As different terminals have different font by default so the right vertical alignment may not be aligned well. You will have to change your font accordingly to make it work.

Acknowledgements

I thank the following people and their packages whom I have studied and was able to port to Go accordingly.

License

Licensed under MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

type Box struct {
	TopRight    string // TopRight corner used for Symbols
	TopLeft     string // TopLeft corner used for Symbols
	Vertical    string // Symbols used for Vertical Bars
	BottomRight string // BottomRight corner used for Symbols
	BottomLeft  string // BotromLeft corner used for Symbols
	Horizontal  string // Symbols used for Horizontal Bars
	Con         Config // Config for Box struct
}

Box struct defines the Box to be made.

func New

func New(config Config) Box

New takes struct Config and returns the specified Box struct.

func (Box) Print

func (b Box) Print(title, lines string)

Print prints the box

func (Box) Println

func (b Box) Println(title, lines string)

Println adds a newline before and after the box

func (Box) String

func (b Box) String(title, lines string) string

String returns the string representation of Box.

type Config

type Config struct {
	Py           int    // Horizontal Padding
	Px           int    // Vertical Padding
	ContentAlign string // Content Alignment inside Box
	Type         string // Type of Box
	TitlePos     string // Title Position
}

Config is the configuration for the Box struct

Jump to

Keyboard shortcuts

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