diff options
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 5df16a2..bff0fe0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,12 @@ fn main() -> Result<()> { .short("t") .long("target-dir") .default_value("."), + ) + .arg( + Arg::with_name("dry-run") + .short("n") + .long("dry-run") + .required(false), ), ) .get_matches(); @@ -68,8 +74,7 @@ fn main() -> Result<()> { if let Some(install) = matches.subcommand_matches("install") { let mods = install.values_of("mod").unwrap().collect::<Vec<_>>(); - let target_dir = install.value_of("target").unwrap(); - install_mods(&mut stdout, &snapshot, &world, &mods, Path::new(target_dir))?; + install_mods(&mut stdout, &snapshot, &world, &mods, install)?; } Ok(()) @@ -183,8 +188,11 @@ fn install_mods( snapshot: &Snapshot, world: &World, mods: &[&str], - target_dir: &Path, + matches: &ArgMatches, ) -> Result<()> { + let target_dir = &Path::new(matches.value_of("target").unwrap()); + let dry_run = matches.is_present("dry-run"); + let content_db = ContentDb::new(); let downloader = Downloader::new()?; let mut wanted = mods @@ -266,6 +274,15 @@ fn install_mods( ask_continue(output)?; + if dry_run { + for m in to_install { + let mod_id = m.mod_id()?; + let mod_dir = target_dir.join(&mod_id); + writeln!(output, "Installing {} to {:?}", mod_id, mod_dir)?; + } + return Ok(()); + } + for m in to_install { let mod_id = m.mod_id()?; writeln!(output, "Installing {}", mod_id)?; |