degorater

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 5 Imported by: 0

README

degorater package

This is a package to decorate of the text in the terminal.
It expected improve visibility and user experience in interactive cli-tools.

Installation

This package can be installed with the go get command:

go get github.com/ebiy0rom0/degorater

How to Use

Simple and basic usage:

degorater.Print("message you want to decorate", nil)

Result is:

+------------------------------+
| message you want to decorate |
+------------------------------+

Too long messages will be automatically wrapped.
Note: The word breaks when wrapped.#

degorater.Print("This is too long message. Want a automatically wrapped.", nil)

Result is:

+------------------------------+
| This is too long message. Wan|
| t a automatically wrapped.   |
+------------------------------+

It can be lined up choices.

degorater.Print("Which one will you choose?", []string{"choice1", "choice2"})

Result is:

+------------------------------+
| Which one will you choose?   |
|                              |
| 1. choice1                   |
| 2. choice2                   |
+------------------------------+

And if there are more than four choices, they may be lined up side by side.
This depends on the string length of each column.

degorater.Print("Which one will you choose?", []string{"choice1", "choice2", "choice3", "choice4"})

Result is:

+------------------------------+
| Which one will you choose?   |
|                              |
| 1. choice1     2. choice2    |
| 3. choice3     4. choice4    |
+------------------------------+

Features

Name Type Default Description
width int terminal width | 30 wip
sp string _ wip
corner string + wip
side string | wip
top string - wip

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeCorner

func ChangeCorner(corner string)

func ChangeOptions

func ChangeOptions(opt *Options)

func ChangeSide

func ChangeSide(side string)

func ChangeSp

func ChangeSp(sp string)

func ChangeTop

func ChangeTop(top string)

func ChangeWidth

func ChangeWidth(width int)

func Print

func Print(msg string, selectors []string)

Types

type Options

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

Jump to

Keyboard shortcuts

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