mirror of
https://github.com/pldubouilh/blockfast.git
synced 2026-08-27 20:36:34 -04:00
use clap to avoid CLI settings conflicts
This commit is contained in:
committed by
Pierre Dubouilh
parent
956d56716e
commit
9d0bc470cc
+3
-15
@@ -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
|
||||
|
||||
+4
-4
@@ -124,19 +124,19 @@ pub struct Args {
|
||||
pub json_logpath: Option<PathBuf>,
|
||||
|
||||
/// 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<PathBuf>,
|
||||
|
||||
/// generic parser ip regex
|
||||
#[clap(long , value_parser = parse_regex)]
|
||||
#[clap(long, value_parser = parse_regex, requires = "generic_logpath")]
|
||||
pub generic_ip: Option<Regex>,
|
||||
|
||||
/// 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<String>,
|
||||
|
||||
/// 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<String>,
|
||||
|
||||
/// invalid http statuses (for CLF and JSON logs). Coma separated list, accepts ranges with XX.
|
||||
|
||||
Reference in New Issue
Block a user