Sharprompt icon indicating copy to clipboard operation
Sharprompt copied to clipboard

refactor(Paginator): extract filtering of text input into Func

Open brianebeling opened this issue 1 year ago • 0 comments

Adds a new constructor parameter that accepts a function for filtering text input (i.e. how text is filtered when typing into a Select or MultiSelect Prompt). This allows developers to override the default behavior (in this case .Contains(keyword)) with custom behavior such as fuzzy matching. This helps with long inputs, where you may have multiple keywords or matches in your string but are unsure about the order or exact input.

Motivation

I wanted to use Sharprompt to develop an internal tool, where I wanted to prompt the user to select one or multiple work items from a DevOps board. Sometimes it helps to filter with a text input such as "deliv closed" to match the row "Title: Delivery Menu, Type: User Story, State: Closed" or similar. For my own use case I would like a fuzzy match akin to fzf but was unable to implement that because the behavior is hardcoded into the paginator.

The PR may not be perfect, so I created it as a draft. What are your thoughts on this?

brianebeling avatar Mar 17 '24 03:03 brianebeling