@@ -580,7 +580,14 @@ enum Commands {
580580 Find {
581581 /// Search query
582582 #[ arg( value_name = "query" ) ]
583- query : String ,
583+ query : Option < String > ,
584+ /// Image query: local path, data URI, HTTP URL, or viking:// URI
585+ #[ arg(
586+ long = "image" ,
587+ value_name = "path|uri" ,
588+ help_heading = "Common options"
589+ ) ]
590+ image : Option < String > ,
584591 /// Target URI
585592 #[ arg(
586593 short,
@@ -638,7 +645,14 @@ enum Commands {
638645 Search {
639646 /// Search query
640647 #[ arg( value_name = "query" ) ]
641- query : String ,
648+ query : Option < String > ,
649+ /// Image query: local path, data URI, HTTP URL, or viking:// URI
650+ #[ arg(
651+ long = "image" ,
652+ value_name = "path|uri" ,
653+ help_heading = "Common options"
654+ ) ]
655+ image : Option < String > ,
642656 /// Target URI
643657 #[ arg(
644658 short,
@@ -3096,6 +3110,7 @@ async fn main() {
30963110 Commands :: Get { uri, local_path } => handlers:: handle_get ( uri, local_path, ctx) . await ,
30973111 Commands :: Find {
30983112 query,
3113+ image,
30993114 uri,
31003115 node_limit,
31013116 threshold,
@@ -3108,6 +3123,7 @@ async fn main() {
31083123 handlers:: handle_find (
31093124 query,
31103125 uri,
3126+ image,
31113127 node_limit,
31123128 threshold,
31133129 after,
@@ -3121,6 +3137,7 @@ async fn main() {
31213137 }
31223138 Commands :: Search {
31233139 query,
3140+ image,
31243141 uri,
31253142 session_id,
31263143 node_limit,
@@ -3134,6 +3151,7 @@ async fn main() {
31343151 handlers:: handle_search (
31353152 query,
31363153 uri,
3154+ image,
31373155 session_id,
31383156 node_limit,
31393157 threshold,
@@ -3237,6 +3255,20 @@ mod tests {
32373255 }
32383256 }
32393257
3258+ #[ test]
3259+ fn cli_parses_find_image_without_query ( ) {
3260+ let cli = Cli :: try_parse_from ( [ "ov" , "find" , "--image" , "cat.png" ] )
3261+ . expect ( "find image should parse" ) ;
3262+
3263+ match cli. command {
3264+ Commands :: Find { query, image, .. } => {
3265+ assert_eq ! ( query, None ) ;
3266+ assert_eq ! ( image. as_deref( ) , Some ( "cat.png" ) ) ;
3267+ }
3268+ _ => panic ! ( "expected find command" ) ,
3269+ }
3270+ }
3271+
32403272 #[ test]
32413273 fn cli_parses_admin_migrate_cleanup_flag ( ) {
32423274 let migrate = Cli :: try_parse_from ( [ "ov" , "--sudo" , "admin" , "migrate" ] )
@@ -3275,6 +3307,20 @@ mod tests {
32753307 }
32763308 }
32773309
3310+ #[ test]
3311+ fn cli_parses_search_image_with_query ( ) {
3312+ let cli = Cli :: try_parse_from ( [ "ov" , "search" , "poster" , "--image" , "viking://x.png" ] )
3313+ . expect ( "search image should parse" ) ;
3314+
3315+ match cli. command {
3316+ Commands :: Search { query, image, .. } => {
3317+ assert_eq ! ( query. as_deref( ) , Some ( "poster" ) ) ;
3318+ assert_eq ! ( image. as_deref( ) , Some ( "viking://x.png" ) ) ;
3319+ }
3320+ _ => panic ! ( "expected search command" ) ,
3321+ }
3322+ }
3323+
32783324 #[ test]
32793325 fn cli_find_and_search_reject_removed_peer_id_flag ( ) {
32803326 assert ! ( Cli :: try_parse_from( [ "ov" , "find" , "invoice" , "--peer-id" , "peer-a" ] ) . is_err( ) ) ;
0 commit comments