Documentation
¶
Index ¶
- func HumanTimeElapsedSince(d time.Duration) string
- func InputFromEditor(placeholder string, pattern string, content string) (string, error)
- func ReadFileContents(file string) (string, error)
- func SetStructDefaults(data any) bool
- func ShortPath(path string) string
- func TryExtractJSONObject(s string, target any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HumanTimeElapsedSince ¶
humanTimeElapsedSince returns a human-friendly "in the past" representation of the given duration.
func InputFromEditor ¶
InputFromEditor retrieves user input by opening an editor (one specified by $EDITOR or 'vim' if $EDITOR is not set) on a temporary file. Once the editor closes, the contents of the file are read and the file is deleted. If the contents of the file exactly match the value of placeholder (no edits to the file were made), then an empty string is returned. Otherwise, the contents are returned. Example patten: message.*.md
func ReadFileContents ¶
ReadFileContents returns the string contents of the given file.
func SetStructDefaults ¶
SetStructDefaultValues checks for any nil ptr fields within the passed struct, and sets the values of those fields to the value that is defined by their "default" struct tag. Handles setting string, int, and bool values. Returns whether any changes were made to the struct.
func TryExtractJSONObject ¶
TryExtractJSONObject finds the first '{' in s and the first '}' after it, then unmarshals the enclosed substring into target. Useful for extracting a JSON object from an LLM response that may contain surrounding text or markdown fences. Does not handle nested objects
Types ¶
This section is empty.