@@ -79,15 +79,15 @@ pub struct QtorrentArgs {
7979 #[ arg( short = 'p' , long) ]
8080 pub dryrun : bool ,
8181
82- /// Offline mode: skip qBittorrent connection entirely (implies -- dryrun)
82+ /// Offline mode: skip qBittorrent connection entirely (implies dryrun)
8383 #[ arg( short = 'o' , long) ]
8484 pub offline : bool ,
8585
8686 /// Skip confirmation prompts
8787 #[ arg( short = 'y' , long) ]
8888 yes : bool ,
8989
90- /// File extensions to skip (e.g., nfo, txt, jpg )
90+ /// File extensions to skip (e.g., nfo, txt)
9191 #[ arg( short = 'e' , long = "skip-ext" , name = "EXT" , value_delimiter = ',' ) ]
9292 skip_extensions : Vec < String > ,
9393
@@ -99,11 +99,19 @@ pub struct QtorrentArgs {
9999 #[ arg( short = 'm' , long = "min-size" , name = "MB" ) ]
100100 min_file_size_mb : Option < f64 > ,
101101
102+ /// Include image files (.jpg, .jpeg, .png)
103+ #[ arg( short = 'i' , long) ]
104+ include_images : bool ,
105+
106+ /// Minimum image file size in KB
107+ #[ arg( short = 'M' , long = "min-image-size" , name = "KB" ) ]
108+ min_image_size_kb : Option < f64 > ,
109+
102110 /// Recurse into subdirectories when searching for torrent files
103111 #[ arg( short = 'r' , long) ]
104112 pub recurse : bool ,
105113
106- /// Skip rename prompts for existing/duplicate torrents
114+ /// Skip rename prompts for existing torrents
107115 #[ arg( short = 'x' , long) ]
108116 pub skip_existing : bool ,
109117
@@ -226,6 +234,30 @@ mod cli_args_tests {
226234 assert_eq ! ( args. min_file_size_mb, Some ( 50.5 ) ) ;
227235 }
228236
237+ #[ test]
238+ fn parses_include_images ( ) {
239+ let args = QtorrentArgs :: try_parse_from ( [ "test" , "--include-images" ] ) . expect ( "should parse" ) ;
240+ assert ! ( args. include_images) ;
241+ }
242+
243+ #[ test]
244+ fn parses_include_images_short_flag ( ) {
245+ let args = QtorrentArgs :: try_parse_from ( [ "test" , "-i" ] ) . expect ( "should parse" ) ;
246+ assert ! ( args. include_images) ;
247+ }
248+
249+ #[ test]
250+ fn parses_min_image_size ( ) {
251+ let args = QtorrentArgs :: try_parse_from ( [ "test" , "--min-image-size" , "3.5" ] ) . expect ( "should parse" ) ;
252+ assert_eq ! ( args. min_image_size_kb, Some ( 3.5 ) ) ;
253+ }
254+
255+ #[ test]
256+ fn parses_min_image_size_short_flag ( ) {
257+ let args = QtorrentArgs :: try_parse_from ( [ "test" , "-M" , "3.5" ] ) . expect ( "should parse" ) ;
258+ assert_eq ! ( args. min_image_size_kb, Some ( 3.5 ) ) ;
259+ }
260+
229261 #[ test]
230262 fn parses_combined_boolean_flags ( ) {
231263 let args = QtorrentArgs :: try_parse_from ( [ "test" , "-apyrxvo" ] ) . expect ( "should parse" ) ;
@@ -289,6 +321,8 @@ mod cli_args_tests {
289321 assert ! ( args. skip_extensions. is_empty( ) ) ;
290322 assert ! ( args. skip_directories. is_empty( ) ) ;
291323 assert ! ( args. min_file_size_mb. is_none( ) ) ;
324+ assert ! ( !args. include_images) ;
325+ assert ! ( args. min_image_size_kb. is_none( ) ) ;
292326 assert ! ( !args. paused) ;
293327 assert ! ( !args. dryrun) ;
294328 assert ! ( !args. offline) ;
@@ -332,6 +366,9 @@ mod cli_args_tests {
332366 "sample" ,
333367 "-m" ,
334368 "50" ,
369+ "--include-images" ,
370+ "--min-image-size" ,
371+ "2" ,
335372 "-a" ,
336373 "-r" ,
337374 "-v" ,
@@ -349,6 +386,8 @@ mod cli_args_tests {
349386 assert_eq ! ( args. skip_extensions, vec![ "nfo" , "txt" ] ) ;
350387 assert_eq ! ( args. skip_directories, vec![ "sample" ] ) ;
351388 assert_eq ! ( args. min_file_size_mb, Some ( 50.0 ) ) ;
389+ assert ! ( args. include_images) ;
390+ assert_eq ! ( args. min_image_size_kb, Some ( 2.0 ) ) ;
352391 assert ! ( args. paused) ;
353392 assert ! ( args. recurse) ;
354393 assert ! ( args. verbose) ;
@@ -524,6 +563,32 @@ mod config_from_args_tests {
524563 assert_eq ! ( config. file_filter. min_size_bytes, Some ( 10 * 1024 * 1024 ) ) ;
525564 }
526565
566+ #[ test]
567+ fn config_cli_includes_images ( ) {
568+ let args = QtorrentArgs :: try_parse_from ( [ "test" , "--include-images" ] ) . expect ( "should parse" ) ;
569+ let config = Config :: from_args ( args) . expect ( "config should parse" ) ;
570+ assert ! ( config. file_filter. include_images) ;
571+ }
572+
573+ #[ test]
574+ fn config_cli_image_min_size_converts_to_bytes ( ) {
575+ let args =
576+ QtorrentArgs :: try_parse_from ( [ "test" , "--include-images" , "--min-image-size" , "2" ] ) . expect ( "should parse" ) ;
577+ let config = Config :: from_args ( args) . expect ( "config should parse" ) ;
578+ assert_eq ! ( config. file_filter. min_image_size_bytes, Some ( 2 * 1024 ) ) ;
579+ }
580+
581+ #[ test]
582+ fn config_zero_sizes_disable_size_filters ( ) {
583+ let args =
584+ QtorrentArgs :: try_parse_from ( [ "test" , "--include-images" , "--min-size" , "0" , "--min-image-size" , "0" ] )
585+ . expect ( "should parse" ) ;
586+ let config = Config :: from_args ( args) . expect ( "config should parse" ) ;
587+ assert ! ( config. file_filter. include_images) ;
588+ assert ! ( config. file_filter. min_size_bytes. is_none( ) ) ;
589+ assert ! ( config. file_filter. min_image_size_bytes. is_none( ) ) ;
590+ }
591+
527592 #[ test]
528593 fn config_has_credentials_when_cli_sets_them ( ) {
529594 let args = QtorrentArgs :: try_parse_from ( [ "test" , "-u" , "user" , "-w" , "pass" ] ) . expect ( "should parse" ) ;
0 commit comments