Documentation
¶
Overview ¶
Package prompt provides interactive CLI prompts for user input.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoResources = errors.New("no resources to select from") ErrInvalidSelection = errors.New("invalid selection") ErrSelectionCancelled = errors.New("selection cancelled") )
Sentinel errors for resource selection.
Functions ¶
Types ¶
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector handles interactive resource selection prompts.
func NewSelector ¶
func NewSelector() *Selector
NewSelector creates a new Selector using stdin and stdout.
func NewSelectorWithIO ¶
NewSelectorWithIO creates a Selector with custom reader and writer for testing.
func (*Selector) SelectResource ¶
func (s *Selector) SelectResource(query string, resources []resource.Resource) (*resource.Resource, error)
SelectResource prompts the user to choose from a list of resources.
Returns:
- ErrNoResources if the list is empty
- The resource if only one exists (auto-selects without prompting)
- The selected resource based on user input
- ErrInvalidSelection if the selection is out of range
- ErrSelectionCancelled if input is EOF (e.g., Ctrl+D)
Click to show internal directories.
Click to hide internal directories.