The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move Cmdliner_base.{Complete,Conv} to Cmdliner_info.Arg (#215)

+129 -130
+10 -10
vendor/opam/cmdliner/src/cmdliner_arg.ml
··· 52 52 53 53 (* Argument converters *) 54 54 55 - module Completion = Cmdliner_base.Completion 56 - module Conv = Cmdliner_base.Conv 55 + module Completion = Cmdliner_info.Arg.Completion 56 + module Conv = Cmdliner_info.Arg.Conv 57 57 type 'a conv = 'a Conv.t 58 - let some = Cmdliner_base.Conv.some 59 - let some' = Cmdliner_base.Conv.some' 58 + let some = Cmdliner_info.Arg.Conv.some 59 + let some' = Cmdliner_info.Arg.Conv.some' 60 60 61 61 (* Argument information *) 62 62 ··· 65 65 let info = Cmdliner_info.Arg.make 66 66 67 67 (* Arguments *) 68 + 69 + let no_completion = Cmdliner_info.Arg.Set.V Cmdliner_info.Arg.Completion.none 68 70 69 71 let ( & ) f x = f x 70 72 let parse_error e = Error (`Parse e) ··· 104 106 | (_, f, _) :: (_ ,g, _) :: _ -> 105 107 parse_error (Cmdliner_msg.err_opt_repeated f g) 106 108 in 107 - Cmdliner_term.make (arg_to_args a (V Cmdliner_base.Completion.none)) convert 109 + Cmdliner_term.make (arg_to_args a no_completion) convert 108 110 109 111 let flag_all a = 110 112 if Cmdliner_info.Arg.is_pos a then invalid_arg err_not_opt else ··· 120 122 Ok (List.rev_map truth l) 121 123 with Failure e -> parse_error e 122 124 in 123 - Cmdliner_term.make (arg_to_args a (V Cmdliner_base.Completion.none)) convert 125 + Cmdliner_term.make (arg_to_args a no_completion) convert 124 126 125 127 let vflag v l = 126 128 let convert _ cl = ··· 144 146 let flag (_, a) = 145 147 if Cmdliner_info.Arg.is_pos a then invalid_arg err_not_opt else a 146 148 in 147 - Cmdliner_term.make 148 - (list_to_args flag l (V Cmdliner_base.Completion.none)) convert 149 + Cmdliner_term.make (list_to_args flag l no_completion) convert 149 150 150 151 let vflag_all v l = 151 152 let convert _ cl = ··· 169 170 if Cmdliner_info.Arg.is_pos a then invalid_arg err_not_opt else 170 171 Cmdliner_info.Arg.make_all_opts a 171 172 in 172 - Cmdliner_term.make 173 - (list_to_args flag l (V Cmdliner_base.Completion.none)) convert 173 + Cmdliner_term.make (list_to_args flag l no_completion) convert 174 174 175 175 let parse_opt_value parse f v = match parse v with 176 176 | Ok v -> v | Error err -> failwith (Cmdliner_msg.err_opt_parse f ~err)
-72
vendor/opam/cmdliner/src/cmdliner_base.ml
··· 251 251 | hints, _ -> Fmt.pf ppf ". Did@ you@ mean@ %a?" pp_alts hints 252 252 in 253 253 Fmt.str "@[%a %s@ %a%a@]" Fmt.unknown () kind Fmt.code_or_quote v hints () 254 - 255 - (* Completions *) 256 - 257 - module Completion = struct 258 - type complete = string -> (string * string) list 259 - type 'a t = 260 - { complete : complete; 261 - dirs : bool; 262 - files : bool; 263 - restart : bool } 264 - 265 - let make 266 - ?(complete = Fun.const []) ?(dirs = false) ?(files = false) 267 - ?(restart = false) () 268 - = 269 - {complete; dirs; files; restart} 270 - 271 - let none = make () 272 - let some = (Fun.id :> 'a t -> 'a option t) 273 - let complete c = c.complete 274 - let dirs c = c.dirs 275 - let files c = c.files 276 - let restart c = c.restart 277 - end 278 - 279 - (* Converters *) 280 - 281 - module Conv = struct 282 - type 'a parser = string -> ('a, string) result 283 - type 'a fmt = Format.formatter -> 'a -> unit 284 - type 'a t = 285 - { docv : string; 286 - parser : 'a parser; 287 - pp : 'a fmt; 288 - completion : 'a Completion.t; } 289 - 290 - let make ?(completion = Completion.none) ~docv ~parser ~pp () = 291 - { docv; parser; pp; completion } 292 - 293 - let of_conv 294 - conv ?(completion = conv.completion) ?(docv = conv.docv) 295 - ?(parser = conv.parser) ?(pp = conv.pp) () 296 - = 297 - { docv; parser; pp; completion } 298 - 299 - let docv c = c.docv 300 - let parser c = c.parser 301 - let pp c = c.pp 302 - let completion c = c.completion 303 - 304 - let some ?(none = "") conv = 305 - let parser s = match parser conv s with 306 - | Ok v -> Ok (Some v) | Error _ as e -> e 307 - in 308 - let pp ppf v = match v with 309 - | None -> Format.pp_print_string ppf none 310 - | Some v -> pp conv ppf v 311 - in 312 - let completion = Completion.some (completion conv) in 313 - { conv with parser; pp; completion } 314 - 315 - let some' ?none conv = 316 - let parser s = match parser conv s with 317 - | Ok v -> Ok (Some v) | Error _ as e -> e 318 - in 319 - let pp ppf = function 320 - | None -> (match none with None -> () | Some v -> (pp conv) ppf v) 321 - | Some v -> pp conv ppf v 322 - in 323 - let completion = Completion.some conv.completion in 324 - { conv with parser; pp; completion } 325 - end
-40
vendor/opam/cmdliner/src/cmdliner_base.mli
··· 57 57 ?dom:string list -> ?hints:string list -> kind:string -> string -> string 58 58 val err_multi_def : 59 59 kind:string -> string -> ('b -> string) -> 'b -> 'b -> string 60 - 61 - (* Completion strategies *) 62 - 63 - module Completion : sig 64 - type complete = string -> (string * string) list 65 - type 'a t 66 - val make : 67 - ?complete:complete -> ?dirs:bool -> ?files:bool -> ?restart:bool -> unit -> 68 - 'a t 69 - 70 - val none : 'a t 71 - val some : 'a t -> 'a option t 72 - val complete : 'a t -> complete 73 - val dirs : 'a t -> bool 74 - val files : 'a t -> bool 75 - val restart : 'a t -> bool 76 - end 77 - 78 - (* Textual OCaml value converters *) 79 - 80 - module Conv : sig 81 - type 'a parser = string -> ('a, string) result 82 - type 'a fmt = 'a Fmt.t 83 - type 'a t 84 - val make : 85 - ?completion:'a Completion.t -> docv:string -> parser:'a parser -> 86 - pp:'a fmt -> unit -> 'a t 87 - 88 - val of_conv : 'a t -> 89 - ?completion:'a Completion.t -> ?docv:string -> ?parser:'a parser -> 90 - ?pp:'a fmt -> unit -> 'a t 91 - 92 - val docv : 'a t -> string 93 - val parser : 'a t -> 'a parser 94 - val pp : 'a t -> 'a fmt 95 - val completion : 'a t -> 'a Completion.t 96 - 97 - val some : ?none:string -> 'a t -> 'a option t 98 - val some' : ?none:'a -> 'a t -> 'a option t 99 - end
+4 -4
vendor/opam/cmdliner/src/cmdliner_completion.ml
··· 34 34 end 35 35 36 36 let pp_arg_values ~after_dashdash ~prefix ppf comp = 37 - if after_dashdash && Cmdliner_base.Completion.restart comp 37 + if after_dashdash && Cmdliner_info.Arg.Completion.restart comp 38 38 then pp_line ppf "restart" else 39 - let items = Cmdliner_base.Completion.complete comp prefix in 40 - let comp_files = Cmdliner_base.Completion.files comp in 41 - let comp_dirs = Cmdliner_base.Completion.dirs comp in 39 + let items = Cmdliner_info.Arg.Completion.complete comp prefix in 40 + let comp_files = Cmdliner_info.Arg.Completion.files comp in 41 + let comp_dirs = Cmdliner_info.Arg.Completion.dirs comp in 42 42 if items <> [] || comp_files || comp_dirs then begin 43 43 pp_group ppf "Values"; 44 44 List.iter (pp_item ppf ~prefix) items;
+74 -2
vendor/opam/cmdliner/src/cmdliner_info.ml
··· 83 83 (* Arguments *) 84 84 85 85 module Arg = struct 86 + 87 + (* Completions *) 88 + 89 + module Completion = struct 90 + type complete = string -> (string * string) list 91 + type 'a t = 92 + { complete : complete; 93 + dirs : bool; 94 + files : bool; 95 + restart : bool } 96 + 97 + let make 98 + ?(complete = Fun.const []) ?(dirs = false) ?(files = false) 99 + ?(restart = false) () 100 + = 101 + {complete; dirs; files; restart} 102 + 103 + let none = make () 104 + let some = (Fun.id :> 'a t -> 'a option t) 105 + let complete c = c.complete 106 + let dirs c = c.dirs 107 + let files c = c.files 108 + let restart c = c.restart 109 + end 110 + 111 + (* Converters *) 112 + 113 + module Conv = struct 114 + type 'a parser = string -> ('a, string) result 115 + type 'a fmt = Format.formatter -> 'a -> unit 116 + type 'a t = 117 + { docv : string; 118 + parser : 'a parser; 119 + pp : 'a fmt; 120 + completion : 'a Completion.t; } 121 + 122 + let make ?(completion = Completion.none) ~docv ~parser ~pp () = 123 + { docv; parser; pp; completion } 124 + 125 + let of_conv 126 + conv ?(completion = conv.completion) ?(docv = conv.docv) 127 + ?(parser = conv.parser) ?(pp = conv.pp) () 128 + = 129 + { docv; parser; pp; completion } 130 + 131 + let docv c = c.docv 132 + let parser c = c.parser 133 + let pp c = c.pp 134 + let completion c = c.completion 135 + 136 + let some ?(none = "") conv = 137 + let parser s = match parser conv s with 138 + | Ok v -> Ok (Some v) | Error _ as e -> e 139 + in 140 + let pp ppf v = match v with 141 + | None -> Format.pp_print_string ppf none 142 + | Some v -> pp conv ppf v 143 + in 144 + let completion = Completion.some (completion conv) in 145 + { conv with parser; pp; completion } 146 + 147 + let some' ?none conv = 148 + let parser s = match parser conv s with 149 + | Ok v -> Ok (Some v) | Error _ as e -> e 150 + in 151 + let pp ppf = function 152 + | None -> (match none with None -> () | Some v -> (pp conv) ppf v) 153 + | Some v -> pp conv ppf v 154 + in 155 + let completion = Completion.some conv.completion in 156 + { conv with parser; pp; completion } 157 + end 158 + 86 159 type absence = Err | Val of string Lazy.t | Doc of string 87 160 type opt_kind = Flag | Opt | Opt_vopt of string 88 161 ··· 197 270 198 271 module Set = struct 199 272 type arg = t 200 - type completion = 201 - | V : 'a Cmdliner_base.Completion.t -> completion 273 + type completion = V : 'a Completion.t -> completion 202 274 203 275 module Map = Map.Make (struct type t = arg let compare = compare end) 204 276 include Map
+41 -2
vendor/opam/cmdliner/src/cmdliner_info.mli
··· 56 56 (** Arguments *) 57 57 module Arg : sig 58 58 59 + (* Completion strategies *) 60 + 61 + module Completion : sig 62 + type complete = string -> (string * string) list 63 + type 'a t 64 + val make : 65 + ?complete:complete -> ?dirs:bool -> ?files:bool -> ?restart:bool -> 66 + unit -> 'a t 67 + 68 + val none : 'a t 69 + val some : 'a t -> 'a option t 70 + val complete : 'a t -> complete 71 + val dirs : 'a t -> bool 72 + val files : 'a t -> bool 73 + val restart : 'a t -> bool 74 + end 75 + 76 + (* Textual OCaml value converters *) 77 + 78 + module Conv : sig 79 + type 'a parser = string -> ('a, string) result 80 + type 'a fmt = 'a Cmdliner_base.Fmt.t 81 + type 'a t 82 + val make : 83 + ?completion:'a Completion.t -> docv:string -> parser:'a parser -> 84 + pp:'a fmt -> unit -> 'a t 85 + 86 + val of_conv : 'a t -> 87 + ?completion:'a Completion.t -> ?docv:string -> ?parser:'a parser -> 88 + ?pp:'a fmt -> unit -> 'a t 89 + 90 + val docv : 'a t -> string 91 + val parser : 'a t -> 'a parser 92 + val pp : 'a t -> 'a fmt 93 + val completion : 'a t -> 'a Completion.t 94 + 95 + val some : ?none:string -> 'a t -> 'a option t 96 + val some' : ?none:'a -> 'a t -> 'a option t 97 + end 98 + 59 99 type absence = 60 100 | Err (** an error is reported. *) 61 101 | Val of string Lazy.t (** if <> "", takes the given default value. *) ··· 123 163 124 164 module Set : sig 125 165 type arg = t 126 - type completion = 127 - | V : 'a Cmdliner_base.Completion.t -> completion 166 + type completion = V : 'a Completion.t -> completion 128 167 129 168 type t 130 169 val is_empty : t -> bool