allow for more config and cli args

This commit is contained in:
2025-05-28 17:33:00 +02:00
parent 5905bd6b15
commit af002b0149
5 changed files with 302 additions and 107 deletions

View File

@@ -22,6 +22,7 @@ enum Action {
MoveDown,
MoveUp,
Select,
Exit,
}
#[derive(Default)]
@@ -59,7 +60,7 @@ fn get_input() -> Option<Action> {
KeyCode::Char('j') => Action::MoveDown,
KeyCode::Char('k') => Action::MoveUp,
KeyCode::Enter => Action::Select,
KeyCode::Char('q') => exit(),
KeyCode::Char('q') => Action::Exit,
_ => return None,
}),
Err(e) => {
@@ -83,9 +84,6 @@ fn exit() -> ! {
std::process::exit(1);
}
// pub fn multi_select(entries: &[Entry]) -> Result<Vec<u16>, std::io::Error> {
// }
pub fn select(entries: &[Entry]) -> Result<u16, std::io::Error> {
let (width, height) = terminal::size()?;
let mut stdout = io::stdout();
@@ -125,6 +123,14 @@ pub fn select(entries: &[Entry]) -> Result<u16, std::io::Error> {
.flush()?;
return Ok(selected);
}
Action::Exit => {
stdout
.queue(MoveTo(0, 0))?
.queue(Clear(ClearType::All))?
.queue(Show)?
.flush()?;
exit();
}
}
stdout.queue(MoveTo(0, selected))?;
}