@@ -94,6 +94,9 @@ pub struct CliMirror {
94
94
/// Setup download threads (default as 4)
95
95
#[ arg( from_global, help = fl!( "clap-download-threads-help" ) ) ]
96
96
download_threads : Option < usize > ,
97
+ /// Set apt options
98
+ #[ arg( from_global, help = fl!( "clap-apt-options-help" ) ) ]
99
+ apt_options : Vec < String > ,
97
100
}
98
101
99
102
#[ derive( Debug , Subcommand ) ]
@@ -190,6 +193,7 @@ impl CliExecuter for CliMirror {
190
193
no_refresh,
191
194
dry_run,
192
195
download_threads,
196
+ apt_options,
193
197
} = self ;
194
198
195
199
if dry_run {
@@ -212,6 +216,7 @@ impl CliExecuter for CliMirror {
212
216
names. iter ( ) . map ( |x| x. as_str ( ) ) . collect :: < Vec < _ > > ( ) ,
213
217
sysroot,
214
218
Operate :: Set ,
219
+ apt_options,
215
220
) ,
216
221
MirrorSubCmd :: Speedtest {
217
222
set_fastest,
@@ -224,6 +229,7 @@ impl CliExecuter for CliMirror {
224
229
!no_refresh_topics && !config. no_refresh_topics ( ) ,
225
230
download_threads. unwrap_or_else ( || config. network_thread ( ) ) ,
226
231
no_refresh,
232
+ apt_options,
227
233
) ,
228
234
MirrorSubCmd :: Add {
229
235
names,
@@ -238,6 +244,7 @@ impl CliExecuter for CliMirror {
238
244
names. iter ( ) . map ( |x| x. as_str ( ) ) . collect :: < Vec < _ > > ( ) ,
239
245
sysroot,
240
246
Operate :: Add ,
247
+ apt_options,
241
248
) ,
242
249
MirrorSubCmd :: Remove {
243
250
names,
@@ -252,6 +259,7 @@ impl CliExecuter for CliMirror {
252
259
names. iter ( ) . map ( |x| x. as_str ( ) ) . collect :: < Vec < _ > > ( ) ,
253
260
sysroot,
254
261
Operate :: Remove ,
262
+ apt_options,
255
263
) ,
256
264
MirrorSubCmd :: SortMirrors {
257
265
no_refresh_topics,
@@ -261,6 +269,7 @@ impl CliExecuter for CliMirror {
261
269
!no_refresh_topics && !config. no_refresh_topics ( ) ,
262
270
download_threads. unwrap_or_else ( || config. network_thread ( ) ) ,
263
271
no_refresh,
272
+ apt_options,
264
273
) ,
265
274
}
266
275
} else {
@@ -269,6 +278,7 @@ impl CliExecuter for CliMirror {
269
278
!no_refresh_topics && !config. no_refresh_topics ( ) ,
270
279
download_threads. unwrap_or_else ( || config. network_thread ( ) ) ,
271
280
no_refresh,
281
+ apt_options,
272
282
)
273
283
}
274
284
}
@@ -279,6 +289,7 @@ pub fn tui(
279
289
refresh_topic : bool ,
280
290
network_threads : usize ,
281
291
no_refresh : bool ,
292
+ apt_options : Vec < String > ,
282
293
) -> Result < i32 , OutputError > {
283
294
root ( ) ?;
284
295
@@ -347,26 +358,28 @@ pub fn tui(
347
358
348
359
if !no_refresh {
349
360
refresh_enabled_topics_sources_list ( no_progress) ?;
350
- refresh ( no_progress, network_threads, refresh_topic) ?;
361
+ refresh ( no_progress, network_threads, refresh_topic, apt_options ) ?;
351
362
}
352
363
353
364
Ok ( 0 )
354
365
}
355
366
356
- pub enum Operate {
367
+ enum Operate {
357
368
Set ,
358
369
Add ,
359
370
Remove ,
360
371
}
361
372
362
- pub fn operate (
373
+ #[ allow( clippy:: too_many_arguments) ]
374
+ fn operate (
363
375
no_progress : bool ,
364
376
refresh_topic : bool ,
365
377
network_threads : usize ,
366
378
no_refresh : bool ,
367
379
args : Vec < & str > ,
368
380
sysroot : PathBuf ,
369
381
subcmd : Operate ,
382
+ apt_options : Vec < String > ,
370
383
) -> Result < i32 , OutputError > {
371
384
root ( ) ?;
372
385
@@ -392,7 +405,7 @@ pub fn operate(
392
405
393
406
if !no_refresh {
394
407
refresh_enabled_topics_sources_list ( no_progress) ?;
395
- refresh ( no_progress, network_threads, refresh_topic) ?;
408
+ refresh ( no_progress, network_threads, refresh_topic, apt_options ) ?;
396
409
}
397
410
398
411
Ok ( 0 )
@@ -403,6 +416,7 @@ pub fn set_order(
403
416
refresh_topic : bool ,
404
417
network_threads : usize ,
405
418
no_refresh : bool ,
419
+ apt_options : Vec < String > ,
406
420
) -> Result < i32 , OutputError > {
407
421
root ( ) ?;
408
422
@@ -428,7 +442,7 @@ pub fn set_order(
428
442
429
443
if !no_refresh {
430
444
refresh_enabled_topics_sources_list ( no_progress) ?;
431
- refresh ( no_progress, network_threads, refresh_topic) ?;
445
+ refresh ( no_progress, network_threads, refresh_topic, apt_options ) ?;
432
446
}
433
447
434
448
Ok ( 0 )
@@ -446,6 +460,7 @@ pub fn speedtest(
446
460
refresh_topic : bool ,
447
461
network_threads : usize ,
448
462
no_refresh : bool ,
463
+ apt_options : Vec < String > ,
449
464
) -> Result < i32 , OutputError > {
450
465
if set_fastest {
451
466
root ( ) ?;
@@ -570,7 +585,7 @@ pub fn speedtest(
570
585
571
586
if !no_refresh {
572
587
refresh_enabled_topics_sources_list ( no_progress) ?;
573
- refresh ( no_progress, network_threads, refresh_topic) ?;
588
+ refresh ( no_progress, network_threads, refresh_topic, apt_options ) ?;
574
589
}
575
590
}
576
591
@@ -581,6 +596,7 @@ fn refresh(
581
596
no_progress : bool ,
582
597
network_threads : usize ,
583
598
refresh_topic : bool ,
599
+ apt_options : Vec < String > ,
584
600
) -> Result < ( ) , OutputError > {
585
601
let auth_config = auth_config ( "/" ) ;
586
602
let auth_config = auth_config. as_ref ( ) ;
@@ -593,6 +609,7 @@ fn refresh(
593
609
. refresh_topics ( refresh_topic)
594
610
. config ( & AptConfig :: new ( ) )
595
611
. maybe_auth_config ( auth_config)
612
+ . apt_options ( apt_options. clone ( ) )
596
613
. build ( )
597
614
. run ( ) ?;
598
615
0 commit comments