My agentic slop goes here. Not intended for anyone else!

more

Changed files
+63 -44
stack
+4 -1
stack/cacheio/bin/cache_cli.ml
···
open Cmdliner
let main () =
(* Run with Eio to provide the filesystem *)
Eio_main.run @@ fun env ->
let fs = env#fs in
···
`P "This tool provides subcommands for listing, clearing, and managing cached files.";
] in
let info = Cmd.info "cache" ~doc ~man in
-
let cmd = Cmd.group info (Cacheio_cmd.make_commands fs) in
exit (Cmd.eval cmd)
···
open Cmdliner
let main () =
+
(* Default app name for the cache CLI tool *)
+
let app_name = "cacheio-cli" in
+
(* Run with Eio to provide the filesystem *)
Eio_main.run @@ fun env ->
let fs = env#fs in
···
`P "This tool provides subcommands for listing, clearing, and managing cached files.";
] in
let info = Cmd.info "cache" ~doc ~man in
+
let cmd = Cmd.group info (Cacheio_cmd.make_commands ~app_name fs) in
exit (Cmd.eval cmd)
+7 -1
stack/cacheio/lib/cacheio.ml
···
let pp fmt t =
Format.fprintf fmt "Cache{base=%s}"
-
(Path.native_exn t.base_dir)
···
let pp fmt t =
Format.fprintf fmt "Cache{base=%s}"
+
(Path.native_exn t.base_dir)
+
+
(** {1 Convenience Functions} *)
+
+
let create_with_xdge xdge =
+
let base_dir = Xdge.cache_dir xdge in
+
create ~base_dir
+3
stack/cacheio/lib/cacheio.mli
···
(** Create a new cache at the specified base directory *)
val create : base_dir:Eio.Fs.dir_ty Eio.Path.t -> t
(** Check if a key exists in the cache.
Keys are strings that will be automatically hashed for filesystem storage. *)
val exists : t -> key:string -> bool
···
(** Create a new cache at the specified base directory *)
val create : base_dir:Eio.Fs.dir_ty Eio.Path.t -> t
+
(** Create a new cache using an Xdge context *)
+
val create_with_xdge : Xdge.t -> t
+
(** Check if a key exists in the cache.
Keys are strings that will be automatically hashed for filesystem storage. *)
val exists : t -> key:string -> bool
+21 -23
stack/cacheio/lib/cacheio_cmd.ml
···
(** {1 Common Terms} *)
-
let cache_dir_term =
-
let doc = "Cache directory path" in
-
let env = Cmd.Env.info "CACHE_DIR" ~doc:"Override default cache directory" in
-
Arg.(value & opt string (Sys.getenv_opt "XDG_CACHE_HOME" |> Option.value ~default:"~/.cache")
-
& info ["cache-dir"; "c"] ~env ~docv:"PATH" ~doc)
(** {1 Commands} *)
-
let list_cmd fs =
let list cache_dir stale expired pinned temporary older_than =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "List cache entries" in
let info = Cmd.info "list" ~doc in
-
Cmd.v info Term.(const list $ cache_dir_term $ stale $ expired $ pinned $ temporary $ older_than)
-
let expire_cmd fs =
let expire cache_dir =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Remove expired entries from cache" in
let info = Cmd.info "expire" ~doc in
-
Cmd.v info Term.(const expire $ cache_dir_term)
-
let clear_cmd fs =
let clear cache_dir all temporary =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Clear cache entries" in
let info = Cmd.info "clear" ~doc in
-
Cmd.v info Term.(const clear $ cache_dir_term $ all $ temporary)
-
let flag_cmd fs =
let flag cache_dir key add remove set_flags =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Manage cache entry flags" in
let info = Cmd.info "flag" ~doc in
-
Cmd.v info Term.(const flag $ cache_dir_term $ key $ add $ remove $ set_flags)
-
let stats_cmd fs =
let stats cache_dir =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Show cache statistics" in
let info = Cmd.info "stats" ~doc in
-
Cmd.v info Term.(const stats $ cache_dir_term)
(** {1 Command Groups} *)
-
let make_commands fs = [
-
list_cmd fs;
-
expire_cmd fs;
-
clear_cmd fs;
-
flag_cmd fs;
-
stats_cmd fs
]
-
let make_cmd fs =
let doc = "Cache management commands" in
let info = Cmd.info "cache" ~doc in
-
Cmd.group info (make_commands fs)
···
(** {1 Common Terms} *)
+
let cache_dir_term ~app_name =
+
(* Use Xdge.Cmd.cache_term for proper XDG handling *)
+
Xdge.Cmd.cache_term app_name
(** {1 Commands} *)
+
let list_cmd ~app_name fs =
let list cache_dir stale expired pinned temporary older_than =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "List cache entries" in
let info = Cmd.info "list" ~doc in
+
Cmd.v info Term.(const list $ cache_dir_term ~app_name $ stale $ expired $ pinned $ temporary $ older_than)
+
let expire_cmd ~app_name fs =
let expire cache_dir =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Remove expired entries from cache" in
let info = Cmd.info "expire" ~doc in
+
Cmd.v info Term.(const expire $ cache_dir_term ~app_name)
+
let clear_cmd ~app_name fs =
let clear cache_dir all temporary =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Clear cache entries" in
let info = Cmd.info "clear" ~doc in
+
Cmd.v info Term.(const clear $ cache_dir_term ~app_name $ all $ temporary)
+
let flag_cmd ~app_name fs =
let flag cache_dir key add remove set_flags =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Manage cache entry flags" in
let info = Cmd.info "flag" ~doc in
+
Cmd.v info Term.(const flag $ cache_dir_term ~app_name $ key $ add $ remove $ set_flags)
+
let stats_cmd ~app_name fs =
let stats cache_dir =
let base_dir = Path.(fs / cache_dir) in
let cache = Cacheio.create ~base_dir in
···
let doc = "Show cache statistics" in
let info = Cmd.info "stats" ~doc in
+
Cmd.v info Term.(const stats $ cache_dir_term ~app_name)
(** {1 Command Groups} *)
+
let make_commands ~app_name fs = [
+
list_cmd ~app_name fs;
+
expire_cmd ~app_name fs;
+
clear_cmd ~app_name fs;
+
flag_cmd ~app_name fs;
+
stats_cmd ~app_name fs
]
+
let make_cmd ~app_name fs =
let doc = "Cache management commands" in
let info = Cmd.info "cache" ~doc in
+
Cmd.group info (make_commands ~app_name fs)
+15 -15
stack/cacheio/lib/cacheio_cmd.mli
···
(** {1 Common Terms} *)
-
(** Term for cache directory path *)
-
val cache_dir_term : string Cmdliner.Term.t
(** {1 Command Builders} *)
-
(** Create list command with given filesystem *)
-
val list_cmd : Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
-
(** Create expire command with given filesystem *)
-
val expire_cmd : Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
-
(** Create clear command with given filesystem *)
-
val clear_cmd : Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
-
(** Create flag management command with given filesystem *)
-
val flag_cmd : Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
-
(** Create statistics command with given filesystem *)
-
val stats_cmd : Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
(** {1 Command Groups} *)
-
(** Create all cache commands for the given filesystem *)
-
val make_commands : Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t list
(** Create main command group containing all cache subcommands *)
-
val make_cmd : Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
···
(** {1 Common Terms} *)
+
(** Term for cache directory path with proper XDG handling *)
+
val cache_dir_term : app_name:string -> string Cmdliner.Term.t
(** {1 Command Builders} *)
+
(** Create list command with given filesystem and app name *)
+
val list_cmd : app_name:string -> Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
+
(** Create expire command with given filesystem and app name *)
+
val expire_cmd : app_name:string -> Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
+
(** Create clear command with given filesystem and app name *)
+
val clear_cmd : app_name:string -> Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
+
(** Create flag management command with given filesystem and app name *)
+
val flag_cmd : app_name:string -> Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
+
(** Create statistics command with given filesystem and app name *)
+
val stats_cmd : app_name:string -> Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
(** {1 Command Groups} *)
+
(** Create all cache commands for the given filesystem and app name *)
+
val make_commands : app_name:string -> Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t list
(** Create main command group containing all cache subcommands *)
+
val make_cmd : app_name:string -> Eio.Fs.dir_ty Eio.Path.t -> unit Cmdliner.Cmd.t
+2 -2
stack/cacheio/lib/dune
···
(public_name cacheio)
(name cacheio)
(modules cacheio cacheio_flags cacheio_entry cacheio_stats)
-
(libraries eio eio_main digestif yojson ptime ptime.clock.os logs fmt))
(library
(public_name cacheio.cmd)
(name cacheio_cmd)
(modules cacheio_cmd)
-
(libraries cacheio cmdliner eio eio_main))
···
(public_name cacheio)
(name cacheio)
(modules cacheio cacheio_flags cacheio_entry cacheio_stats)
+
(libraries eio eio_main digestif yojson ptime ptime.clock.os logs fmt xdge))
(library
(public_name cacheio.cmd)
(name cacheio_cmd)
(modules cacheio_cmd)
+
(libraries cacheio cmdliner eio eio_main xdge))
+11 -1
stack/cacheio/test/dune
···
(executable
(public_name test_new_cache)
(name test_new_cache)
-
(libraries cacheio eio_main))
···
(executable
(public_name test_new_cache)
(name test_new_cache)
+
(libraries cacheio eio_main))
+
+
(executable
+
(public_name test_xdg)
+
(name test_xdg)
+
(libraries cacheio xdge eio_main))
+
+
(executable
+
(public_name test_xdg_cmd)
+
(name test_xdg_cmd)
+
(libraries cacheio xdge cmdliner eio_main))
-1
stack/cacheio/xdg-eio
···
-
../xdg-eio
···