Documentation
¶
Index ¶
- Variables
- func AttemptPrettyPrint(chatMessage models.Message, username string, raw bool) error
- func ClearTermTo(termWidth, upTo int)
- func CreateConfigDir(configPath string) error
- func CreateFile[T any](path string, toCreate *T) error
- func DeleteRange[T any](s []T, start, end int) ([]T, error)
- func GetClaiConfigDir() (string, 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 ReadUserInput() (string, error)
- func ReplaceTildeWithHome(s string) (string, error)
- func ReturnNonDefault[T comparable](a, b, defaultVal T) (T, error)
- func TermWidth() (int, error)
- func UpdateMessageTerminalMetadata(msg string, line *string, lineCount *int, termWidth int)
- func WriteFile[T any](path string, toWrite *T) error
Constants ¶
This section is empty.
Variables ¶
var ErrUserInitiatedExit = errors.New("user exit")
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 CreateConfigDir ¶
func CreateFile ¶
func DeleteRange ¶
DeleteRange removes elements in [start, end] (inclusive) from the slice and returns the new slice. Panics if indices are invalid. Works for any slice type (Go 1.18+).
func GetClaiConfigDir ¶
GetClaiConfigDir returns the path to the clai configuration directory. The directory is located inside the user's configuration directory as <UserConfigDir>/.clai.
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 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 ReadUserInput ¶
ReadUserInput and return on interrupt channel
func ReplaceTildeWithHome ¶
func ReturnNonDefault ¶
func ReturnNonDefault[T comparable](a, b, defaultVal T) (T, error)
func UpdateMessageTerminalMetadata ¶
UpdateMessageTerminalMetadata updates the terminal metadata. Meaning the lineCount, to eventually clear the terminal
Types ¶
This section is empty.