utils

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPrefix = color.New(color.FgRed).Sprint("»")

ErrPrefix is the prefix that should output when an error occurred

Green is a simple green foreground color

View Source
var OkPrefix = Green.Sprint("»")

OkPrefix is the prefix that should prefix output when everything is ok

Yellow is a simple yellow foreground color

Functions

func AskIfEmptyString

func AskIfEmptyString(in *string, name, message, def string, debug bool)

AskIfEmptyString will prompt the user if needed

func ConfirmFileExists

func ConfirmFileExists(path string, dir, yes, debug bool) bool

ConfirmFileExists will prompt the user with a confirmation if the file/directory already exists If the user answers "no", the program exits properly, otherwise the function returns true if the file existed and false if it doesn't

func ErrPrintln

func ErrPrintln(opts ...interface{})

ErrPrintln prints with a red prefix

func ErrSprintln

func ErrSprintln(opts ...interface{}) string

ErrSprintln will return the string with a red prefix

func ExitPrintln

func ExitPrintln(opts ...interface{})

ExitPrintln prints out information with a red prefix and exits the program with an acceptable status code

func FatalPrintln

func FatalPrintln(opts ...interface{})

FatalPrintln prints out information with a red prefix and exits the program with an error status code

func GetTemplateDir

func GetTemplateDir(output string) (string, error)

GetTemplateDir creates the necessary directory or uses the one provided in the configuration on the command line

func OkPrintln

func OkPrintln(opts ...interface{})

OkPrintln prints with a green prefix

func OkSprintln

func OkSprintln(opts ...interface{}) string

OkSprintln will return the string with a green prefix

Types

type Spinner

type Spinner struct {
	*spinner.Spinner
}

Spinner extends the spinner.Spinner struct and adds a few useful methods

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner configures and starts a new spinner

func (*Spinner) DoneStop

func (is *Spinner) DoneStop(message string, opts ...interface{})

DoneStop changes the final message of a Spinner (ok) and stops it right away

func (*Spinner) ErrStop

func (is *Spinner) ErrStop(message string, opts ...interface{})

ErrStop changes the final message of a Spinner (error) and stops it right away

Jump to

Keyboard shortcuts

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