diff --git a/README.md b/README.md index 37166c0..d55e8e3 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Make sure that the input file is at the end. The file format is detected from th |Long|Short|Description| |----|-----|-----------| -|`--output`|`-o`|Designate the output path| +|`--output`|`-o`|Designate the output directory path| |`--size`|`-s`|Designate how many blocks long the longest axis of the model is. Default is 1 model unit = 1 block.| |`--scale`|`-S`|Specify a units-to-blocks ratio. Defaults to 1.| |`--block`|`-b`|Specify what block the shell of the model will be. Defaults to stone.| diff --git a/src/bin/main.rs b/src/bin/main.rs index 3a2160f..49d2485 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -90,6 +90,12 @@ The largest difference between versions is pre- and post-1.13 (1241 vs 1626): th ) .get_matches_from(env::args()); + let path_prefix = matches + .value_of("output") + .map(|s| s.to_string()) + .unwrap_or_default(); + let path_prefix = Path::new(&path_prefix); + let config = AppConfig::from_argmatch(matches)?; log::info!("Spawning {} threads", config.threads); @@ -105,7 +111,8 @@ The largest difference between versions is pre- and post-1.13 (1241 vs 1626): th // Output nbt to file. - let output_path = path.join(Path::new(&format!("{}.{}", file_stem, file_ending))); + std::fs::create_dir_all(path_prefix); + let output_path = path_prefix.join(&format!("{}.{}", file_stem, file_ending)); log::info!("Writing to '{}'", output_path.to_str().unwrap()); let mut file = File::create(output_path.clone())