banner

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 6 Imported by: 1

README

banner

Golang app / package to generate a banner of text

Building

Requirements
  • Go 1.19
  • (Optional) Make

A binary can be built either via the Makefile target make build or via go build directly. The Makefile target will place the binary into the bin directory.

❯ make build
mkdir -p bin
go build -ldflags "-s -w " -o bin/banner cmd/banner/main.go

❯ ls bin
banner

CLI Usage

❯ make install
go install ./cmd/banner
❯ banner
Error: requires at least 1 arg(s), only received 0
Usage:
  banner 'Surround this text' [flags]

Flags:
      --char string          The characer to surround the text with (default "=")
      --color string         The color of the banner (none) oneOf [BRIGHT_CYAN BLACK RED WHITE BRIGHT_YELLOW BRIGHT_BLUE BRIGHT_MAGENTA MAGENTA CYAN BRIGHT_BLACK BRIGHT_RED BRIGHT_GREEN BRIGHT_WHITE GREEN YELLOW BLUE]
      --frame-left string    The left framing character (default "[")
      --frame-right string   The right framing character (default "]")
  -h, --help                 help for banner
      --length int           The total length of the banner (default 80)

requires at least 1 arg(s), only received 0

Example (zsh)

Note: The CLI does not yet support Block Banners.

❯ banner "Surround me" --color green --char '*' --frame-left '{' --frame-right '}' --length 40
*************{ Surround me }*************
❯ go run examples/examples.go
==============================[ Surround this text ]==============================
==============================[ Surround this text ]==============================
==================================================[ Surround this text ]==================================================
==============================( Surround this text )==============================
******************************[ Surround this text ]******************************
----------------------------------------~ Surround this text ~----------------------------------------
. . .
====================================[ HEADER ]====================================
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed hendrerit interdum
Duis condimentum nulla eu fringilla bibendum. Integer eget
nibh. Phasellus dignissim eleifend felis at eleifend. Aliquam congue
ligula, in tempus odio dignissim eu. Proin commodo nulla ut dui
malesuada. Suspendisse nec mauris non lorem condimentum euismod nec
nisl. Donec sollicitudin ex sit amet orci auctor, a tincidunt turpis feugiat.
eget justo purus. Suspendisse tincidunt, nunc at lobortis auctor, velit
fermentum ligula, eu sagittis nisl nulla at mi. Curabitur id tellus
In finibus mauris a eros interdum placerat.
==================================================================================
====================================[ HEADER ]====================================
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed hendrerit interdum
Duis condimentum nulla eu fringilla bibendum. Integer eget
nibh. Phasellus dignissim eleifend felis at eleifend. Aliquam congue
ligula, in tempus odio dignissim eu. Proin commodo nulla ut dui
malesuada. Suspendisse nec mauris non lorem condimentum euismod nec
nisl. Donec sollicitudin ex sit amet orci auctor, a tincidunt turpis feugiat.
eget justo purus. Suspendisse tincidunt, nunc at lobortis auctor, velit
fermentum ligula, eu sagittis nisl nulla at mi. Curabitur id tellus
In finibus mauris a eros interdum placerat.
====================================[ FOOTER ]====================================
====================================[ HEADER ]====================================
Thisisonereallylongwordthatshouldbesplitontomultiplelinesbutidkhowitllworkwitho-
ver2lengthsoflines
==================================================================================

The following screenshot is from a zsh terminal in WSL2 on Windows 10.

banner_examples.png

Package Usage

See examples.go for usage within a Go project.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedColor = errors.New("unsupported color")
)

Functions

func AvailableColors

func AvailableColors() []string

func New

func New(text string, opts ...Option) string

func NewBlock added in v1.1.0

func NewBlock(header, block, footer string, opts ...Option) string

Types

type Color

type Color string

type ColorFunc

type ColorFunc func() Option

func GetColorFunc

func GetColorFunc(color string) (ColorFunc, error)

type Option

type Option struct {
	// contains filtered or unexported fields
}

func Black

func Black() Option

func Blue

func Blue() Option

func BrightBlack

func BrightBlack() Option

func BrightBlue

func BrightBlue() Option

func BrightCyan

func BrightCyan() Option

func BrightGreen

func BrightGreen() Option

func BrightMagenta

func BrightMagenta() Option

func BrightRed

func BrightRed() Option

func BrightWhite

func BrightWhite() Option

func BrightYellow

func BrightYellow() Option

func Cyan

func Cyan() Option

func Green

func Green() Option

func Magenta

func Magenta() Option

func NoFrame added in v1.1.0

func NoFrame() Option

func NoReset added in v1.1.0

func NoReset() Option

func Red

func Red() Option

func White

func White() Option

func WithChar

func WithChar(c rune) Option

func WithFrame

func WithFrame(left, right rune) Option

func WithLength

func WithLength(l int) Option

func Yellow

func Yellow() Option

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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