···52525353(* Argument converters *)
54545555-module Completion = Cmdliner_base.Completion
5656-module Conv = Cmdliner_base.Conv
5555+module Completion = Cmdliner_info.Arg.Completion
5656+module Conv = Cmdliner_info.Arg.Conv
5757type 'a conv = 'a Conv.t
5858-let some = Cmdliner_base.Conv.some
5959-let some' = Cmdliner_base.Conv.some'
5858+let some = Cmdliner_info.Arg.Conv.some
5959+let some' = Cmdliner_info.Arg.Conv.some'
60606161(* Argument information *)
6262···6565let info = Cmdliner_info.Arg.make
66666767(* Arguments *)
6868+6969+let no_completion = Cmdliner_info.Arg.Set.V Cmdliner_info.Arg.Completion.none
68706971let ( & ) f x = f x
7072let parse_error e = Error (`Parse e)
···104106 | (_, f, _) :: (_ ,g, _) :: _ ->
105107 parse_error (Cmdliner_msg.err_opt_repeated f g)
106108 in
107107- Cmdliner_term.make (arg_to_args a (V Cmdliner_base.Completion.none)) convert
109109+ Cmdliner_term.make (arg_to_args a no_completion) convert
108110109111let flag_all a =
110112 if Cmdliner_info.Arg.is_pos a then invalid_arg err_not_opt else
···120122 Ok (List.rev_map truth l)
121123 with Failure e -> parse_error e
122124 in
123123- Cmdliner_term.make (arg_to_args a (V Cmdliner_base.Completion.none)) convert
125125+ Cmdliner_term.make (arg_to_args a no_completion) convert
124126125127let vflag v l =
126128 let convert _ cl =
···144146 let flag (_, a) =
145147 if Cmdliner_info.Arg.is_pos a then invalid_arg err_not_opt else a
146148 in
147147- Cmdliner_term.make
148148- (list_to_args flag l (V Cmdliner_base.Completion.none)) convert
149149+ Cmdliner_term.make (list_to_args flag l no_completion) convert
149150150151let vflag_all v l =
151152 let convert _ cl =
···169170 if Cmdliner_info.Arg.is_pos a then invalid_arg err_not_opt else
170171 Cmdliner_info.Arg.make_all_opts a
171172 in
172172- Cmdliner_term.make
173173- (list_to_args flag l (V Cmdliner_base.Completion.none)) convert
173173+ Cmdliner_term.make (list_to_args flag l no_completion) convert
174174175175let parse_opt_value parse f v = match parse v with
176176| Ok v -> v | Error err -> failwith (Cmdliner_msg.err_opt_parse f ~err)
-72
vendor/opam/cmdliner/src/cmdliner_base.ml
···251251 | hints, _ -> Fmt.pf ppf ". Did@ you@ mean@ %a?" pp_alts hints
252252 in
253253 Fmt.str "@[%a %s@ %a%a@]" Fmt.unknown () kind Fmt.code_or_quote v hints ()
254254-255255-(* Completions *)
256256-257257-module Completion = struct
258258- type complete = string -> (string * string) list
259259- type 'a t =
260260- { complete : complete;
261261- dirs : bool;
262262- files : bool;
263263- restart : bool }
264264-265265- let make
266266- ?(complete = Fun.const []) ?(dirs = false) ?(files = false)
267267- ?(restart = false) ()
268268- =
269269- {complete; dirs; files; restart}
270270-271271- let none = make ()
272272- let some = (Fun.id :> 'a t -> 'a option t)
273273- let complete c = c.complete
274274- let dirs c = c.dirs
275275- let files c = c.files
276276- let restart c = c.restart
277277-end
278278-279279-(* Converters *)
280280-281281-module Conv = struct
282282- type 'a parser = string -> ('a, string) result
283283- type 'a fmt = Format.formatter -> 'a -> unit
284284- type 'a t =
285285- { docv : string;
286286- parser : 'a parser;
287287- pp : 'a fmt;
288288- completion : 'a Completion.t; }
289289-290290- let make ?(completion = Completion.none) ~docv ~parser ~pp () =
291291- { docv; parser; pp; completion }
292292-293293- let of_conv
294294- conv ?(completion = conv.completion) ?(docv = conv.docv)
295295- ?(parser = conv.parser) ?(pp = conv.pp) ()
296296- =
297297- { docv; parser; pp; completion }
298298-299299- let docv c = c.docv
300300- let parser c = c.parser
301301- let pp c = c.pp
302302- let completion c = c.completion
303303-304304- let some ?(none = "") conv =
305305- let parser s = match parser conv s with
306306- | Ok v -> Ok (Some v) | Error _ as e -> e
307307- in
308308- let pp ppf v = match v with
309309- | None -> Format.pp_print_string ppf none
310310- | Some v -> pp conv ppf v
311311- in
312312- let completion = Completion.some (completion conv) in
313313- { conv with parser; pp; completion }
314314-315315- let some' ?none conv =
316316- let parser s = match parser conv s with
317317- | Ok v -> Ok (Some v) | Error _ as e -> e
318318- in
319319- let pp ppf = function
320320- | None -> (match none with None -> () | Some v -> (pp conv) ppf v)
321321- | Some v -> pp conv ppf v
322322- in
323323- let completion = Completion.some conv.completion in
324324- { conv with parser; pp; completion }
325325-end
-40
vendor/opam/cmdliner/src/cmdliner_base.mli
···5757 ?dom:string list -> ?hints:string list -> kind:string -> string -> string
5858val err_multi_def :
5959 kind:string -> string -> ('b -> string) -> 'b -> 'b -> string
6060-6161-(* Completion strategies *)
6262-6363-module Completion : sig
6464- type complete = string -> (string * string) list
6565- type 'a t
6666- val make :
6767- ?complete:complete -> ?dirs:bool -> ?files:bool -> ?restart:bool -> unit ->
6868- 'a t
6969-7070- val none : 'a t
7171- val some : 'a t -> 'a option t
7272- val complete : 'a t -> complete
7373- val dirs : 'a t -> bool
7474- val files : 'a t -> bool
7575- val restart : 'a t -> bool
7676-end
7777-7878-(* Textual OCaml value converters *)
7979-8080-module Conv : sig
8181- type 'a parser = string -> ('a, string) result
8282- type 'a fmt = 'a Fmt.t
8383- type 'a t
8484- val make :
8585- ?completion:'a Completion.t -> docv:string -> parser:'a parser ->
8686- pp:'a fmt -> unit -> 'a t
8787-8888- val of_conv : 'a t ->
8989- ?completion:'a Completion.t -> ?docv:string -> ?parser:'a parser ->
9090- ?pp:'a fmt -> unit -> 'a t
9191-9292- val docv : 'a t -> string
9393- val parser : 'a t -> 'a parser
9494- val pp : 'a t -> 'a fmt
9595- val completion : 'a t -> 'a Completion.t
9696-9797- val some : ?none:string -> 'a t -> 'a option t
9898- val some' : ?none:'a -> 'a t -> 'a option t
9999-end
+4-4
vendor/opam/cmdliner/src/cmdliner_completion.ml
···3434 end
35353636let pp_arg_values ~after_dashdash ~prefix ppf comp =
3737- if after_dashdash && Cmdliner_base.Completion.restart comp
3737+ if after_dashdash && Cmdliner_info.Arg.Completion.restart comp
3838 then pp_line ppf "restart" else
3939- let items = Cmdliner_base.Completion.complete comp prefix in
4040- let comp_files = Cmdliner_base.Completion.files comp in
4141- let comp_dirs = Cmdliner_base.Completion.dirs comp in
3939+ let items = Cmdliner_info.Arg.Completion.complete comp prefix in
4040+ let comp_files = Cmdliner_info.Arg.Completion.files comp in
4141+ let comp_dirs = Cmdliner_info.Arg.Completion.dirs comp in
4242 if items <> [] || comp_files || comp_dirs then begin
4343 pp_group ppf "Values";
4444 List.iter (pp_item ppf ~prefix) items;
+74-2
vendor/opam/cmdliner/src/cmdliner_info.ml
···8383(* Arguments *)
84848585module Arg = struct
8686+8787+ (* Completions *)
8888+8989+ module Completion = struct
9090+ type complete = string -> (string * string) list
9191+ type 'a t =
9292+ { complete : complete;
9393+ dirs : bool;
9494+ files : bool;
9595+ restart : bool }
9696+9797+ let make
9898+ ?(complete = Fun.const []) ?(dirs = false) ?(files = false)
9999+ ?(restart = false) ()
100100+ =
101101+ {complete; dirs; files; restart}
102102+103103+ let none = make ()
104104+ let some = (Fun.id :> 'a t -> 'a option t)
105105+ let complete c = c.complete
106106+ let dirs c = c.dirs
107107+ let files c = c.files
108108+ let restart c = c.restart
109109+ end
110110+111111+ (* Converters *)
112112+113113+ module Conv = struct
114114+ type 'a parser = string -> ('a, string) result
115115+ type 'a fmt = Format.formatter -> 'a -> unit
116116+ type 'a t =
117117+ { docv : string;
118118+ parser : 'a parser;
119119+ pp : 'a fmt;
120120+ completion : 'a Completion.t; }
121121+122122+ let make ?(completion = Completion.none) ~docv ~parser ~pp () =
123123+ { docv; parser; pp; completion }
124124+125125+ let of_conv
126126+ conv ?(completion = conv.completion) ?(docv = conv.docv)
127127+ ?(parser = conv.parser) ?(pp = conv.pp) ()
128128+ =
129129+ { docv; parser; pp; completion }
130130+131131+ let docv c = c.docv
132132+ let parser c = c.parser
133133+ let pp c = c.pp
134134+ let completion c = c.completion
135135+136136+ let some ?(none = "") conv =
137137+ let parser s = match parser conv s with
138138+ | Ok v -> Ok (Some v) | Error _ as e -> e
139139+ in
140140+ let pp ppf v = match v with
141141+ | None -> Format.pp_print_string ppf none
142142+ | Some v -> pp conv ppf v
143143+ in
144144+ let completion = Completion.some (completion conv) in
145145+ { conv with parser; pp; completion }
146146+147147+ let some' ?none conv =
148148+ let parser s = match parser conv s with
149149+ | Ok v -> Ok (Some v) | Error _ as e -> e
150150+ in
151151+ let pp ppf = function
152152+ | None -> (match none with None -> () | Some v -> (pp conv) ppf v)
153153+ | Some v -> pp conv ppf v
154154+ in
155155+ let completion = Completion.some conv.completion in
156156+ { conv with parser; pp; completion }
157157+ end
158158+86159 type absence = Err | Val of string Lazy.t | Doc of string
87160 type opt_kind = Flag | Opt | Opt_vopt of string
88161···197270198271 module Set = struct
199272 type arg = t
200200- type completion =
201201- | V : 'a Cmdliner_base.Completion.t -> completion
273273+ type completion = V : 'a Completion.t -> completion
202274203275 module Map = Map.Make (struct type t = arg let compare = compare end)
204276 include Map
+41-2
vendor/opam/cmdliner/src/cmdliner_info.mli
···5656(** Arguments *)
5757module Arg : sig
58585959+ (* Completion strategies *)
6060+6161+ module Completion : sig
6262+ type complete = string -> (string * string) list
6363+ type 'a t
6464+ val make :
6565+ ?complete:complete -> ?dirs:bool -> ?files:bool -> ?restart:bool ->
6666+ unit -> 'a t
6767+6868+ val none : 'a t
6969+ val some : 'a t -> 'a option t
7070+ val complete : 'a t -> complete
7171+ val dirs : 'a t -> bool
7272+ val files : 'a t -> bool
7373+ val restart : 'a t -> bool
7474+ end
7575+7676+ (* Textual OCaml value converters *)
7777+7878+ module Conv : sig
7979+ type 'a parser = string -> ('a, string) result
8080+ type 'a fmt = 'a Cmdliner_base.Fmt.t
8181+ type 'a t
8282+ val make :
8383+ ?completion:'a Completion.t -> docv:string -> parser:'a parser ->
8484+ pp:'a fmt -> unit -> 'a t
8585+8686+ val of_conv : 'a t ->
8787+ ?completion:'a Completion.t -> ?docv:string -> ?parser:'a parser ->
8888+ ?pp:'a fmt -> unit -> 'a t
8989+9090+ val docv : 'a t -> string
9191+ val parser : 'a t -> 'a parser
9292+ val pp : 'a t -> 'a fmt
9393+ val completion : 'a t -> 'a Completion.t
9494+9595+ val some : ?none:string -> 'a t -> 'a option t
9696+ val some' : ?none:'a -> 'a t -> 'a option t
9797+ end
9898+5999 type absence =
60100 | Err (** an error is reported. *)
61101 | Val of string Lazy.t (** if <> "", takes the given default value. *)
···123163124164 module Set : sig
125165 type arg = t
126126- type completion =
127127- | V : 'a Cmdliner_base.Completion.t -> completion
166166+ type completion = V : 'a Completion.t -> completion
128167129168 type t
130169 val is_empty : t -> bool