changed "Results Summary:" color to Green #595

This commit is contained in:
DustInDark
2022-06-22 17:04:52 +09:00
parent 91a89a42ad
commit dfde18860f
2 changed files with 13 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ use crate::detections::configs::TERM_SIZE;
use crate::detections::print; use crate::detections::print;
use crate::detections::print::{AlertMessage, IS_HIDE_RECORD_ID}; use crate::detections::print::{AlertMessage, IS_HIDE_RECORD_ID};
use crate::detections::utils; 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 bytesize::ByteSize;
use chrono::{DateTime, Local, TimeZone, Utc}; use chrono::{DateTime, Local, TimeZone, Utc};
use csv::QuoteStyle; use csv::QuoteStyle;
@@ -379,11 +379,9 @@ fn emit_csv<W: std::io::Write>(
} }
}; };
disp_wtr_buf.clear(); disp_wtr_buf.clear();
disp_wtr_buf.set_color(ColorSpec::new().set_fg(None)).ok(); write_color_buffer(disp_wtr, get_writable_color(Color::Green), "Results Summary:").ok();
writeln!(disp_wtr_buf, "Results Summary:").ok();
disp_wtr.print(&disp_wtr_buf).ok();
let terminal_width = match *TERM_SIZE { let terminal_width = match *TERM_SIZE {
Some((Width(w), _)) => w as usize, Some((Width(w), _)) => w as usize,
None => 100, None => 100,

View File

@@ -252,6 +252,15 @@ pub fn write_color_buffer(
wtr.print(&buf) wtr.print(&buf)
} }
/// no-colorのオプションの指定があるかを確認し、指定されている場合はNoneをかえし、指定されていない場合は引数で指定されたColorをSomeでラップして返す関数
pub fn get_writable_color(color: Color) -> Option<Color> {
if configs::CONFIG.read().unwrap().args.no_color {
None
} else {
Some(color)
}
}
/** /**
* CSVのrecord infoカラムに出力する文字列を作る * CSVのrecord infoカラムに出力する文字列を作る
*/ */