cloud_terrastodon_user_input 0.35.1

Helper functions for interacting with users in the terminal
Documentation
use cloud_terrastodon_user_input::Choice;
use cloud_terrastodon_user_input::PickerTui;

pub fn main() -> eyre::Result<()> {
    let mut choices = Vec::new();
    let dir = std::fs::read_dir(".")?;
    for entry in dir {
        let entry = entry?;
        choices.push(entry);
    }

    let chosen = PickerTui::new()
        .set_header("Pick a path")
        .pick_one(choices.into_iter().map(|entry| Choice {
            key: entry.path().display().to_string(), // the value shown to the user
            value: entry, // the inner value we want to have after the user picks
        }))?;

    println!("You chose {}", chosen.file_name().to_string_lossy());

    Ok(())
}