@@ -46,6 +46,7 @@ use std::str::FromStr;
4646struct Filter {
4747 domain : String ,
4848 regex : Regex ,
49+ inverted : bool ,
4950}
5051
5152#[ derive( Debug ) ]
@@ -80,6 +81,11 @@ impl FromStr for Filter {
8081 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
8182 let ( domain, regex) = s. split_once ( '=' ) . ok_or ( FilterError :: NoFilter ) ?;
8283
84+ let ( regex, inverted) = regex
85+ . strip_prefix ( '-' )
86+ . map ( |regex| ( regex, true ) )
87+ . unwrap_or ( ( regex, false ) ) ;
88+
8389 let regex = regex. strip_prefix ( '/' ) . ok_or ( FilterError :: NoOpeningSlash ) ?;
8490 let regex = regex. strip_suffix ( '/' ) . ok_or ( FilterError :: NoClosingSlash ) ?;
8591
@@ -90,6 +96,7 @@ impl FromStr for Filter {
9096 Ok ( Filter {
9197 domain : domain. to_owned ( ) ,
9298 regex,
99+ inverted,
93100 } )
94101 }
95102}
@@ -589,8 +596,10 @@ fn main() -> eyre::Result<()> {
589596
590597 for filter in & cli. attribute_filter {
591598 let regex = filter. regex . clone ( ) ;
592- driver =
593- driver. with_marker_attributes_filter ( & filter. domain , move |attr| regex. is_match ( attr) )
599+ let inverted = filter. inverted ;
600+ driver = driver. with_marker_attributes_filter ( & filter. domain , move |attr| {
601+ regex. is_match ( attr) ^ inverted
602+ } )
594603 }
595604
596605 let metadata: Result < ExportMetadata , DataError > = match cli. format {
0 commit comments