diff --git a/casr/Cargo.toml b/casr/Cargo.toml index 4213e775..da10af86 100644 --- a/casr/Cargo.toml +++ b/casr/Cargo.toml @@ -13,7 +13,7 @@ exclude = ["/tests"] [dependencies] shell-words = "1.1" anyhow = "1.0" -clap = { version = "4.2", features = ["wrap_help", "cargo"] } +clap = { version = "4.2", features = ["wrap_help", "cargo", "env"] } chrono = "0.4" goblin = "0.6" log = "0.4" diff --git a/casr/src/bin/casr-cluster.rs b/casr/src/bin/casr-cluster.rs index 030141c5..1c403295 100644 --- a/casr/src/bin/casr-cluster.rs +++ b/casr/src/bin/casr-cluster.rs @@ -2,7 +2,7 @@ use casr::util; use libcasr::{init_ignored_frames, stacktrace::*}; use anyhow::{bail, Context, Result}; -use clap::{Arg, ArgAction}; +use clap::{builder::FalseyValueParser, Arg, ArgAction}; use rayon::iter::{IndexedParallelIterator, ParallelIterator}; use rayon::iter::{IntoParallelIterator, IntoParallelRefIterator}; @@ -365,6 +365,14 @@ fn main() -> Result<()> { reports in this directory will not be deleted.", ), ) + .arg( + Arg::new("cluster-unique-crashline") + .long("cluster-unique-crashline") + .env("CASR_CLUSTER_UNIQUE_CRASHLINE") + .action(ArgAction::SetTrue) + .value_parser(FalseyValueParser::new()) + .help("Deduplicate each cluster by crashline") + ) .arg( Arg::new("deduplication") .short('d') @@ -426,11 +434,7 @@ fn main() -> Result<()> { } // Get env var - let dedup_crashlines = if let Ok(dedup) = std::env::var("CASR_CLUSTER_UNIQUE_CRASHLINE") { - dedup == "1" - } else { - false - }; + let dedup_crashlines = matches.get_flag("cluster-unique-crashline"); if matches.contains_id("similarity") { let casreps: Vec<&PathBuf> = matches.get_many::("similarity").unwrap().collect(); diff --git a/docs/usage.md b/docs/usage.md index 9b16b4b4..326654d1 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -224,6 +224,8 @@ Tool for clustering CASR reports Cluster CASR reports. If two directories are set, clusters will be placed in the second directory. If one directory is provided, clusters will be placed there, but reports in this directory will not be deleted. + --cluster-unique-crashline + Deduplicate each cluster by crashline [env: CASR_CLUSTER_UNIQUE_CRASHLINE=] -d, --deduplicate Deduplicate CASR reports. If two directories are set, deduplicated reports are copied to the second directory. If one directory is provided, duplicated reports @@ -299,8 +301,9 @@ For the **--ignore ** option, file format should be as follows: Headers may be in different order, one of them may be missing. Frames that match these regular expressions will be not considered during analysis. -When `CASR_CLUSTER_UNIQUE_CRASHLINE` environment variable is set to 1, each -cluster will contain reports with unique crash lines. +For `CASR_CLUSTER_UNIQUE_CRASHLINE` a `false` literal is `n`, `no`, `f`, +`false`, `off` or `0`. An absent environment variable will also be considered as +`false`. Anything else will considered as true. ## casr-cli