···11+This is a monorepo of a collection of OCaml libraries that should all work together, but they are in different stages of porting. Ultimately, the goal is to use Eio for everything and move away from Lwt entirely. For HTTP(S) requests the idea is to use River as the main high evel 'http requests' API, so anything using Cohttp or other HTTP fetchers will need to be ported.
22+
···1313 ("PATCH", `PATCH);
1414 ] in
1515 let doc = "HTTP method to use" in
1616- let env = Cmd.Env.info "OCURL_METHOD" in
1717- Arg.(value & opt (enum methods) `GET & info ["X"; "request"] ~env ~docv:"METHOD" ~doc)
1616+ let env_info = Cmdliner.Cmd.Env.info "OCURL_METHOD" in
1717+ Arg.(value & opt (enum methods) `GET & info ["X"; "request"] ~env:env_info ~docv:"METHOD" ~doc)
18181919let urls =
2020 let doc = "URL(s) to fetch" in
···53535454let enable_cache =
5555 let doc = "Enable HTTP response caching for GET and HEAD requests" in
5656- let env = Cmd.Env.info "OCURL_ENABLE_CACHE" in
5757- Arg.(value & flag & info ["enable-cache"] ~env ~doc)
5656+ let env_info = Cmdliner.Cmd.Env.info "OCURL_ENABLE_CACHE" in
5757+ Arg.(value & flag & info ["enable-cache"] ~env:env_info ~doc)
58585959(* Logging setup *)
6060(* Setup logging using Logs_cli for standard logging options *)
+19-19
stack/requests/lib/requests.ml
···332332 let persist_cookies_term app_name =
333333 let doc = "Persist cookies to disk between sessions" in
334334 let env_name = String.uppercase_ascii app_name ^ "_PERSIST_COOKIES" in
335335- let env = Cmd.Env.info env_name in
336336- Arg.(value & flag & info ["persist-cookies"] ~env ~doc)
335335+ let env_info = Cmdliner.Cmd.Env.info env_name in
336336+ Arg.(value & flag & info ["persist-cookies"] ~env:env_info ~doc)
337337338338 let verify_tls_term app_name =
339339 let doc = "Skip TLS certificate verification (insecure)" in
340340 let env_name = String.uppercase_ascii app_name ^ "_NO_VERIFY_TLS" in
341341- let env = Cmd.Env.info env_name in
341341+ let env_info = Cmdliner.Cmd.Env.info env_name in
342342 Term.(const (fun no_verify -> not no_verify) $
343343- Arg.(value & flag & info ["no-verify-tls"] ~env ~doc))
343343+ Arg.(value & flag & info ["no-verify-tls"] ~env:env_info ~doc))
344344345345 let timeout_term app_name =
346346 let doc = "Request timeout in seconds" in
347347 let env_name = String.uppercase_ascii app_name ^ "_TIMEOUT" in
348348- let env = Cmd.Env.info env_name in
349349- Arg.(value & opt (some float) None & info ["timeout"] ~env ~docv:"SECONDS" ~doc)
348348+ let env_info = Cmdliner.Cmd.Env.info env_name in
349349+ Arg.(value & opt (some float) None & info ["timeout"] ~env:env_info ~docv:"SECONDS" ~doc)
350350351351 let retries_term app_name =
352352 let doc = "Maximum number of request retries" in
353353 let env_name = String.uppercase_ascii app_name ^ "_MAX_RETRIES" in
354354- let env = Cmd.Env.info env_name in
355355- Arg.(value & opt int 3 & info ["max-retries"] ~env ~docv:"N" ~doc)
354354+ let env_info = Cmdliner.Cmd.Env.info env_name in
355355+ Arg.(value & opt int 3 & info ["max-retries"] ~env:env_info ~docv:"N" ~doc)
356356357357 let retry_backoff_term app_name =
358358 let doc = "Retry backoff factor for exponential delay" in
359359 let env_name = String.uppercase_ascii app_name ^ "_RETRY_BACKOFF" in
360360- let env = Cmd.Env.info env_name in
361361- Arg.(value & opt float 0.3 & info ["retry-backoff"] ~env ~docv:"FACTOR" ~doc)
360360+ let env_info = Cmdliner.Cmd.Env.info env_name in
361361+ Arg.(value & opt float 0.3 & info ["retry-backoff"] ~env:env_info ~docv:"FACTOR" ~doc)
362362363363 let follow_redirects_term app_name =
364364 let doc = "Don't follow HTTP redirects" in
365365 let env_name = String.uppercase_ascii app_name ^ "_NO_FOLLOW_REDIRECTS" in
366366- let env = Cmd.Env.info env_name in
366366+ let env_info = Cmdliner.Cmd.Env.info env_name in
367367 Term.(const (fun no_follow -> not no_follow) $
368368- Arg.(value & flag & info ["no-follow-redirects"] ~env ~doc))
368368+ Arg.(value & flag & info ["no-follow-redirects"] ~env:env_info ~doc))
369369370370 let max_redirects_term app_name =
371371 let doc = "Maximum number of redirects to follow" in
372372 let env_name = String.uppercase_ascii app_name ^ "_MAX_REDIRECTS" in
373373- let env = Cmd.Env.info env_name in
374374- Arg.(value & opt int 10 & info ["max-redirects"] ~env ~docv:"N" ~doc)
373373+ let env_info = Cmdliner.Cmd.Env.info env_name in
374374+ Arg.(value & opt int 10 & info ["max-redirects"] ~env:env_info ~docv:"N" ~doc)
375375376376 let user_agent_term app_name =
377377 let doc = "User-Agent header to send with requests" in
378378 let env_name = String.uppercase_ascii app_name ^ "_USER_AGENT" in
379379- let env = Cmd.Env.info env_name in
380380- Arg.(value & opt (some string) None & info ["user-agent"] ~env ~docv:"STRING" ~doc)
379379+ let env_info = Cmdliner.Cmd.Env.info env_name in
380380+ Arg.(value & opt (some string) None & info ["user-agent"] ~env:env_info ~docv:"STRING" ~doc)
381381382382 (* Combined terms *)
383383···399399 $ max_redirects_term app_name
400400 $ user_agent_term app_name)
401401402402- let requests_term app_name env sw =
403403- let config_t = config_term app_name env#fs in
404404- Term.(const (fun config -> create config env sw) $ config_t)
402402+ let requests_term app_name eio_env sw =
403403+ let config_t = config_term app_name eio_env#fs in
404404+ Term.(const (fun config -> create config eio_env sw) $ config_t)
405405406406 let minimal_term app_name fs =
407407 let xdg_term = Xdge.Cmd.term app_name fs
···498498 0
499499500500(* Command definitions *)
501501-let info_cmd_def env sw =
501501+let info_cmd_def eio_env sw =
502502 let doc = "Show cache statistics and location" in
503503- let term = Term.(const (info_cmd env sw) $ global_opts_term) in
503503+ let term = Term.(const (info_cmd eio_env sw) $ global_opts_term) in
504504 Cmd.v (Cmd.info "info" ~doc) term
505505506506-let list_cmd_def env sw =
506506+let list_cmd_def eio_env sw =
507507 let sort_by =
508508 let doc = "Sort files by size, age, or name" in
509509 Arg.(value & opt (enum [("size", `Size); ("age", `Age); ("name", `Name)]) `Name &
···519519 Arg.(value & opt (some int) None & info ["limit"; "n"] ~docv:"N" ~doc)
520520 in
521521 let doc = "List cached files with details" in
522522- let term = Term.(const (list_cmd env sw) $ global_opts_term $ sort_by $ format $ limit) in
522522+ let term = Term.(const (list_cmd eio_env sw) $ global_opts_term $ sort_by $ format $ limit) in
523523 Cmd.v (Cmd.info "list" ~doc) term
524524525525-let size_cmd_def env sw =
525525+let size_cmd_def eio_env sw =
526526 let breakdown =
527527 let doc = "Show size breakdown by file type and age" in
528528 Arg.(value & flag & info ["breakdown"; "b"] ~doc)
···532532 Arg.(value & flag & info ["human-readable"; "h"] ~doc)
533533 in
534534 let doc = "Show cache size information" in
535535- let term = Term.(const (size_cmd env sw) $ global_opts_term $ breakdown $ human_readable) in
535535+ let term = Term.(const (size_cmd eio_env sw) $ global_opts_term $ breakdown $ human_readable) in
536536 Cmd.v (Cmd.info "size" ~doc) term
537537538538-let clean_cmd_def env sw =
538538+let clean_cmd_def eio_env sw =
539539 let max_size =
540540 let doc = "Remove files to get cache under this size (e.g., 1GB, 500MB)" in
541541 let parse_size s =
542542 let s = String.uppercase_ascii s in
543543 let len = String.length s in
544544- if len < 2 then `Error "Invalid size format"
544544+ if len < 2 then Error "Invalid size format"
545545 else
546546- let (num_str, unit) =
546546+ let (num_str, unit) =
547547 if String.sub s (len-2) 2 = "GB" then
548548 (String.sub s 0 (len-2), Int64.(mul 1024L (mul 1024L 1024L)))
549549 else if String.sub s (len-2) 2 = "MB" then
···557557 in
558558 try
559559 let num = Float.of_string num_str in
560560- `Ok (Int64.of_float (num *. Int64.to_float unit))
560560+ Ok (Int64.of_float (num *. Int64.to_float unit))
561561 with
562562- | _ -> `Error "Invalid number in size"
562562+ | _ -> Error "Invalid number in size"
563563 in
564564- Arg.(value & opt (some (parse_size, fun fmt size ->
565565- Format.fprintf fmt "%Ld" size)) None & info ["max-size"] ~docv:"SIZE" ~doc)
564564+ let size_conv = Arg.conv' (parse_size, fun fmt size ->
565565+ Format.fprintf fmt "%Ld" size) in
566566+ Arg.(value & opt (some size_conv) None & info ["max-size"] ~docv:"SIZE" ~doc)
566567 in
567568 let max_age =
568569 let doc = "Remove files older than this many days" in
···573574 Arg.(value & flag & info ["dry-run"; "n"] ~doc)
574575 in
575576 let doc = "Clean cache with various options" in
576576- let term = Term.(const (clean_cmd env sw) $ global_opts_term $ max_size $ max_age $ dry_run) in
577577+ let term = Term.(const (clean_cmd eio_env sw) $ global_opts_term $ max_size $ max_age $ dry_run) in
577578 Cmd.v (Cmd.info "clean" ~doc) term
578579579579-let vacuum_cmd_def env sw =
580580+let vacuum_cmd_def eio_env sw =
580581 let dry_run =
581582 let doc = "Show what would be removed without actually removing" in
582583 Arg.(value & flag & info ["dry-run"; "n"] ~doc)
583584 in
584585 let doc = "Remove empty directories and broken links" in
585585- let term = Term.(const (vacuum_cmd env sw) $ global_opts_term $ dry_run) in
586586+ let term = Term.(const (vacuum_cmd eio_env sw) $ global_opts_term $ dry_run) in
586587 Cmd.v (Cmd.info "vacuum" ~doc) term
587588588588-let main_cmd env sw =
589589+let main_cmd eio_env sw =
589590 let doc = "Toru cache management tool" in
590591 let sdocs = Manpage.s_common_options in
591592 let man = [
···605606 ] in
606607 let default = Term.(const 0) in
607608 Cmd.group ~default (Cmd.info "toru-cache" ~version:"0.1.0" ~doc ~sdocs ~man)
608608- [info_cmd_def env sw; list_cmd_def env sw; size_cmd_def env sw; clean_cmd_def env sw; vacuum_cmd_def env sw]
609609+ [info_cmd_def eio_env sw; list_cmd_def eio_env sw; size_cmd_def eio_env sw; clean_cmd_def eio_env sw; vacuum_cmd_def eio_env sw]
609610610611let () =
611612 Eio_main.run @@ fun env ->
+13-13
stack/toru/bin/toru_main.ml
···3737 let resolved_cache_dir = resolve_cache_dir app_name cache_dir in
3838 { app_name; cache_dir = Some resolved_cache_dir; version; verbose_level; env }
39394040-let global_opts_t env =
4040+let global_opts_t eio_env =
4141 let app_name =
4242 let doc = "Application name for cache and config directories" in
4343 Arg.(value & opt string "toru" & info ["app-name"; "a"] ~doc)
···5555 Arg.(value & flag_all & info ["verbose"; "v"] ~doc)
5656 in
5757 Term.(const (fun app_name cache_dir version verbose_flags ->
5858- create_global_opts app_name cache_dir version (List.length verbose_flags) env
5858+ create_global_opts app_name cache_dir version (List.length verbose_flags) eio_env
5959 ) $ app_name $ cache_dir $ version $ verbose_count)
60606161(** Registry inspect command *)
6262-let inspect_cmd env =
6262+let inspect_cmd eio_env =
6363 let registry_source =
6464 let doc = "Registry file path or URL to inspect" in
6565 Arg.(required & pos 0 (some string) None & info [] ~docv:"REGISTRY" ~doc)
···187187 | exn -> `Error (false, "Failed to inspect registry: " ^ (Printexc.to_string exn))
188188 in
189189190190- let term env = Term.(ret (const inspect $ global_opts_t env $ registry_source $ show_stats $ list_files $ search_pattern)) in
190190+ let term eio_env = Term.(ret (const inspect $ global_opts_t eio_env $ registry_source $ show_stats $ list_files $ search_pattern)) in
191191 let info = Cmd.info "inspect" ~doc:"Inspect a registry file or URL" in
192192- Cmd.v info (term env)
192192+ Cmd.v info (term eio_env)
193193194194(** Registry validate command *)
195195-let validate_cmd env =
195195+let validate_cmd eio_env =
196196 let registry_source =
197197 let doc = "Registry file path or URL to validate" in
198198 Arg.(required & pos 0 (some string) None & info [] ~docv:"REGISTRY" ~doc)
199199 in
200200-200200+201201 let check_hashes =
202202 let doc = "Check if all hash formats are valid" in
203203 Arg.(value & flag & info ["check-hashes"] ~doc)
204204 in
205205-205205+206206 let validate global_opts registry_source check_hashes =
207207 try
208208 Toru.Logging.Cli.info (fun m -> m "Validating registry: %s" registry_source);
···257257 | exn -> `Error (false, "Registry validation failed: " ^ (Printexc.to_string exn))
258258 in
259259260260- let term env = Term.(ret (const validate $ global_opts_t env $ registry_source $ check_hashes)) in
260260+ let term eio_env = Term.(ret (const validate $ global_opts_t eio_env $ registry_source $ check_hashes)) in
261261 let info = Cmd.info "validate" ~doc:"Validate a registry file format and integrity" in
262262- Cmd.v info (term env)
262262+ Cmd.v info (term eio_env)
263263264264(** Registry convert command *)
265265-let convert_cmd env =
265265+let convert_cmd eio_env =
266266 let input_registry =
267267 let doc = "Input registry file path or URL" in
268268 Arg.(required & pos 0 (some string) None & info [] ~docv:"INPUT" ~doc)
···301301 | exn -> `Error (false, "Conversion failed: " ^ (Printexc.to_string exn))
302302 in
303303304304- let term env = Term.(ret (const convert $ global_opts_t env $ input_registry $ output_file)) in
304304+ let term eio_env = Term.(ret (const convert $ global_opts_t eio_env $ input_registry $ output_file)) in
305305 let info = Cmd.info "convert" ~doc:"Convert registry between different formats or sources" in
306306- Cmd.v info (term env)
306306+ Cmd.v info (term eio_env)
307307308308(** Main command *)
309309let main_cmd env =
+2-2
stack/toru/bin/toru_make_registry_simple.ml
···7373 exit 1
74747575(* Command definition *)
7676-let cmd env sw =
7676+let cmd eio_env sw =
7777 let doc = "Generate Pooch-compatible registry files from directories (simple version)" in
7878 let info = Cmd.info "toru-make-registry-simple" ~version:"1.0" ~doc in
79798080- Cmd.v info Term.(const (make_registry_main env sw)
8080+ Cmd.v info Term.(const (make_registry_main eio_env sw)
8181 $ directory_arg $ output_arg $ recursive_arg
8282 $ algorithm_arg $ progress_arg $ const ())
8383