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

Renders a multi select prompt.

Example usage

use dialoguer::MultiSelect;

let items = vec!["Option 1", "Option 2"];
let chosen : Vec<usize> = MultiSelect::new()
    .items(&items)
    .interact()?;

Implementations

Creates a multi select prompt.

Sets the clear behavior of the menu.

The default is to clear the menu.

Sets a defaults for the menu.

Sets an optional max length for a page

Max length is disabled by None

Add a single item to the selector.

Add a single item to the selector with a default checked state.

Adds multiple items to the selector.

Adds multiple items to the selector with checked state

Prefaces the menu with a prompt.

By default, when a prompt is set the system also prints out a confirmation after the selection. You can opt-out of this with report.

Indicates whether to report the selected values after interaction.

The default is to report the selections.

Enables user interaction and returns the result.

The user can select the items with the ‘Space’ bar and on ‘Enter’ the indices of selected items will be returned. The dialog is rendered on stderr. Result contains Vec<index> 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 with the ‘Space’ bar and on ‘Enter’ the indices of selected items will be returned. The dialog is rendered on stderr. Result contains Some(Vec<index>) if user hit ‘Enter’ or None if user cancelled with ‘Esc’ or ‘q’.

Like interact but allows a specific terminal to be set.

Examples
 use dialoguer::MultiSelect;
 use console::Term;

 fn main() -> std::io::Result<()> {
     let selections = MultiSelect::new()
         .item("Option A")
         .item("Option B")
         .interact_on(&Term::stderr())?;

     println!("User selected options at indices {:?}", selections);

     Ok(())
 }

Like interact_opt but allows a specific terminal to be set.

Examples
use dialoguer::MultiSelect;
use console::Term;

fn main() -> std::io::Result<()> {
    let selections = MultiSelect::new()
        .item("Option A")
        .item("Option B")
        .interact_on_opt(&Term::stdout())?;

    match selections {
        Some(positions) => println!("User selected options at indices {:?}", positions),
        None => println!("User exited using Esc or q")
    }

    Ok(())
}

Creates a multi select prompt 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.