Documentation ¶
Index ¶
- func AttemptPrettyPrint(chatMessage models.Message, username string) error
- func ClearTermTo(termWidth, upTo int)
- func CreateFile[T any](path string, toCreate *T) error
- func GetFirstTokens(prompt []string, n int) []string
- func LoadConfigFromFile[T any](placeConfigPath, configFileName string, migrationCb func(string) error, ...) (T, error)
- func Prompt(stdinReplace string, args []string) (string, error)
- func RandomPrefix() string
- func ReadAndUnmarshal[T any](filePath string, config *T) error
- func ReturnNonDefault[T comparable](a, b, defaultVal T) (T, error)
- func TerminalWidth() (int, error)
- func UpdateMessageTerminalMetadata(msg string, line *string, lineCount *int, termWidth int)
- func WillBeNewLine(line, msg string, termWidth int) bool
- func WriteFile[T any](path string, toWrite *T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttemptPrettyPrint ¶
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 GetFirstTokens ¶
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)
LoadConfigFromFile if config exists. If non existent, create a new config using default. Run migrationCb after config has been created or fetched
func Prompt ¶
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 ¶
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 TerminalWidth ¶
func UpdateMessageTerminalMetadata ¶
UpdateMessageTerminalMetadata updates the terminal metadata. Meaning the lineCount, to eventually clear the terminal
func WillBeNewLine ¶
Types ¶
This section is empty.