diff options
author | Daniel <kingdread@gmx.de> | 2019-06-03 02:02:44 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2019-06-03 02:02:44 +0200 |
commit | 5d2f51ab8593946a0f24db367a887a37258901d5 (patch) | |
tree | 498f2af9584046ed63f256375169bbf5756bfb7d /src/output.rs | |
parent | c731b470fc162e56f6d81c475bacb41230a5e2d3 (diff) | |
download | raidgrep-5d2f51ab8593946a0f24db367a887a37258901d5.tar.gz raidgrep-5d2f51ab8593946a0f24db367a887a37258901d5.tar.bz2 raidgrep-5d2f51ab8593946a0f24db367a887a37258901d5.zip |
[WIP] rewrite output logic as a pipeline
Diffstat (limited to 'src/output.rs')
-rw-r--r-- | src/output.rs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/output.rs b/src/output.rs deleted file mode 100644 index 148c088..0000000 --- a/src/output.rs +++ /dev/null @@ -1,45 +0,0 @@ -use super::errors::RuntimeError; -use super::{FightOutcome, LogResult, Opt}; - -use std::io::Write; - -/// Write the output to the given stream, according to the command line flags. -pub fn output<W: Write>(mut f: W, opt: &Opt, item: &LogResult) -> Result<(), RuntimeError> { - if opt.file_name_only { - writeln!(f, "{}", item.log_file.to_string_lossy())?; - } else { - colored(f, item)?; - } - Ok(()) -} - -/// 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)?; - let outcome = match item.outcome { - FightOutcome::Success => "SUCCESS".green(), - FightOutcome::Wipe => "WIPE".red(), - }; - writeln!( - f, - "{}: {} - {}: {} {}", - "Date".green(), - item.time.format("%Y-%m-%d %H:%M:%S %a"), - "Boss".green(), - item.boss_name, - outcome, - )?; - 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(()) -} |