aboutsummaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-04-06 14:43:28 +0200
committerDaniel <kingdread@gmx.de>2020-04-06 14:43:28 +0200
commita304370df4f998f7054731bac173113f91bf5cb1 (patch)
treeaab806f530e8871dbc35368e021485dc02265c54 /src/output
parentf7a0f17ce47e15f4cb39b49fecf4e252ce7897c3 (diff)
downloadraidgrep-a304370df4f998f7054731bac173113f91bf5cb1.tar.gz
raidgrep-a304370df4f998f7054731bac173113f91bf5cb1.tar.bz2
raidgrep-a304370df4f998f7054731bac173113f91bf5cb1.zip
implement guild display & filtering options
Filtering based on guilds is slow, as it will have to retrieve every guild name from the GW2 API, and it has to parse every log file instead of bailing early. Therefore, guilds are not searched by default, and have to be explicitely turned on with --guilds. In addition, this means that raidgrep will now need network access when --guilds is passed, which was not the case before.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/formats.rs23
-rw-r--r--src/output/mod.rs5
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)
}
}