Pure OCaml xxhash implementation

Merge commit 'f930fb36d944d2599754c212e06afaba11aec583'

+32
+2
sortal/bin/sortal_cli.ml
··· 42 42 43 43 let list_cmd = make_term Sortal.Cmd.list_info (Term.const Sortal.Cmd.list_cmd) in 44 44 let show_cmd = make_term Sortal.Cmd.show_info Term.(const Sortal.Cmd.show_cmd $ Sortal.Cmd.handle_arg) in 45 + let thumbnail_cmd = make_term Sortal.Cmd.thumbnail_info Term.(const Sortal.Cmd.thumbnail_cmd $ Sortal.Cmd.handle_arg) in 45 46 let search_cmd = make_term Sortal.Cmd.search_info Term.(const Sortal.Cmd.search_cmd $ Sortal.Cmd.query_arg) in 46 47 let stats_cmd = make_term Sortal.Cmd.stats_info Term.(const (fun () -> Sortal.Cmd.stats_cmd ()) $ const ()) in 47 48 let sync_cmd = make_term Sortal.Cmd.sync_info Term.(const (fun () -> Sortal.Cmd.sync_cmd ()) $ const ()) in ··· 230 231 let cmd = Cmd.group info ~default:default_term [ 231 232 list_cmd; 232 233 show_cmd; 234 + thumbnail_cmd; 233 235 search_cmd; 234 236 stats_cmd; 235 237 sync_cmd;
+1
sortal/lib/core/sortal.ml
··· 19 19 let delete = Store.delete 20 20 let list = Store.list 21 21 let thumbnail_path = Store.thumbnail_path 22 + let png_thumbnail_path = Store.png_thumbnail_path 22 23 let find_by_name = Store.find_by_name 23 24 let find_by_name_opt = Store.find_by_name_opt 24 25 let search_all = Store.search_all
+4
sortal/lib/core/sortal.mli
··· 98 98 See {!Store.thumbnail_path} for details. *) 99 99 val thumbnail_path : t -> Contact.t -> Eio.Fs.dir_ty Eio.Path.t option 100 100 101 + (** [png_thumbnail_path t contact] returns the path to the PNG version of a contact's thumbnail. 102 + See {!Store.png_thumbnail_path} for details. *) 103 + val png_thumbnail_path : t -> Contact.t -> Eio.Fs.dir_ty Eio.Path.t option 104 + 101 105 (** [find_by_name t name] searches for contacts by name. 102 106 See {!Store.find_by_name} for details. *) 103 107 val find_by_name : t -> string -> Contact.t
+14
sortal/lib/core/sortal_cmd.ml
··· 42 42 0 43 43 | None -> Logs.err (fun m -> m "Contact not found: %s" handle); 1 44 44 45 + let thumbnail_cmd handle xdg = 46 + let store = Sortal_store.create_from_xdg xdg in 47 + match Sortal_store.lookup store handle with 48 + | None -> Logs.err (fun m -> m "Contact not found: %s" handle); 1 49 + | Some c -> 50 + match Sortal_store.thumbnail_path store c with 51 + | Some path -> 52 + Printf.printf "%s\n" (Eio.Path.native_exn path); 53 + 0 54 + | None -> 55 + Logs.err (fun m -> m "No thumbnail for contact: %s" handle); 56 + 1 57 + 45 58 let search_cmd query xdg = 46 59 let store = Sortal_store.create_from_xdg xdg in 47 60 match Sortal_store.search_all store query with ··· 314 327 (* Command info and args *) 315 328 let list_info = Cmd.info "list" ~doc:"List all contacts" 316 329 let show_info = Cmd.info "show" ~doc:"Show detailed information about a contact" 330 + let thumbnail_info = Cmd.info "thumbnail" ~doc:"Print the thumbnail file path for a contact" 317 331 let search_info = Cmd.info "search" ~doc:"Search contacts by name" 318 332 let stats_info = Cmd.info "stats" ~doc:"Show statistics about the contact database" 319 333 let sync_info = Cmd.info "sync" ~doc:"Synchronize and normalize contact data"
+11
sortal/lib/core/sortal_cmd.mli
··· 23 23 @param handle The contact handle to display *) 24 24 val show_cmd : string -> (Xdge.t -> int) 25 25 26 + (** [thumbnail_cmd handle] prints the thumbnail file path for a contact. 27 + 28 + Returns exit code 0 and prints the path if the contact has a thumbnail, 29 + or exit code 1 if the contact is not found or has no thumbnail. 30 + 31 + @param handle The contact handle to look up *) 32 + val thumbnail_cmd : string -> (Xdge.t -> int) 33 + 26 34 (** [search_cmd query] creates a command to search contacts by name. 27 35 28 36 @param query The search query string *) ··· 120 128 121 129 (** [show_info] is the command info for the show command. *) 122 130 val show_info : Cmdliner.Cmd.info 131 + 132 + (** [thumbnail_info] is the command info for the thumbnail command. *) 133 + val thumbnail_info : Cmdliner.Cmd.info 123 134 124 135 (** [search_info] is the command info for the search command. *) 125 136 val search_info : Cmdliner.Cmd.info