pub struct FuzzySelect<'a> { /* private fields */ }
Expand description

Renders a selection menu that user can fuzzy match to reduce set.

User can use fuzzy search to limit selectable items. Interaction returns index of an item selected in the order they appear in item invocation or items slice.

Examples

use dialoguer::{
    FuzzySelect,
    theme::ColorfulTheme
};
use console::Term;

fn main() -> std::io::Result<()> {
    let items = vec!["Item 1", "item 2"];
    let selection = FuzzySelect::with_theme(&ColorfulTheme::default())
        .items(&items)
        .default(0)
        .interact_on_opt(&Term::stderr())?;

    match selection {
        Some(index) => println!("User selected item : {}", items[index]),
        None => println!("User did not select anything")
    }

    Ok(())
}

Implementations

Creates the prompt with a specific text.

Sets the clear behavior of the menu.

The default is to clear the menu.

Sets a default for the menu

Add a single item to the fuzzy selector.

Adds multiple items to the fuzzy selector.

Prefaces the menu with a prompt.

When a prompt is set the system also prints out a confirmation after the fuzzy selection.

Indicates whether to report the selected value after interaction.

The default is to report the selection.

Indicates whether to highlight matched indices

The default is to highlight the indices

Enables user interaction and returns the result.

The user can select the items using ‘Enter’ and the index of selected item will be returned. The dialog is rendered on stderr. Result contains index of selected item if user hit ‘Enter’. This unlike interact_opt does not allow to quit with ‘Esc’ or ‘q’.

Enables user interaction and returns the result.

The user can select the items using ‘Enter’ and the index of selected item will be returned. The dialog is rendered on stderr. Result contains Some(index) if user hit ‘Enter’ or None if user cancelled with ‘Esc’ or ‘q’.

Like interact but allows a specific terminal to be set.

Like interact but allows a specific terminal to be set.

Same as new but with a specific theme.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.