aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-29 10:56:35 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-29 10:56:35 +0200
commitea9316f04f87a9011f7e554a3093aba78e3a81b4 (patch)
tree53e1403c1bfe92c42af3e6b1c111356fe95dee4c /pkgs
parentpkgs/river-mk-keymap: Improve with key-chord support and which-key interface (diff)
downloadnixos-config-ea9316f04f87a9011f7e554a3093aba78e3a81b4.zip
pkgs/river-mk-keymap: Support a dry-run mode
This can be used to check that the keymap.json file is valid, before deploying it.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/by-name/ri/river-mk-keymap/src/cli.rs6
-rw-r--r--pkgs/by-name/ri/river-mk-keymap/src/main.rs20
2 files changed, 17 insertions, 9 deletions
diff --git a/pkgs/by-name/ri/river-mk-keymap/src/cli.rs b/pkgs/by-name/ri/river-mk-keymap/src/cli.rs
index 61646cfd..ad872cc9 100644
--- a/pkgs/by-name/ri/river-mk-keymap/src/cli.rs
+++ b/pkgs/by-name/ri/river-mk-keymap/src/cli.rs
@@ -26,6 +26,10 @@ pub(super) struct Args {
#[derive(clap::Subcommand, Clone, Debug)]
pub(super) enum SubCommand {
- Init {},
+ Init {
+ #[arg(short, long, default_value_t = false)]
+ /// Only show what would be done, don't actually perform the init.
+ dry_run: bool,
+ },
ShowHelp {},
}
diff --git a/pkgs/by-name/ri/river-mk-keymap/src/main.rs b/pkgs/by-name/ri/river-mk-keymap/src/main.rs
index 7d7736b9..18c291cf 100644
--- a/pkgs/by-name/ri/river-mk-keymap/src/main.rs
+++ b/pkgs/by-name/ri/river-mk-keymap/src/main.rs
@@ -45,17 +45,21 @@ fn main() -> Result<(), anyhow::Error> {
};
match args.command {
- cli::SubCommand::Init {} => {
+ cli::SubCommand::Init { dry_run } => {
println!("{config}");
- // println!("Commands:");
for mut command in config.to_commands(keymap_path)? {
- // println!("{command:?}");
- let status = command
- .status()
- .with_context(|| format!("Failed to run command: '{command:?}'"))?;
+ if dry_run {
+ println!("{command:?}");
+ } else {
+ 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}");
+ if !status.success() {
+ eprintln!(
+ "Command ('{command:?}') returned with non zero exit code: {status}"
+ );
+ }
}
}
}