Skip to content

Commit ef85207

Browse files
committed
fix: validate --output requirement before printing any output
Check for required --output argument at the start of cmd_load() so we fail cleanly without printing partial output first.
1 parent b8f92ab commit ef85207

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/uffs-mft/src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,11 @@ async fn cmd_load(input: &Path, output: Option<&Path>, info_only: bool) -> Resul
20462046

20472047
use uffs_mft::{MftReader, load_raw_mft_header};
20482048

2049+
// Validate arguments upfront - don't print anything if we're going to fail
2050+
if !info_only && output.is_none() {
2051+
anyhow::bail!("--output is required when not using --info-only");
2052+
}
2053+
20492054
let start_time = Instant::now();
20502055

20512056
// Load header first
@@ -2183,8 +2188,8 @@ async fn cmd_load(input: &Path, output: Option<&Path>, info_only: bool) -> Resul
21832188
return Ok(());
21842189
}
21852190

2186-
// Parse and export
2187-
let output = output.context("--output is required when not using --info-only")?;
2191+
// Parse and export (output is guaranteed to be Some by upfront validation)
2192+
let output = output.expect("output validated at function start");
21882193

21892194
// Determine output format from extension
21902195
let ext = output

0 commit comments

Comments
 (0)