#[path = "./backend/mod.rs"]
mod backend;
#[path = "./action.rs"]
mod action;
use crate::backend::{print, quit, run};
use action::Action;
use keymap::KeyMapConfig;
fn main() -> std::io::Result<()> {
println!("# Example: Using the KeyMap derive macro");
let config = Action::keymap_config();
run(|key| match config.get(&key) {
Some(action) => match action {
Action::Quit => quit("quit!"),
Action::Shoot(_) => print("Shoot! (Use .get_bound() to capture the character)"),
Action::Jump | Action::Up | Action::Down | Action::Left | Action::Right => print(
&format!("{action:?} = {}", action.keymap_item().description),
),
},
None => print(&format!("Unknown key {key:?}")),
})
}