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.

Have the whole converter in Arg_info.Set.t values

+54 -45
+9 -11
vendor/opam/cmdliner/src/cmdliner_arg.ml
··· 57 57 type 'a conv = 'a Conv.t 58 58 let some = Cmdliner_def.Arg_conv.some 59 59 let some' = Cmdliner_def.Arg_conv.some' 60 + let none = Cmdliner_def.Arg_conv.none 60 61 61 62 (* Argument information *) 62 63 ··· 65 66 let info = Cmdliner_def.Arg_info.make 66 67 67 68 (* Arguments *) 68 - 69 - let no_completion = 70 - Cmdliner_def.Arg_info.Completion Cmdliner_def.Arg_completion.complete_none 71 69 72 70 let ( & ) f x = f x 73 71 let parse_error e = Error (`Parse e) ··· 107 105 | (_, f, _) :: (_ ,g, _) :: _ -> 108 106 parse_error (Cmdliner_msg.err_opt_repeated f g) 109 107 in 110 - Cmdliner_term.make (arg_to_args a no_completion) convert 108 + Cmdliner_term.make (arg_to_args a (Conv none)) convert 111 109 112 110 let flag_all a = 113 111 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else ··· 123 121 Ok (List.rev_map truth l) 124 122 with Failure e -> parse_error e 125 123 in 126 - Cmdliner_term.make (arg_to_args a no_completion) convert 124 + Cmdliner_term.make (arg_to_args a (Conv none)) convert 127 125 128 126 let vflag v l = 129 127 let convert _ cl = ··· 147 145 let flag (_, a) = 148 146 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else a 149 147 in 150 - Cmdliner_term.make (list_to_args flag l no_completion) convert 148 + Cmdliner_term.make (list_to_args flag l (Conv none)) convert 151 149 152 150 let vflag_all v l = 153 151 let convert _ cl = ··· 171 169 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else 172 170 Cmdliner_def.Arg_info.make_all_opts a 173 171 in 174 - Cmdliner_term.make (list_to_args flag l no_completion) convert 172 + Cmdliner_term.make (list_to_args flag l (Conv none)) convert 175 173 176 174 let parse_opt_value parse f v = match parse v with 177 175 | Ok v -> v | Error err -> failwith (Cmdliner_msg.err_opt_parse f ~err) ··· 203 201 | (_, f, _) :: (_, g, _) :: _ -> 204 202 parse_error (Cmdliner_msg.err_opt_repeated g f) 205 203 in 206 - Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 204 + Cmdliner_term.make (arg_to_args a (Conv conv)) convert 207 205 208 206 let opt_all ?vopt conv v a = 209 207 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else ··· 232 230 (List.sort rev_compare (List.rev_map parse l))) with 233 231 | Failure e -> parse_error e 234 232 in 235 - Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 233 + Cmdliner_term.make (arg_to_args a (Conv conv)) convert 236 234 237 235 (* Positional arguments *) 238 236 ··· 258 256 | Failure e -> parse_error e) 259 257 | _ -> assert false 260 258 in 261 - Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 259 + Cmdliner_term.make (arg_to_args a (Conv conv)) convert 262 260 263 261 let pos_list pos conv v a = 264 262 if Cmdliner_def.Arg_info.is_opt a then invalid_arg err_not_pos else ··· 273 271 with 274 272 | Failure e -> parse_error e 275 273 in 276 - Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 274 + Cmdliner_term.make (arg_to_args a (Conv conv)) convert 277 275 278 276 let all = Cmdliner_def.Arg_info.pos ~rev:false ~start:0 ~len:None 279 277 let pos_all c v a = pos_list all c v a
+28 -19
vendor/opam/cmdliner/src/cmdliner_def.ml
··· 209 209 type ('ctx, 'a) completion_func = 210 210 'ctx option -> token:string -> ('a completion_directive list, string) result 211 211 212 + type 'a parser = string -> ('a, string) result 212 213 type 'a complete = 213 214 | Complete : 'ctx term option * ('ctx, 'a) completion_func -> 'a complete 214 215 215 216 and 'a completion = { complete : 'a complete } 216 - and e_completion = Completion : 'a completion -> e_completion 217 - and arg_set = e_completion Map.t 217 + 218 + and 'a conv = 219 + { docv : string; 220 + parser : 'a parser; 221 + pp : 'a Cmdliner_base.Fmt.t; 222 + completion : 'a completion; } 223 + 224 + and e_conv = Conv : 'a conv -> e_conv 225 + and arg_set = e_conv Map.t 218 226 and cmd = 219 227 { name : string; (* name of the cmd. *) 220 228 version : string option; (* version (for --version). *) ··· 250 258 251 259 module Set = struct 252 260 include Map 253 - type t = e_completion Map.t 261 + type t = e_conv Map.t 254 262 let find_opt k m = try Some (Map.find k m) with Not_found -> None 255 263 let elements m = List.map fst (bindings m) 256 264 let union a b = ··· 409 417 (* Converters *) 410 418 411 419 module Arg_conv = struct 412 - type 'a parser = string -> ('a, string) result 413 - type 'a fmt = Format.formatter -> 'a -> unit 414 - type 'a t = 415 - { docv : string; 416 - parser : 'a parser; 417 - pp : 'a fmt; 418 - completion : 'a Arg_completion.t; } 420 + type 'a parser = 'a Arg_info.parser 421 + type 'a fmt = 'a Cmdliner_base.Fmt.t 422 + type 'a t = 'a Arg_info.conv 419 423 420 - let make ?(completion = Arg_completion.complete_none) ~docv ~parser ~pp () = 424 + let make 425 + ?(completion = Arg_completion.complete_none) ~docv ~parser ~pp () : 'a t = 421 426 { docv; parser; pp; completion } 422 427 423 428 let of_conv 424 - conv 429 + (conv : 'a t) 425 430 ?(completion = conv.completion) ?(docv = conv.docv) 426 - ?(parser = conv.parser) ?(pp = conv.pp) () 431 + ?(parser = conv.parser) ?(pp = conv.pp) () : 'a t 427 432 = 428 433 { docv; parser; pp; completion } 429 434 430 - let docv c = c.docv 431 - let parser c = c.parser 432 - let pp c = c.pp 433 - let completion c = c.completion 435 + let docv (c : 'a t) = c.docv 436 + let parser (c : 'a t) = c.parser 437 + let pp (c : 'a t) = c.pp 438 + let completion (c : 'a t) = c.completion 439 + 440 + let none : 'a t = 441 + { docv = ""; 442 + parser = (fun _ -> assert false); 443 + pp = (fun _ _ -> assert false); 444 + completion = Arg_completion.complete_none } 434 445 435 446 let some ?(none = "") conv = 436 447 let parser s = Result.map Option.some (parser conv s) in ··· 450 461 let completion = Arg_completion.complete_some conv.completion in 451 462 { conv with parser; pp; completion } 452 463 end 453 - 454 - 455 464 456 465 (* Completion *) 457 466
+14 -12
vendor/opam/cmdliner/src/cmdliner_def.mli
··· 119 119 120 120 module Map : Map.S with type key := t 121 121 122 - type 'a completion 123 - type e_completion = Completion : 'a completion -> e_completion 122 + type 'a conv 123 + type e_conv = Conv : 'a conv -> e_conv 124 124 125 125 module Set : sig 126 126 type arg := t 127 127 type t 128 128 val is_empty : t -> bool 129 129 val empty : t 130 - val add : arg -> e_completion -> t -> t 131 - val choose : t -> arg * e_completion 132 - val partition : (arg -> e_completion -> bool) -> t -> t * t 133 - val filter : (arg -> e_completion -> bool) -> t -> t 134 - val iter : (arg -> e_completion -> unit) -> t -> unit 135 - val singleton : arg -> e_completion -> t 136 - val fold : (arg -> e_completion -> 'acc -> 'acc) -> t -> 'acc -> 'acc 130 + val add : arg -> e_conv -> t -> t 131 + val choose : t -> arg * e_conv 132 + val partition : (arg -> e_conv -> bool) -> t -> t * t 133 + val filter : (arg -> e_conv -> bool) -> t -> t 134 + val iter : (arg -> e_conv -> unit) -> t -> unit 135 + val singleton : arg -> e_conv -> t 136 + val fold : (arg -> e_conv -> 'acc -> 'acc) -> t -> 'acc -> 'acc 137 137 val elements : t -> arg list 138 138 val union : t -> t -> t 139 - val find_opt : arg -> t -> e_completion option 139 + val find_opt : arg -> t -> e_conv option 140 140 end 141 141 end 142 142 ··· 229 229 type 'a complete = 230 230 | Complete : 'ctx Term.t option * ('ctx, 'a) func -> 'a complete 231 231 232 - type 'a t = 'a Arg_info.completion 232 + type 'a t 233 233 234 234 val make : ?context:'ctx Term.t -> ('ctx, 'a) func -> 'a t 235 235 val complete : 'a t -> 'a complete ··· 244 244 module Arg_conv : sig 245 245 type 'a parser = string -> ('a, string) result 246 246 type 'a fmt = 'a Cmdliner_base.Fmt.t 247 - type 'a t 247 + type 'a t = 'a Arg_info.conv 248 248 val make : 249 249 ?completion:'a Arg_completion.t -> docv:string -> parser:'a parser -> 250 250 pp:'a fmt -> unit -> 'a t ··· 260 260 261 261 val some : ?none:string -> 'a t -> 'a option t 262 262 val some' : ?none:'a -> 'a t -> 'a option t 263 + 264 + val none : 'a t 263 265 end 264 266 265 267
+3 -3
vendor/opam/cmdliner/src/cmdliner_eval.ml
··· 53 53 | Error _ -> None 54 54 | exception exn -> None 55 55 56 - 57 56 let try_eval_stdopts ~catch ei cl help version : 'a eval_result option = 58 57 match run_parser ~catch ei cl (Cmdliner_term.parser help) with 59 58 | Ok (Some fmt) -> Some (Error (`Std_help fmt)) ··· 120 119 match Cmdliner_def.Arg_info.Set.find_opt 121 120 arg_info cmd_args_info with 122 121 | None -> comp 123 - | Some (Completion c) -> (* FIXME we want converter here *) 124 - match Cmdliner_def.Arg_completion.complete c with 122 + | Some (Conv c) -> 123 + let completion = Cmdliner_def.Arg_conv.completion c in 124 + match Cmdliner_def.Arg_completion.complete completion with 125 125 | Complete (ctx, func) -> 126 126 let cline = Cmdliner_def.Complete.context comp in 127 127 let ctx = match ctx with