···98 f fs client
99 ) env
100101+(* Profile configuration for external programs *)
102+103+module Profile_config = struct
104+ type t = {
105+ style_renderer : Fmt.style_renderer option;
106+ log_level : Logs.level option;
107+ requests_config : Requests.Cmd.config;
108+ profile : string option;
109+ }
110+111+ let style_renderer t = t.style_renderer
112+ let log_level t = t.log_level
113+ let requests_config t = t.requests_config
114+ let profile t = t.profile
115+116+ let setup_logging t =
117+ setup_logging_with_config t.style_renderer t.log_level t.requests_config
118+end
119+120+let profile_config_term fs =
121+ let make (sr, ll) rc p =
122+ Profile_config.{ style_renderer = sr; log_level = ll; requests_config = rc; profile = p }
123+ in
124+ Term.(const make $ setup_logging $ requests_config_term fs $ profile_arg)
125+126(* Login command *)
127128let login_action ~requests_config ~server ~api_key ~email ~password ~profile ~key_name env =
+62
ocaml-immich/lib/cmd.mli
···115 [f fs client]. Prints an error and exits if not logged in.
116 @param requests_config HTTP request configuration
117 @param profile Profile to load (default: current profile) *)
00000000000000000000000000000000000000000000000000000000000000
···115 [f fs client]. Prints an error and exits if not logged in.
116 @param requests_config HTTP request configuration
117 @param profile Profile to load (default: current profile) *)
118+119+(** {1 Profile Configuration for External Programs}
120+121+ These types and functions allow other programs to easily use Immich profiles
122+ that were set up with the immich CLI. This provides a single cmdliner term
123+ that bundles all the necessary configuration.
124+125+ {2 Example Usage}
126+127+ {[
128+ (* In your sortal/bin/main.ml *)
129+ open Cmdliner
130+131+ let my_cmd env fs =
132+ let doc = "My command using Immich" in
133+ let info = Cmd.info "my-command" ~doc in
134+ let action config =
135+ let open Immich_auth.Cmd.Profile_config in
136+ setup_logging config;
137+ Immich_auth.Cmd.with_client
138+ ~requests_config:(requests_config config)
139+ ?profile:(profile config)
140+ (fun _fs client ->
141+ let api = Immich_auth.Client.client client in
142+ (* Use the Immich API here *)
143+ ()
144+ ) env
145+ in
146+ Cmd.v info Term.(const action $ Immich_auth.Cmd.profile_config_term fs)
147+ ]} *)
148+149+(** Configuration for using an Immich profile. *)
150+module Profile_config : sig
151+ type t
152+ (** Bundled configuration for Immich profile access. *)
153+154+ val style_renderer : t -> Fmt.style_renderer option
155+ (** Terminal style renderer setting. *)
156+157+ val log_level : t -> Logs.level option
158+ (** Logging level. *)
159+160+ val requests_config : t -> Requests.Cmd.config
161+ (** HTTP request configuration. *)
162+163+ val profile : t -> string option
164+ (** Selected profile name, if any. *)
165+166+ val setup_logging : t -> unit
167+ (** [setup_logging config] initializes logging with the bundled settings.
168+ Call this at the start of your command execution. *)
169+end
170+171+val profile_config_term : Eio.Fs.dir_ty Eio.Path.t -> Profile_config.t Term.t
172+(** Cmdliner term that collects all configuration needed to use an Immich profile.
173+174+ Combines:
175+ - Logging options ([-v], [--color], etc.)
176+ - HTTP configuration (timeouts, retries, proxy, [--verbose-http])
177+ - Profile selection ([--profile])
178+179+ Use with {!with_client} to create an authenticated client. *)