#command-line #select #cli #radio-button #select-box

cli_select

A crate build on top of crossterm to provide a simple customizable select dialog for the command line

7 releases

0.1.6 Oct 15, 2023
0.1.5 Sep 30, 2023
0.1.4 Jan 29, 2022

#8 in #select

41 downloads per month
Used in aes_rust

MIT license

16KB
340 lines

cli_select

A crate build on top of crossterm to provide a simple customizable select dialog for the command line.


Example

Cargo.toml

[dependencies]
cli_select = "0.1.4"

Basic

main.rs

use cli_select::Select;

fn main() {

    let items = vec!["item1", "item2", "item3"];

    let select = Select::new(&items);

    let selected_item = select.start();

    println!("You selected: {}", selected_item);
}

Output

> item1
  item2
  item3
  You selected: item1

Customized

main.rs


use cli_select::Select;

fn main() {

    let items = vec!["item1", "item2", "item3"];

    let select = Select::new(&items);

    let selected_item = select        
        .pointer('')
        .not_selected_pointer('🞅')
        .move_selected_item_forward()
        .start();

    println!("You selected: {}", selected_item);
}

Output

◉  item1
🞅 item2
🞅 item3
You selected: item1

Dependencies

~0.8–8MB
~62K SLoC