utils

package
v0.0.0-...-4eef74f Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCaseToDashCase

func CamelCaseToDashCase(name string) string

CamelCaseToDashCase converts a camelCase name to dash case.

func CheckForNilAndHandleError

func CheckForNilAndHandleError(err error, message string)

CheckForNilAndHandleError will check to see if an error is nil and handle the error if it exists.

func ClearLine

func ClearLine()

ClearLine clears the last line in the terminal.

func CopyDirectory

func CopyDirectory(oldDirPath, newDirPath string, exclustionList []string) error

CopyDirectory copies a directory and its contents to a new location.

func CopyFile

func CopyFile(oldFilePath, newFilePath string) error

CopyFile copies a file to a different file.

func CopyPackagedDirectory

func CopyPackagedDirectory(oldDirPath, newDirPath string, exclustionList []string) error

CopyPackagedDirectory copies a directory packaged in the binary and its contents to a new location.

func CreateConfigFile

func CreateConfigFile(configDirectoryName string, name string, env string) error

func CreateNewDirectory

func CreateNewDirectory(name string) error

CreateNewDirectory creates a new directory in the current working directory.

func DashCaseToCamelCase

func DashCaseToCamelCase(name string) string

DashCaseToCamelCase converts a dash-case name to camelCase.

func DashCaseToSentenceCase

func DashCaseToSentenceCase(name string) string

DashCaseToSentenceCase converts a dash-case name to SentenceCase

func DoesFileExist

func DoesFileExist(filePath string) (bool, error)

DoesFileExist checks if a file exists

func HandleError

func HandleError(message string, err error)

HandleError outputs error messages and exits the program.

func HashStringMD5

func HashStringMD5(text string) string

HashStringMD5 hashes a string with md5.

func IsCurrentDirectoryEmpty

func IsCurrentDirectoryEmpty() (bool, error)

IsCurrentDirectoryEmpty checks to see if the current working directory is empty.

func ListenForProgramClose

func ListenForProgramClose(cb func())

ListenForProgramClose sets a listener for program exits so we can exit gracefully.

func NewErrorMessage

func NewErrorMessage(message string, err error) error

NewErrorMessage creates a new error with a given message.

func Print

func Print(items ...interface{})

func Printf

func Printf(pattern string, items ...interface{})

func PromptRequiredString

func PromptRequiredString(label string) (string, error)

PromptRequiredString prompts the user for required string.

func PromptSecretString

func PromptSecretString(label string) (string, error)

PromptSecretString prompts the user for a string that is a secret.

func PromptSelection

func PromptSelection(label string, choices []string) (string, error)

PromptSelection prompts the user to pick from a list of choices.

func ReadDirectoryContents

func ReadDirectoryContents(dirPath string) ([]string, error)

ReadDirectoryContents reads the contents of a directory and returns a list of the names of the contents.

func RunCommand

func RunCommand(command string, args []string) (string, error)

RunCommand runs a command and return the output.

func RunCommandWithOutput

func RunCommandWithOutput(command string, args []string) error

RunCommandWithOutput runs a command and streams the output to the terminal.

func RunCommandWithSpinner

func RunCommandWithSpinner(command string, args []string, terminalSpinner TerminalSpinner) error

RunCommandWithSpinner runs a command with a spinner instead of streaming the output.

func SentenceToCamelCase

func SentenceToCamelCase(sentence string) string

SentenceToCamelCase turns a sentence into camelCase.

func SentenceToDashCase

func SentenceToDashCase(name string) string

SentenceToDashCase takes a sentence and turns it into a lowercase string with dash separators.

func TextColor

func TextColor(text string, textColor ...color.Attribute) string

func WriteNewFile

func WriteNewFile(pathName string, fileName string, content string) error

WriteNewFile writes out a new file with the provided content.

func WriteOutTemplateToFile

func WriteOutTemplateToFile(templatePath string, filePath string, args interface{}) error

func ZipDirectory

func ZipDirectory(pathToDir, pathToZip string) error

ZipDirectory zips a directory.

func ZipFile

func ZipFile(fileToZipPath, zipFilePath, zipFileName string) error

ZipFile zips a file.

Types

type DefaultConfigFile

type DefaultConfigFile struct {
	Name        string
	Environment string
}

func ReadConfigFile

func ReadConfigFile(configDirectoryName string, env string) (DefaultConfigFile, error)

type ProgramCloseCallback

type ProgramCloseCallback func()

type TemporaryDirectory

type TemporaryDirectory struct {
	Name string
}

TemporaryDirectory is a temporary directory that will be cleaned up.

func (*TemporaryDirectory) Clean

func (tmp *TemporaryDirectory) Clean()

func (*TemporaryDirectory) Create

func (tmp *TemporaryDirectory) Create() error

type TerminalSpinner

type TerminalSpinner struct {
	SpinnerText   string
	CompletedText string
	FailureText   string
	Element       *spinner.Spinner
}

func CreateNewTerminalSpinner

func CreateNewTerminalSpinner(spinnerText, completedText, failureText string) TerminalSpinner

CreateNewTerminalSpinner creates a new terminal spinner.

func (*TerminalSpinner) Create

func (t *TerminalSpinner) Create()

func (*TerminalSpinner) Fail

func (t *TerminalSpinner) Fail()

func (*TerminalSpinner) FailWithMessage

func (t *TerminalSpinner) FailWithMessage(message string, err error) error

func (*TerminalSpinner) SetOutput

func (t *TerminalSpinner) SetOutput(writer io.Writer)

func (*TerminalSpinner) Stop

func (t *TerminalSpinner) Stop()

type TerminalSpinnerLogger

type TerminalSpinnerLogger struct{}

func (*TerminalSpinnerLogger) Write

func (t *TerminalSpinnerLogger) Write(msg []byte) (int, error)

type TerminalTable

type TerminalTable struct {
	Table *tm.Table
}

TerminalTable represents a a terminal table to output.

func CreateTerminalTable

func CreateTerminalTable() TerminalTable

CreateTerminalTable creates a new terminal table.

func (*TerminalTable) AddRow

func (t *TerminalTable) AddRow(pattern string, args ...interface{})

func (*TerminalTable) Print

func (t *TerminalTable) Print()

Jump to

Keyboard shortcuts

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