support overriding temp dir on command line
#[arg(short = 'b', long)]
identifier_bin: Option<PathBuf>,
+ /// Directory to store temporary files
+ #[arg(long)]
+ temp_dir: Option<PathBuf>,
+
/// Do not actually write metadata to file, but print which files
/// would have changed.
#[arg(short = 'n', long)]
}
}
+ fn temp_dir(&self) -> Option<PathBuf> {
+ match &self.cli {
+ Some(c) => c.temp_dir.clone(),
+ _ => Default::default(),
+ }
+ }
+
fn max_dimension(&self) -> u32 {
match self.max_dimension {
0 => std::u32::MAX,
let res = p.wait()
.map_err(|e| PwwError::Unknown(format!("Failed to wait for identifier binary: {}", e)))?;
if !res.success() {
- return Err(PwwError::Unknown("identifier binary failed to execute.".into()));
+ return Err(PwwError::Unknown("identifier binary exited with failure.".into()));
}
let mut s: String = String::new();
let mut stdout = p.stdout.ok_or_else(|| PwwError::Unknown(format!("Failed to get output from identifier binary")))?;
}
let i = Image::<u8, image2::Rgb>::open(&input_path)
.map_err(|_e| PwwError::InvalidImage)?;
- let temp_dir = config.temp_dir.clone()
+ let temp_dir = config.temp_dir().clone()
.unwrap_or(PathBuf::from(std::env::temp_dir()));
tmpfile = Some(tempfile::Builder::new()
.prefix("pww-")