@@ -169,6 +169,20 @@ struct Cli {
169169 #[ arg( help = "Analyzes the binary and only includes markers that are used by the binary." ) ]
170170 markers_for_bin : Option < PathBuf > ,
171171
172+ #[ arg( long, num_args = 2 .., value_names = [ "DOMAIN" , "ATTRIBUTES" ] ) ]
173+ #[ arg(
174+ help = "Filter attributes on markers for a domain. Accepts two or more arguments.\n \
175+ The attributes are selected in the output."
176+ ) ]
177+ attribute_allowlist : Vec < String > ,
178+
179+ #[ arg( long, num_args = 2 .., value_names = [ "DOMAIN" , "ATTRIBUTES" ] ) ]
180+ #[ arg(
181+ help = "Filter out attributes on markers for a domain. Accepts two or more arguments.\n \
182+ The attributes are excluded in the output."
183+ ) ]
184+ attribute_denylist : Vec < String > ,
185+
172186 #[ arg( long, short, num_args = 0 ..) ]
173187 #[ cfg_attr( feature = "provider" , arg( default_value = "recommended" ) ) ]
174188 #[ arg(
@@ -528,6 +542,42 @@ fn main() -> eyre::Result<()> {
528542 driver. with_segmenter_models ( cli. segmenter_models . clone ( ) )
529543 } ;
530544
545+ if !cli. attribute_allowlist . is_empty ( ) {
546+ driver = driver. with_marker_attributes_filter (
547+ & cli. attribute_allowlist [ 0 ] . clone ( ) ,
548+ move |attrs| {
549+ let ( _prefix, unit) = attrs
550+ . as_str ( )
551+ . split_once ( '-' )
552+ . unwrap_or ( ( "" , attrs. as_str ( ) ) ) ;
553+
554+ cli. attribute_allowlist
555+ . clone ( )
556+ . iter ( )
557+ . skip ( 1 )
558+ . any ( |attr| attr == unit)
559+ } ,
560+ ) ;
561+ } ;
562+
563+ if !cli. attribute_denylist . is_empty ( ) {
564+ driver = driver. with_marker_attributes_filter (
565+ & cli. attribute_denylist [ 0 ] . clone ( ) ,
566+ move |attrs| {
567+ let ( _prefix, unit) = attrs
568+ . as_str ( )
569+ . split_once ( '-' )
570+ . unwrap_or ( ( "" , attrs. as_str ( ) ) ) ;
571+
572+ !cli. attribute_denylist
573+ . clone ( )
574+ . iter ( )
575+ . skip ( 1 )
576+ . any ( |attr| attr == unit)
577+ } ,
578+ ) ;
579+ } ;
580+
531581 let metadata: Result < ExportMetadata , DataError > = match cli. format {
532582 #[ cfg( not( feature = "fs_exporter" ) ) ]
533583 Format :: Fs => {
0 commit comments