diff --git a/src/banner.rs b/src/banner.rs index c197c43..3b954ec 100644 --- a/src/banner.rs +++ b/src/banner.rs @@ -297,6 +297,24 @@ by Ben "epi" Risher {} ver: {}"#, } } + for filter in &config.filter_word_count { + writeln!( + &mut writer, + "{}", + format_banner_entry!("\u{1f4a2}", "Word Count Filter", filter) + ) + .unwrap_or_default(); // 💢 + } + + for filter in &config.filter_line_count { + writeln!( + &mut writer, + "{}", + format_banner_entry!("\u{1f4a2}", "Line Count Filter", filter) + ) + .unwrap_or_default(); // 💢 + } + if config.extract_links { writeln!( &mut writer, diff --git a/src/config.rs b/src/config.rs index 0403b34..34ebb3e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -447,6 +447,24 @@ impl Configuration { .collect(); } + if let Some(arg) = args.values_of("filter_words") { + config.filter_word_count = arg + .map(|size| { + size.parse::() + .unwrap_or_else(|e| report_and_exit(&e.to_string())) + }) + .collect(); + } + + if let Some(arg) = args.values_of("filter_lines") { + config.filter_line_count = arg + .map(|size| { + size.parse::() + .unwrap_or_else(|e| report_and_exit(&e.to_string())) + }) + .collect(); + } + if args.is_present("quiet") { // the reason this is protected by an if statement: // consider a user specifying quiet = true in ferox-config.toml diff --git a/src/parser.rs b/src/parser.rs index ab545d4..888f175 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -218,6 +218,30 @@ pub fn initialize() -> App<'static, 'static> { "Filter out messages of a particular size (ex: -S 5120 -S 4927,1970)", ), ) + .arg( + Arg::with_name("filter_words") + .short("W") + .long("filter-words") + .value_name("WORDS") + .takes_value(true) + .multiple(true) + .use_delimiter(true) + .help( + "Filter out messages of a particular word count (ex: -W 312 -W 91,82)", + ), + ) + .arg( + Arg::with_name("filter_lines") + .short("N") + .long("filter-lines") + .value_name("LINES") + .takes_value(true) + .multiple(true) + .use_delimiter(true) + .help( + "Filter out messages of a particular line count (ex: -N 20 -N 31,30)", + ), + ) .arg( Arg::with_name("filter_status") .short("C")