diff --git a/src/indent.rs b/src/indent.rs index c8c93ca..ff3595f 100644 --- a/src/indent.rs +++ b/src/indent.rs @@ -111,15 +111,17 @@ pub fn apply_indent( logs: &mut Vec, pass: Option, ) -> String { - record_log( - logs, - Info, - pass, - filename.to_string(), - None, - None, - format!("Indent pass {}.", pass.unwrap()), - ); + if args.verbose { + record_log( + logs, + Info, + pass, + filename.to_string(), + None, + None, + format!("Indent pass {}.", pass.unwrap()), + ); + } let mut indent = Indent::new(); let mut ignore = Ignore::new(); @@ -136,15 +138,20 @@ pub fn apply_indent( let comment_index = find_comment_index(line); let line_strip = remove_comment(line, comment_index); indent = get_indent(line_strip, indent); - record_log( - logs, - Info, - pass, - filename.to_string(), - Some(linum), - Some(line.to_string()), - format!("Indent: actual = {}, visual = {}", indent.actual, indent.visual), - ); + if args.verbose { + record_log( + logs, + Info, + pass, + filename.to_string(), + Some(linum), + Some(line.to_string()), + format!( + "Indent: actual = {}, visual = {}", + indent.actual, indent.visual + ), + ); + } if (indent.visual < 0) || (indent.actual < 0) { record_log( diff --git a/src/logging.rs b/src/logging.rs index 35a027f..8746d14 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -5,8 +5,8 @@ use log::Level; use log::Level::{Error, Info, Warn}; use log::LevelFilter; use std::io::Write; -use std::time::Instant; use std::path::Path; +use std::time::Instant; #[derive(Debug)] pub struct Log { @@ -73,8 +73,7 @@ pub fn init_logger(args: &Cli) { } pub fn print_logs(args: &Cli, mut logs: Vec) { - - if get_log_level(args) == LevelFilter::Warn { + if get_log_level(args) == LevelFilter::Warn && !logs.is_empty() { let max_pass = &logs.iter().map(|l| l.pass).max().unwrap(); logs.retain(|l| l.pass == *max_pass || l.pass == None); } @@ -96,7 +95,11 @@ pub fn print_logs(args: &Cli, mut logs: Vec) { "{}tex-fmt {}{}: {}{}{}{} {}{:.50}", PINK, PURPLE, - Path::new(&log.filename).file_name().unwrap().to_str().unwrap(), + Path::new(&log.filename) + .file_name() + .unwrap() + .to_str() + .unwrap(), WHITE, linum, YELLOW, diff --git a/src/main.rs b/src/main.rs index 637a955..7854e6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,17 +39,18 @@ fn main() { init_logger(&args); for filename in &args.filenames { - let mut logs: Vec = vec![]; - record_log( - &mut logs, - Info, - None, - filename.to_string(), - None, - None, - "Begin indenting.".to_string(), - ); + if args.verbose { + record_log( + &mut logs, + Info, + None, + filename.to_string(), + None, + None, + "Begin indenting.".to_string(), + ); + } let extension_valid = check_extension_valid(filename); if extension_valid { diff --git a/src/print.rs b/src/print.rs index beccadb..43b8485 100644 --- a/src/print.rs +++ b/src/print.rs @@ -1,11 +1,11 @@ //use crate::colors::*; //pub fn print_script_name() { - //println!("{}tex-fmt{}", PINK, RESET); +//println!("{}tex-fmt{}", PINK, RESET); //} //pub fn print_filename(filename: &str) { - //println!("{}{}{}", PURPLE, filename, RESET); +//println!("{}{}{}", PURPLE, filename, RESET); //} pub fn print_file(new_file: &str) { diff --git a/src/wrap.rs b/src/wrap.rs index 3665280..983d33b 100644 --- a/src/wrap.rs +++ b/src/wrap.rs @@ -66,7 +66,12 @@ fn wrap_line(line: &str) -> String { new_line } -pub fn wrap(file: &str, filename: &str, logs: &mut Vec, pass: Option) -> String { +pub fn wrap( + file: &str, + filename: &str, + logs: &mut Vec, + pass: Option, +) -> String { //log::info!("Wrapping file"); let mut new_file = "".to_string(); let mut new_line: String;