diff --git a/src/main.rs b/src/main.rs index 063122e..9901932 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,21 +28,9 @@ async fn run() -> Result<()> { let generic_ip_re = args.generic_ip.as_ref(); let generic_positive = args.generic_positive.as_ref(); let generic_negative = args.generic_negative.as_ref(); - if args.generic_ip.is_some() - || args.generic_logpath.is_some() - || args.generic_positive.is_some() - || args.generic_negative.is_some() - { - if args.generic_ip.is_none() || args.generic_logpath.is_none() { - bail!("generic parser needs both ip regex and log file path"); - } - if !(args.generic_positive.is_some() ^ args.generic_negative.is_some()) { - bail!("generic parser requires either a positive or a negative regex"); - } - if let Some(p) = generic_path.as_ref() { - ml.add_file(&p).await?; - log!("starting with generic parsing at {:?}", &p); - } + if let Some(p) = generic_path { + ml.add_file(&p).await?; + log!("starting with generic parsing at {:?}", &p); } // sshd diff --git a/src/utils.rs b/src/utils.rs index 48ad9f5..8fec206 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -124,19 +124,19 @@ pub struct Args { pub json_logpath: Option, /// generic parser log file path - #[clap(long, value_parser = resolve_path)] + #[clap(long, value_parser = resolve_path, requires_all = ["generic_ip", "generic_match"])] pub generic_logpath: Option, /// generic parser ip regex - #[clap(long , value_parser = parse_regex)] + #[clap(long, value_parser = parse_regex, requires = "generic_logpath")] pub generic_ip: Option, /// generic parser positive - if a logline contains this, it is considered bad, the rest is good - #[clap(long)] + #[clap(long, requires = "generic_logpath")] pub generic_positive: Option, /// generic parser negative - if a logline contains this, it is considered good, the rest is bad - #[clap(long)] + #[clap(long, requires = "generic_logpath")] pub generic_negative: Option, /// invalid http statuses (for CLF and JSON logs). Coma separated list, accepts ranges with XX.