tics

package module
v0.0.0-...-94eb9c5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Perm = 0755

Variables

This section is empty.

Functions

func CobraRootInitBoilerPlate

func CobraRootInitBoilerPlate(confMap map[string]string, crashOnErr bool) map[string]string

Expects "confDir" and possibly a "dataDir" in the map argument; returns these same values with the $USER, $HOME, or '~' strings replaced with the actual $HOME value.

Left open to multiple data dirs in the future.

func Confirmed

func Confirmed(prompt string) bool

Wrapper around GetInput -- takes a string, gets input, and returns whether true.

func FileExists

func FileExists(path string) bool

Checks if file exists by tagging os.Stat; came about as tics needs a way to check which of the consuming CLIs' dependent files tripped the config error.

func GetDir

func GetDir(path string) []fs.FileInfo

func GetDirContents

func GetDirContents(dirName string) map[string]interface{}

func GetDirContentsExclusive

func GetDirContentsExclusive(dirName string, notExcludedByFunc func(string) bool) map[string]interface{}

func GetDirFiles

func GetDirFiles(path string) []string

func GetDirFilesExclusive

func GetDirFilesExclusive(path string, notExcludedByFunc func(string) bool) []string

func GetFile

func GetFile(path string) []byte

func GetInput

func GetInput() string

func IsValidInput

func IsValidInput(a string) bool

func Make

func Make(s string) *str

Creates an intermediate 'tic' for string chain processing. Call var.String() to unwrap out of the container.

func NotConfig

func NotConfig(name string) bool

func PrintInvalid

func PrintInvalid(inp string)

func PrintPrompt

func PrintPrompt(kind, toolName string)

func ReplaceHomeDir

func ReplaceHomeDir(s string, crashOnErr bool) string

Replaces the $USER / $HOME / ~ in the string arg and returns the str with actual system homeDir. Retains crashOnErr from the parent function, or from arg.

func RunConfPrompts

func RunConfPrompts(toolName string, confMap map[string]string, defaults []string)

Runs the interactive prompts that create the default config and data dirs where this given CLI lives.

func SearchInDirNames

func SearchInDirNames(dirPath, searchStr string) []string

func SelectBetween

func SelectBetween(explanation string, args []string) string

Literally just a wrapper around promptui, but reflects on errs, and is reusable for my libs.

func Throw

func Throw(err string)

func ThrowQuiet

func ThrowQuiet(s string)

func ThrowSys

func ThrowSys(funcCulprit interface{}, err error)

An unrecoverable error with a descriptive package pointer to what went wrong.

func ThrowTooFewArgs

func ThrowTooFewArgs(cmd string)

func ThrowTooManyArgs

func ThrowTooManyArgs(cmd string)

func ThrowUnhandled

func ThrowUnhandled(err error)

func ThrowX

func ThrowX(err error, desc string)

func ToJson

func ToJson(i interface{}) map[string]interface{}

Quick reusable json boiler, intended to be used on byte slices.

Types

This section is empty.

Jump to

Keyboard shortcuts

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