$ show erikgeiser/promptkit
Promptkit is a Go library for building interactive command-line prompts. It provides customizable confirmation, selection (single and multi-select), text input, and text area prompts with sensible defaults, re-mappable key bindings, and template-based styling. Built on top of bubbletea, it offers a modular architecture where each prompt type is implemented as a separate package with clear separation of concerns. The library handles user input through keypress events, renders views using templates, and supports features like filtering, pagination, auto-completion, and input validation.
The LLM identified 3 files worth highlighting for reuse:
Provides UtilFuncMap() returning a template.FuncMap with handy utility functions for prompt templates. Includes ANSI-aware string length calculation, common mathematical operations, and string manipulation functions. This isolated utility can be extracted and used in any Go project utilizing text/template with minimal dependencies.
Implements auto-completion functions with case-sensitive and case-insensitive variants, plus versions that provide default values for empty input. The core algorithm efficiently filters suggestions based on prefix matching. This self-contained package has minimal dependencies (only sort and strings) and can be reused in any text input scenario requiring auto-completion functionality.
Defines a generic Choice[T] type that wraps values with metadata (index and string representation) and provides asChoices[T] for converting slices. Demonstrates skilled use of Go generics to create a typesafe selection UI component that preserves original values while providing string representation logic. This isolated pattern could be used in any selection UI implementation with zero external dependencies beyond fmt.