From e132410e7a526239389d3e8dedbcf5a84f0503b5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 18 May 2019 01:36:35 +0200 Subject: add support for -l to only output the file name --- src/output.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/output.rs') diff --git a/src/output.rs b/src/output.rs index fcbda1b..148c088 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,8 +1,18 @@ use super::errors::RuntimeError; -use super::{FightOutcome, LogResult}; +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(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(mut f: W, item: &LogResult) -> Result<(), RuntimeError> { use colored::Colorize; -- cgit v1.2.3