aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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}"
+ );
+ }
}
}
}