make deck selection more intuitive

This commit is contained in:
andromeda
2026-04-15 11:47:13 +02:00
parent dfe95e2a89
commit a6afe8626b

View File

@@ -22,7 +22,14 @@ fn main() {
fn init(anki: &AnkiClient) {
clear_screen();
display_prompt_text("Name des Stapels: ");
let decks = anki.request(DeckNamesRequest {}).unwrap();
for (index, title) in decks.clone().into_iter().enumerate() {
// 0th index is Default, which is not predictable
if index > 0 {
println!("{:?}: {}", index, title);
}
}
display_prompt_text("deck index:");
let mut input = "".to_string();
loop {
match event::read().unwrap() {
@@ -34,7 +41,10 @@ fn init(anki: &AnkiClient) {
_ => (),
}
}
anki.request(GuiDeckReviewRequest { name: input }).unwrap();
anki.request(GuiDeckReviewRequest {
name: decks[input.parse::<usize>().unwrap()].clone(),
})
.unwrap();
}
fn prompt(anki: &AnkiClient) {