diff --git a/src/afterfact.rs b/src/afterfact.rs index f29ba76d..69d52d0e 100644 --- a/src/afterfact.rs +++ b/src/afterfact.rs @@ -3,7 +3,7 @@ use crate::detections::configs::TERM_SIZE; use crate::detections::print; use crate::detections::print::{AlertMessage, IS_HIDE_RECORD_ID}; use crate::detections::utils; -use crate::detections::utils::write_color_buffer; +use crate::detections::utils::{write_color_buffer, get_writable_color}; use bytesize::ByteSize; use chrono::{DateTime, Local, TimeZone, Utc}; use csv::QuoteStyle; @@ -379,11 +379,9 @@ fn emit_csv( } }; - disp_wtr_buf.clear(); - disp_wtr_buf.set_color(ColorSpec::new().set_fg(None)).ok(); - writeln!(disp_wtr_buf, "Results Summary:").ok(); - disp_wtr.print(&disp_wtr_buf).ok(); - + disp_wtr_buf.clear(); + write_color_buffer(disp_wtr, get_writable_color(Color::Green), "Results Summary:").ok(); + let terminal_width = match *TERM_SIZE { Some((Width(w), _)) => w as usize, None => 100, diff --git a/src/detections/utils.rs b/src/detections/utils.rs index 7f20781b..0ac7186c 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -252,6 +252,15 @@ pub fn write_color_buffer( wtr.print(&buf) } +/// no-colorのオプションの指定があるかを確認し、指定されている場合はNoneをかえし、指定されていない場合は引数で指定されたColorをSomeでラップして返す関数 +pub fn get_writable_color(color: Color) -> Option { + if configs::CONFIG.read().unwrap().args.no_color { + None + } else { + Some(color) + } +} + /** * CSVのrecord infoカラムに出力する文字列を作る */