blob: 5cb99f74ca60e69c3723763133e8d3da237769a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use std::fs;
use anyhow::Context;
use clap::Parser;
mod cli;
pub mod key_map;
use crate::{cli::Args, key_map::KeyMap};
fn main() -> Result<(), anyhow::Error> {
let args = Args::parse();
let keymap_file = fs::read_to_string(&args.path)
.with_context(|| format!("Failed to open keymap file at: '{}'.", args.path.display()))?;
let keymap: KeyMap = keymap_file
.parse()
.with_context(|| format!("Failed to parse keymap file at: {}", args.path.display()))?;
// println!("{keymap}");
// println!("Commands:");
for mut command in keymap.to_commands() {
// println!("Executing {command:?}");
let status = command
.status()
.with_context(|| format!("Failed to run command: '{command:?}'"))?;
if !status.success() {
eprintln!("Command ('{command:?}') returned with non zero exit code: {status}");
}
}
Ok(())
}
|