pick_a_path/
pick_a_path.rs1use cloud_terrastodon_user_input::Choice;
2use cloud_terrastodon_user_input::FzfArgs;
3use cloud_terrastodon_user_input::pick;
4
5pub fn main() -> eyre::Result<()> {
6 let mut choices = Vec::new();
7 let mut dir = std::fs::read_dir(".")?;
8 while let Some(entry) = dir.next() {
9 let entry = entry?;
10 choices.push(entry);
11 }
12
13 let chosen = pick(FzfArgs {
14 choices: choices
15 .into_iter()
16 .map(|entry| Choice {
17 key: entry.path().display().to_string(), value: entry, })
20 .collect(),
21 header: Some("Pick a path".to_string()),
22 ..Default::default()
23 })?;
24
25 println!("You chose {}", chosen.file_name().to_string_lossy());
26
27 Ok(())
28}