aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2021-11-06 22:36:28 +0100
committerDaniel Schadt <kingdread@gmx.de>2021-11-06 22:36:28 +0100
commit20c8574ab6b9db586ccc88e453cdb84fe44f1004 (patch)
tree55321aff573902fe39f83918d0f8d122fb347739 /src
parent834a2d4f8a7dbd0e9eb14573c4340eb41af04738 (diff)
downloadmodderbaas-20c8574ab6b9db586ccc88e453cdb84fe44f1004.tar.gz
modderbaas-20c8574ab6b9db586ccc88e453cdb84fe44f1004.tar.bz2
modderbaas-20c8574ab6b9db586ccc88e453cdb84fe44f1004.zip
add a dry-run mode to install
Diffstat (limited to 'src')
-rw-r--r--src/main.rs23
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)?;