Skip to content

Commit 1703045

Browse files
committed
fix: do not create unnecessary output file
1 parent 6a14a63 commit 1703045

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/afterfact.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,19 @@ pub fn init_writer(stored_static: &StoredStatic) -> AfterfactWriter {
165165

166166
let mut display_flag = false;
167167
let target: Box<dyn io::Write> = if let Some(path) = &stored_static.output_path {
168-
// output to file
169-
match File::create(path) {
170-
Ok(file) => Box::new(BufWriter::new(file)),
171-
Err(err) => {
172-
AlertMessage::alert(&format!("Failed to open file. {err}")).ok();
173-
process::exit(1);
168+
if matches!(
169+
stored_static.config.action.as_ref().unwrap(),
170+
Action::PivotKeywordsList(_) | Action::LogonSummary(_)
171+
) {
172+
Box::new(BufWriter::new(io::stdout()))
173+
} else {
174+
// output to file
175+
match File::create(path) {
176+
Ok(file) => Box::new(BufWriter::new(file)),
177+
Err(err) => {
178+
AlertMessage::alert(&format!("Failed to open file. {err}")).ok();
179+
process::exit(1);
180+
}
174181
}
175182
}
176183
} else {

0 commit comments

Comments
 (0)