make deck selection more intuitive
This commit is contained in:
14
src/main.rs
14
src/main.rs
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user