diff --git a/src/commands/config.rs b/src/commands/config.rs index 63c3f2f40..d4444b1b6 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -4,7 +4,7 @@ use crate::{Application, RUSTIC_APP, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; -use anyhow::Result; +use anyhow::{Result, bail}; use rustic_core::ConfigOptions; @@ -29,6 +29,11 @@ impl ConfigCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); + // Handle dry-run mode + if config.global.dry_run { + bail!("cannot modify config in dry-run mode!",); + } + let changed = config .repository .run_open(|mut repo| Ok(repo.apply_config(&self.config_opts)?))?; diff --git a/src/commands/merge.rs b/src/commands/merge.rs index f5bd45f45..aadb6b55f 100644 --- a/src/commands/merge.rs +++ b/src/commands/merge.rs @@ -53,8 +53,13 @@ impl MergeCmd { repo.get_snapshots(&self.ids)? }; - let snap = SnapshotFile::from_options(&self.snap_opts)?; + // Handle dry-run mode + if config.global.dry_run { + println!("would have modified the following snapshots:\n {snapshots:?}"); + return Ok(()); + } + let snap = SnapshotFile::from_options(&self.snap_opts)?; let snap = repo.merge_snapshots(&snapshots, &last_modified_node, snap)?; if self.json {