···5757type 'a conv = 'a Conv.t
5858let some = Cmdliner_def.Arg_conv.some
5959let some' = Cmdliner_def.Arg_conv.some'
6060+let none = Cmdliner_def.Arg_conv.none
60616162(* Argument information *)
6263···6566let info = Cmdliner_def.Arg_info.make
66676768(* Arguments *)
6868-6969-let no_completion =
7070- Cmdliner_def.Arg_info.Completion Cmdliner_def.Arg_completion.complete_none
71697270let ( & ) f x = f x
7371let parse_error e = Error (`Parse e)
···107105 | (_, f, _) :: (_ ,g, _) :: _ ->
108106 parse_error (Cmdliner_msg.err_opt_repeated f g)
109107 in
110110- Cmdliner_term.make (arg_to_args a no_completion) convert
108108+ Cmdliner_term.make (arg_to_args a (Conv none)) convert
111109112110let flag_all a =
113111 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else
···123121 Ok (List.rev_map truth l)
124122 with Failure e -> parse_error e
125123 in
126126- Cmdliner_term.make (arg_to_args a no_completion) convert
124124+ Cmdliner_term.make (arg_to_args a (Conv none)) convert
127125128126let vflag v l =
129127 let convert _ cl =
···147145 let flag (_, a) =
148146 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else a
149147 in
150150- Cmdliner_term.make (list_to_args flag l no_completion) convert
148148+ Cmdliner_term.make (list_to_args flag l (Conv none)) convert
151149152150let vflag_all v l =
153151 let convert _ cl =
···171169 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else
172170 Cmdliner_def.Arg_info.make_all_opts a
173171 in
174174- Cmdliner_term.make (list_to_args flag l no_completion) convert
172172+ Cmdliner_term.make (list_to_args flag l (Conv none)) convert
175173176174let parse_opt_value parse f v = match parse v with
177175| Ok v -> v | Error err -> failwith (Cmdliner_msg.err_opt_parse f ~err)
···203201 | (_, f, _) :: (_, g, _) :: _ ->
204202 parse_error (Cmdliner_msg.err_opt_repeated g f)
205203 in
206206- Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert
204204+ Cmdliner_term.make (arg_to_args a (Conv conv)) convert
207205208206let opt_all ?vopt conv v a =
209207 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else
···232230 (List.sort rev_compare (List.rev_map parse l))) with
233231 | Failure e -> parse_error e
234232 in
235235- Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert
233233+ Cmdliner_term.make (arg_to_args a (Conv conv)) convert
236234237235(* Positional arguments *)
238236···258256 | Failure e -> parse_error e)
259257 | _ -> assert false
260258 in
261261- Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert
259259+ Cmdliner_term.make (arg_to_args a (Conv conv)) convert
262260263261let pos_list pos conv v a =
264262 if Cmdliner_def.Arg_info.is_opt a then invalid_arg err_not_pos else
···273271 with
274272 | Failure e -> parse_error e
275273 in
276276- Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert
274274+ Cmdliner_term.make (arg_to_args a (Conv conv)) convert
277275278276let all = Cmdliner_def.Arg_info.pos ~rev:false ~start:0 ~len:None
279277let pos_all c v a = pos_list all c v a
+28-19
vendor/opam/cmdliner/src/cmdliner_def.ml
···209209 type ('ctx, 'a) completion_func =
210210 'ctx option -> token:string -> ('a completion_directive list, string) result
211211212212+ type 'a parser = string -> ('a, string) result
212213 type 'a complete =
213214 | Complete : 'ctx term option * ('ctx, 'a) completion_func -> 'a complete
214215215216 and 'a completion = { complete : 'a complete }
216216- and e_completion = Completion : 'a completion -> e_completion
217217- and arg_set = e_completion Map.t
217217+218218+ and 'a conv =
219219+ { docv : string;
220220+ parser : 'a parser;
221221+ pp : 'a Cmdliner_base.Fmt.t;
222222+ completion : 'a completion; }
223223+224224+ and e_conv = Conv : 'a conv -> e_conv
225225+ and arg_set = e_conv Map.t
218226 and cmd =
219227 { name : string; (* name of the cmd. *)
220228 version : string option; (* version (for --version). *)
···250258251259 module Set = struct
252260 include Map
253253- type t = e_completion Map.t
261261+ type t = e_conv Map.t
254262 let find_opt k m = try Some (Map.find k m) with Not_found -> None
255263 let elements m = List.map fst (bindings m)
256264 let union a b =
···409417(* Converters *)
410418411419module Arg_conv = struct
412412- type 'a parser = string -> ('a, string) result
413413- type 'a fmt = Format.formatter -> 'a -> unit
414414- type 'a t =
415415- { docv : string;
416416- parser : 'a parser;
417417- pp : 'a fmt;
418418- completion : 'a Arg_completion.t; }
420420+ type 'a parser = 'a Arg_info.parser
421421+ type 'a fmt = 'a Cmdliner_base.Fmt.t
422422+ type 'a t = 'a Arg_info.conv
419423420420- let make ?(completion = Arg_completion.complete_none) ~docv ~parser ~pp () =
424424+ let make
425425+ ?(completion = Arg_completion.complete_none) ~docv ~parser ~pp () : 'a t =
421426 { docv; parser; pp; completion }
422427423428 let of_conv
424424- conv
429429+ (conv : 'a t)
425430 ?(completion = conv.completion) ?(docv = conv.docv)
426426- ?(parser = conv.parser) ?(pp = conv.pp) ()
431431+ ?(parser = conv.parser) ?(pp = conv.pp) () : 'a t
427432 =
428433 { docv; parser; pp; completion }
429434430430- let docv c = c.docv
431431- let parser c = c.parser
432432- let pp c = c.pp
433433- let completion c = c.completion
435435+ let docv (c : 'a t) = c.docv
436436+ let parser (c : 'a t) = c.parser
437437+ let pp (c : 'a t) = c.pp
438438+ let completion (c : 'a t) = c.completion
439439+440440+ let none : 'a t =
441441+ { docv = "";
442442+ parser = (fun _ -> assert false);
443443+ pp = (fun _ _ -> assert false);
444444+ completion = Arg_completion.complete_none }
434445435446 let some ?(none = "") conv =
436447 let parser s = Result.map Option.some (parser conv s) in
···450461 let completion = Arg_completion.complete_some conv.completion in
451462 { conv with parser; pp; completion }
452463end
453453-454454-455464456465(* Completion *)
457466
+14-12
vendor/opam/cmdliner/src/cmdliner_def.mli
···119119120120 module Map : Map.S with type key := t
121121122122- type 'a completion
123123- type e_completion = Completion : 'a completion -> e_completion
122122+ type 'a conv
123123+ type e_conv = Conv : 'a conv -> e_conv
124124125125 module Set : sig
126126 type arg := t
127127 type t
128128 val is_empty : t -> bool
129129 val empty : t
130130- val add : arg -> e_completion -> t -> t
131131- val choose : t -> arg * e_completion
132132- val partition : (arg -> e_completion -> bool) -> t -> t * t
133133- val filter : (arg -> e_completion -> bool) -> t -> t
134134- val iter : (arg -> e_completion -> unit) -> t -> unit
135135- val singleton : arg -> e_completion -> t
136136- val fold : (arg -> e_completion -> 'acc -> 'acc) -> t -> 'acc -> 'acc
130130+ val add : arg -> e_conv -> t -> t
131131+ val choose : t -> arg * e_conv
132132+ val partition : (arg -> e_conv -> bool) -> t -> t * t
133133+ val filter : (arg -> e_conv -> bool) -> t -> t
134134+ val iter : (arg -> e_conv -> unit) -> t -> unit
135135+ val singleton : arg -> e_conv -> t
136136+ val fold : (arg -> e_conv -> 'acc -> 'acc) -> t -> 'acc -> 'acc
137137 val elements : t -> arg list
138138 val union : t -> t -> t
139139- val find_opt : arg -> t -> e_completion option
139139+ val find_opt : arg -> t -> e_conv option
140140 end
141141end
142142···229229 type 'a complete =
230230 | Complete : 'ctx Term.t option * ('ctx, 'a) func -> 'a complete
231231232232- type 'a t = 'a Arg_info.completion
232232+ type 'a t
233233234234 val make : ?context:'ctx Term.t -> ('ctx, 'a) func -> 'a t
235235 val complete : 'a t -> 'a complete
···244244module Arg_conv : sig
245245 type 'a parser = string -> ('a, string) result
246246 type 'a fmt = 'a Cmdliner_base.Fmt.t
247247- type 'a t
247247+ type 'a t = 'a Arg_info.conv
248248 val make :
249249 ?completion:'a Arg_completion.t -> docv:string -> parser:'a parser ->
250250 pp:'a fmt -> unit -> 'a t
···260260261261 val some : ?none:string -> 'a t -> 'a option t
262262 val some' : ?none:'a -> 'a t -> 'a option t
263263+264264+ val none : 'a t
263265end
264266265267
+3-3
vendor/opam/cmdliner/src/cmdliner_eval.ml
···5353 | Error _ -> None
5454 | exception exn -> None
55555656-5756let try_eval_stdopts ~catch ei cl help version : 'a eval_result option =
5857 match run_parser ~catch ei cl (Cmdliner_term.parser help) with
5958 | Ok (Some fmt) -> Some (Error (`Std_help fmt))
···120119 match Cmdliner_def.Arg_info.Set.find_opt
121120 arg_info cmd_args_info with
122121 | None -> comp
123123- | Some (Completion c) -> (* FIXME we want converter here *)
124124- match Cmdliner_def.Arg_completion.complete c with
122122+ | Some (Conv c) ->
123123+ let completion = Cmdliner_def.Arg_conv.completion c in
124124+ match Cmdliner_def.Arg_completion.complete completion with
125125 | Complete (ctx, func) ->
126126 let cline = Cmdliner_def.Complete.context comp in
127127 let ctx = match ctx with