From 34b8b4c52e4afa8b854e6c3d37780ce5faf74c05 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 2 Feb 2025 18:14:33 +0100 Subject: refactor(modules/river): Migrate to `by-name` This includes a near rewrite `river-mk-keymap` (previously, `river_init_lesser`.) --- pkgs/by-name/ri/river-mk-keymap/src/main.rs | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pkgs/by-name/ri/river-mk-keymap/src/main.rs (limited to 'pkgs/by-name/ri/river-mk-keymap/src/main.rs') diff --git a/pkgs/by-name/ri/river-mk-keymap/src/main.rs b/pkgs/by-name/ri/river-mk-keymap/src/main.rs new file mode 100644 index 00000000..5cb99f74 --- /dev/null +++ b/pkgs/by-name/ri/river-mk-keymap/src/main.rs @@ -0,0 +1,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(()) +} -- cgit 1.4.1