diff options
Diffstat (limited to 'src/output')
| -rw-r--r-- | src/output/formats.rs | 23 | ||||
| -rw-r--r-- | src/output/mod.rs | 5 | 
2 files changed, 23 insertions, 5 deletions
| diff --git a/src/output/formats.rs b/src/output/formats.rs index 5915069..b697401 100644 --- a/src/output/formats.rs +++ b/src/output/formats.rs @@ -2,6 +2,7 @@  use std::fmt::Write;  use super::{LogResult, FightOutcome}; +use super::super::guilds;  /// An output format  pub trait Format: Sync + Send { @@ -12,7 +13,9 @@ pub trait Format: Sync + Send {  /// The human readable, colored format.  #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub struct HumanReadable; +pub struct HumanReadable { +    pub show_guilds: bool, +}  impl Format for HumanReadable { @@ -35,14 +38,26 @@ impl Format for HumanReadable {              outcome,          ).unwrap();          for player in &item.players { -            writeln!( +            write!(                  result, -                "  {:2} {:20} {:19} {}", +                "  {:2} {:20} {:19} {:12}",                  player.subgroup,                  player.account_name.yellow(),                  player.character_name.cyan(), -                player.profession +                player.profession,              ).unwrap(); +            if self.show_guilds { +                let guild = player.guild_id.as_ref().and_then(|id| guilds::lookup(id)); +                if let Some(guild) = guild { +                    write!( +                        result, +                        " [{}] {}", +                        guild.tag().magenta(), +                        guild.name().magenta(), +                    ).unwrap(); +                } +            } +            writeln!(result).unwrap();          }          result      } diff --git a/src/output/mod.rs b/src/output/mod.rs index 73af5ab..84ed0a4 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -17,6 +17,9 @@ pub fn build_pipeline(opt: &Opt) -> Pipeline {      if opt.file_name_only {          Pipeline::new(stream, formats::FileOnly, aggregator)      } else { -        Pipeline::new(stream, formats::HumanReadable, aggregator) +        let format = formats::HumanReadable { +            show_guilds: opt.guilds, +        }; +        Pipeline::new(stream, format, aggregator)      }  } | 
