XDG library path support for OCaml via Eio capabilities
linux macos ocaml xdg
at v1.0.0 1.1 kB view raw
1let run (xdg, cfg) = 2 Fmt.pr "%a@.%a@.@.%a@.%a@." 3 Fmt.(styled `Bold string) 4 "=== Cmdliner Config ===" Xdge.Cmd.pp cfg 5 Fmt.(styled `Bold string) 6 "=== XDG Directories ===" 7 (Xdge.pp ~brief:false ~sources:true) 8 xdg 9 10open Cmdliner 11 12let () = 13 Fmt.set_style_renderer Fmt.stdout `Ansi_tty; 14 let app_name = "xdg_example" in 15 let doc = 16 "Example program demonstrating XDG directory selection with Cmdliner" 17 in 18 let man = 19 [ 20 `S Manpage.s_description; 21 `P 22 "This example shows how to use the Xdge library with Cmdliner to \ 23 handle XDG Base Directory Specification paths with command-line and \ 24 environment variable overrides."; 25 `S Manpage.s_environment; 26 `P (Xdge.Cmd.env_docs app_name); 27 ] 28 in 29 let info = Cmdliner.Cmd.info "xdg_example" ~version:"1.0" ~doc ~man in 30 Eio_main.run @@ fun env -> 31 let create_xdg_term = Xdge.Cmd.term app_name env#fs () in 32 let main_term = Term.(const run $ create_xdg_term) in 33 let cmd = Cmdliner.Cmd.v info main_term in 34 exit @@ Cmdliner.Cmd.eval cmd