@@ -120,13 +120,17 @@ impl App {
120120 )
121121 }
122122
123- macro_rules! sub {
124- (
125- $data: ty => $format: expr;
126- $quantity: ident => $get_data: ident;
127- $progress: literal => $create_reporter: ident;
128- ) => {
129- if let Args {
123+ macro_rules! run {
124+ ( $(
125+ $( #[ $variant_attrs: meta] ) *
126+ {
127+ $data: ty => $format: expr;
128+ $quantity: ident => $get_data: ident;
129+ $progress: literal => $create_reporter: ident;
130+ }
131+ ) * ) => { match self . args { $(
132+ $( #[ $variant_attrs] ) *
133+ Args {
130134 quantity: Quantity :: $quantity,
131135 progress: $progress,
132136 files,
@@ -138,68 +142,63 @@ impl App {
138142 min_ratio,
139143 no_sort,
140144 ..
141- } = self . args
142- {
143- #[ allow( clippy:: redundant_closure_call) ]
144- return Sub {
145- direction: Direction :: from_top_down( top_down) ,
146- bar_alignment: BarAlignment :: from_align_right( align_right) ,
147- get_data: $get_data,
148- reporter: $create_reporter:: <$data>( report_error) ,
149- bytes_format: $format( bytes_format) ,
150- files,
151- json_output,
152- column_width_distribution,
153- max_depth,
154- min_ratio,
155- no_sort,
156- }
157- . run( ) ;
145+ } => Sub {
146+ direction: Direction :: from_top_down( top_down) ,
147+ bar_alignment: BarAlignment :: from_align_right( align_right) ,
148+ get_data: $get_data,
149+ reporter: $create_reporter:: <$data>( report_error) ,
150+ bytes_format: $format( bytes_format) ,
151+ files,
152+ json_output,
153+ column_width_distribution,
154+ max_depth,
155+ min_ratio,
156+ no_sort,
158157 }
159- } ;
158+ . run( ) ,
159+ ) * } } ;
160160 }
161161
162- sub ! {
163- Bytes => |x| x;
164- ApparentSize => GET_APPARENT_SIZE ;
165- false => error_only_reporter;
166- }
162+ run ! {
163+ {
164+ Bytes => |x| x;
165+ ApparentSize => GET_APPARENT_SIZE ;
166+ false => error_only_reporter;
167+ }
167168
168- sub ! {
169- Bytes => |x| x;
170- ApparentSize => GET_APPARENT_SIZE ;
171- true => progress_and_error_reporter;
172- }
169+ {
170+ Bytes => |x| x;
171+ ApparentSize => GET_APPARENT_SIZE ;
172+ true => progress_and_error_reporter;
173+ }
173174
174- #[ cfg( unix) ]
175- sub ! {
176- Bytes => |x| x;
177- BlockSize => GET_BLOCK_SIZE ;
178- false => error_only_reporter;
179- }
175+ #[ cfg( unix) ]
176+ {
177+ Bytes => |x| x;
178+ BlockSize => GET_BLOCK_SIZE ;
179+ false => error_only_reporter;
180+ }
180181
181- #[ cfg( unix) ]
182- sub ! {
183- Bytes => |x| x;
184- BlockSize => GET_BLOCK_SIZE ;
185- true => progress_and_error_reporter;
186- }
182+ #[ cfg( unix) ]
183+ {
184+ Bytes => |x| x;
185+ BlockSize => GET_BLOCK_SIZE ;
186+ true => progress_and_error_reporter;
187+ }
187188
188- #[ cfg( unix) ]
189- sub ! {
190- Blocks => |_| ( ) ;
191- BlockCount => GET_BLOCK_COUNT ;
192- false => error_only_reporter;
193- }
189+ #[ cfg( unix) ]
190+ {
191+ Blocks => |_| ( ) ;
192+ BlockCount => GET_BLOCK_COUNT ;
193+ false => error_only_reporter;
194+ }
194195
195- #[ cfg( unix) ]
196- sub ! {
197- Blocks => |_| ( ) ;
198- BlockCount => GET_BLOCK_COUNT ;
199- true => progress_and_error_reporter;
196+ #[ cfg( unix) ]
197+ {
198+ Blocks => |_| ( ) ;
199+ BlockCount => GET_BLOCK_COUNT ;
200+ true => progress_and_error_reporter;
201+ }
200202 }
201-
202- dbg ! ( self . args) ;
203- panic ! ( "Invalid combination of arguments" )
204203 }
205204}
0 commit comments