From 65c1124f25f3674087e7c32898aa0406351889ff Mon Sep 17 00:00:00 2001 From: William Date: Sun, 1 Oct 2023 17:13:02 +0100 Subject: [PATCH] Fix default output path for extraction being cwd --- fastgmad-lib/src/extract/conf.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fastgmad-lib/src/extract/conf.rs b/fastgmad-lib/src/extract/conf.rs index 89cb4f7..35fab42 100644 --- a/fastgmad-lib/src/extract/conf.rs +++ b/fastgmad-lib/src/extract/conf.rs @@ -74,7 +74,20 @@ impl ExtractGmaConfig { _ => return Err(PrintHelp(Some("Unknown GMAD extraction argument"))), } } - Ok((config, r#in.ok_or(PrintHelp(Some("Please provide an output path")))?)) + + let r#in = r#in.ok_or(PrintHelp(Some("Please provide an input path")))?; + + if config.out.as_os_str().is_empty() { + if let ExtractGmadIn::File(path) = &r#in { + let mut dir = path.to_owned(); + dir.set_extension(""); + if !dir.exists() || dir.is_dir() { + config.out = dir; + } + } + } + + Ok((config, r#in)) } } impl Default for ExtractGmaConfig {