Merge branch 'main' into 592-config-flag-seems-to-be-ignored

This commit is contained in:
DustInDark
2022-06-23 21:22:17 +09:00
20 changed files with 119 additions and 168 deletions

View File

@@ -331,7 +331,7 @@ impl AlertMessage {
/// ERRORメッセージを表示する関数
pub fn alert(contents: &str) -> io::Result<()> {
write_color_buffer(
BufferWriter::stderr(ColorChoice::Always),
&BufferWriter::stderr(ColorChoice::Always),
None,
&format!("[ERROR] {}", contents),
)
@@ -340,7 +340,7 @@ impl AlertMessage {
/// WARNメッセージを表示する関数
pub fn warn(contents: &str) -> io::Result<()> {
write_color_buffer(
BufferWriter::stderr(ColorChoice::Always),
&BufferWriter::stderr(ColorChoice::Always),
None,
&format!("[WARN] {}", contents),
)

View File

@@ -242,7 +242,7 @@ pub fn create_rec_info(data: Value, path: String, keys: &[String]) -> EvtxRecord
* 標準出力のカラー出力設定を指定した値に変更し画面出力を行う関数
*/
pub fn write_color_buffer(
wtr: BufferWriter,
wtr: &BufferWriter,
color: Option<Color>,
output_str: &str,
) -> io::Result<()> {
@@ -252,6 +252,15 @@ pub fn write_color_buffer(
wtr.print(&buf)
}
/// no-colorのオプションの指定があるかを確認し、指定されている場合はNoneをかえし、指定されていない場合は引数で指定されたColorをSomeでラップして返す関数
pub fn get_writable_color(color: Option<Color>) -> Option<Color> {
if configs::CONFIG.read().unwrap().args.no_color {
None
} else {
color
}
}
/**
* CSVのrecord infoカラムに出力する文字列を作る
*/