diff options
author | Daniel <kingdread@gmx.de> | 2020-04-26 11:45:37 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-04-26 11:45:37 +0200 |
commit | 13053073e3336b8e6ffefd6a056d159239550be7 (patch) | |
tree | 63544e8764b55563a48d3f9fd530b0381f42a277 /src/output | |
parent | 3c429432382dfad6d4ac97349c96e4a4eb292089 (diff) | |
parent | 9bbd5db2a6caae10f0ab2cf2625fbc34485a4ce9 (diff) | |
download | raidgrep-13053073e3336b8e6ffefd6a056d159239550be7.tar.gz raidgrep-13053073e3336b8e6ffefd6a056d159239550be7.tar.bz2 raidgrep-13053073e3336b8e6ffefd6a056d159239550be7.zip |
Merge branch 'new-filters'
The new filter system (includes both the internal rewrite and the
command line parsing) is now being included in master. This gives a lot
more flexibility.
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/aggregators.rs | 2 | ||||
-rw-r--r-- | src/output/formats.rs | 15 | ||||
-rw-r--r-- | src/output/mod.rs | 2 |
3 files changed, 8 insertions, 11 deletions
diff --git a/src/output/aggregators.rs b/src/output/aggregators.rs index 5d0429c..1b04af3 100644 --- a/src/output/aggregators.rs +++ b/src/output/aggregators.rs @@ -15,12 +15,10 @@ pub trait Aggregator: Sync { fn finish(self, format: &dyn Format, stream: &mut dyn Write); } - /// An aggregator that just pushes through each item to the output stream without any sorting or /// whatsoever. pub struct WriteThrough; - impl Aggregator for WriteThrough { fn push_item(&self, item: &LogResult, format: &dyn Format, stream: &mut dyn Write) { let text = format.format_result(item); diff --git a/src/output/formats.rs b/src/output/formats.rs index b697401..a608eab 100644 --- a/src/output/formats.rs +++ b/src/output/formats.rs @@ -1,8 +1,8 @@ //! A crate defining different output formats for search results. use std::fmt::Write; -use super::{LogResult, FightOutcome}; use super::super::guilds; +use super::{FightOutcome, LogResult}; /// An output format pub trait Format: Sync + Send { @@ -10,14 +10,12 @@ pub trait Format: Sync + Send { fn format_result(&self, item: &LogResult) -> String; } - /// The human readable, colored format. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct HumanReadable { pub show_guilds: bool, } - impl Format for HumanReadable { fn format_result(&self, item: &LogResult) -> String { use colored::Colorize; @@ -36,7 +34,8 @@ impl Format for HumanReadable { "Boss".green(), item.boss_name, outcome, - ).unwrap(); + ) + .unwrap(); for player in &item.players { write!( result, @@ -45,7 +44,8 @@ impl Format for HumanReadable { player.account_name.yellow(), player.character_name.cyan(), player.profession, - ).unwrap(); + ) + .unwrap(); if self.show_guilds { let guild = player.guild_id.as_ref().and_then(|id| guilds::lookup(id)); if let Some(guild) = guild { @@ -54,7 +54,8 @@ impl Format for HumanReadable { " [{}] {}", guild.tag().magenta(), guild.name().magenta(), - ).unwrap(); + ) + .unwrap(); } } writeln!(result).unwrap(); @@ -63,12 +64,10 @@ impl Format for HumanReadable { } } - /// A format which outputs only the file-name #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct FileOnly; - impl Format for FileOnly { fn format_result(&self, item: &LogResult) -> String { let filename = item.log_file.to_string_lossy(); diff --git a/src/output/mod.rs b/src/output/mod.rs index aadcbf9..0fd92d9 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -2,8 +2,8 @@ use super::{FightOutcome, LogResult, Opt}; use std::io; -pub mod formats; pub mod aggregators; +pub mod formats; pub mod pipeline; pub use self::pipeline::Pipeline; |