aboutsummaryrefslogtreecommitdiff
path: root/src/output.rs
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2018-09-07 00:07:16 +0200
committerDaniel <kingdread@gmx.de>2018-09-07 00:07:16 +0200
commitb94272563e98ca268bcee800533ce851cce9c604 (patch)
treed510e70e85987a0bd47b1c1749b4366f31ecb3b8 /src/output.rs
parent92cc9192081a3fa5cc9e5846dfe7118f5b87ae42 (diff)
downloadraidgrep-b94272563e98ca268bcee800533ce851cce9c604.tar.gz
raidgrep-b94272563e98ca268bcee800533ce851cce9c604.tar.bz2
raidgrep-b94272563e98ca268bcee800533ce851cce9c604.zip
move output formatting to submodule
Diffstat (limited to 'src/output.rs')
-rw-r--r--src/output.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/output.rs b/src/output.rs
new file mode 100644
index 0000000..848eab5
--- /dev/null
+++ b/src/output.rs
@@ -0,0 +1,30 @@
+use super::LogResult;
+use super::errors::RuntimeError;
+
+use std::io::Write;
+
+/// Write the given log result to the given stream, using ANSI colors.
+pub fn colored<W: Write>(mut f: W, item: &LogResult) -> Result<(), RuntimeError> {
+ use colored::Colorize;
+ writeln!(f, "{}: {:?}", "File".green(), item.log_file)?;
+ writeln!(
+ f,
+ "{}: {} - {}: {}",
+ "Date".green(),
+ item.time,
+ "Boss".green(),
+ item.boss_name
+ )?;
+ for player in &item.players {
+ writeln!(
+ f,
+ " {:2} {:20} {:19} {}",
+ player.subgroup,
+ player.account_name.yellow(),
+ player.character_name.cyan(),
+ player.profession
+ )?;
+ }
+ writeln!(f)?;
+ Ok(())
+}