utils

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttemptPrettyPrint

func AttemptPrettyPrint(chatMessage models.Message, username string, raw bool) error

AttemptPrettyPrint by first checking if the glow command is available, and if so, pretty print the chat message if not found, simply print the message as is

func ClearTermTo

func ClearTermTo(termWidth, upTo int)

func CreateFile

func CreateFile[T any](path string, toCreate *T) error

func GetFirstTokens

func GetFirstTokens(prompt []string, n int) []string

GetFirstTokens returns the first n tokens of the prompt, or the whole prompt if it has less than n tokens

func LoadConfigFromFile

func LoadConfigFromFile[T any](
	placeConfigPath,
	configFileName string,
	migrationCb func(string) error,
	dflt *T,
) (T, error)

func Prompt

func Prompt(stdinReplace string, args []string) (string, error)

Prompt returns the prompt by checking all the arguments and stdin. If there is no arguments, but data in stdin, stdin will become the prompt. If there are arguments and data in stdin, all stdinReplace tokens will be substituted with the data in stdin

func RandomPrefix

func RandomPrefix() string

func ReadAndUnmarshal

func ReadAndUnmarshal[T any](filePath string, config *T) error

ReadAndUnmarshal by first finding the file, then attempting to read + unmarshal to T

func ReturnNonDefault

func ReturnNonDefault[T comparable](a, b, defaultVal T) (T, error)

func TermWidth

func TermWidth() (int, error)

func UpdateMessageTerminalMetadata

func UpdateMessageTerminalMetadata(msg string, line *string, lineCount *int, termWidth int)

UpdateMessageTerminalMetadata updates the terminal metadata. Meaning the lineCount, to eventually clear the terminal

func WriteFile

func WriteFile[T any](path string, toWrite *T) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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