fuzzy_multi_select

Function fuzzy_multi_select 

Source
pub fn fuzzy_multi_select<T: ToString>(
    prompt: &str,
    items: &[T],
    defaults: &[usize],
    no_color: bool,
) -> Result<Vec<usize>>
Expand description

Performs a multi-selection with fuzzy search capability.

Displays a searchable list where users can:

  • Type to filter options with fuzzy matching
  • Use Space to toggle selection
  • Use arrow keys to navigate
  • Press Enter to confirm

§Arguments

  • prompt - The prompt message to display
  • items - The list of items to choose from
  • defaults - Indices of items to pre-select
  • no_color - Whether to disable colored output

§Returns

  • Result<Vec<usize>> - Indices of the selected items

§Errors

Returns CliError::User if:

  • User cancels the prompt (Ctrl+C)
  • Terminal interaction fails

Returns CliError::Validation if:

  • No items are selected

§Examples

use sublime_cli_tools::interactive::select::fuzzy_multi_select;

let packages = vec!["pkg-a", "pkg-b", "pkg-c"];
let defaults = vec![0]; // Pre-select first item
let selections = fuzzy_multi_select("Select packages", &packages, &defaults, false)?;