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.

Add context of type term to completion fields (#215)

This requires quite a bit of churn because it introduces
a type recursion.

+247 -231
+10 -9
vendor/opam/cmdliner/src/cmdliner_arg.ml
··· 52 52 53 53 (* Argument converters *) 54 54 55 - module Completion = Cmdliner_info.Arg.Completion 56 - module Conv = Cmdliner_info.Arg.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_info.Arg.Conv.some 59 - let some' = Cmdliner_info.Arg.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 ··· 66 66 67 67 (* Arguments *) 68 68 69 - let no_completion = Cmdliner_info.Arg.Set.V Cmdliner_info.Arg.Completion.none 69 + let no_completion = 70 + Cmdliner_info.Arg.Completion Cmdliner_info.Arg_completion.none 70 71 71 72 let ( & ) f x = f x 72 73 let parse_error e = Error (`Parse e) ··· 202 203 | (_, f, _) :: (_, g, _) :: _ -> 203 204 parse_error (Cmdliner_msg.err_opt_repeated g f) 204 205 in 205 - Cmdliner_term.make (arg_to_args a (V (Conv.completion conv))) convert 206 + Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 206 207 207 208 let opt_all ?vopt conv v a = 208 209 if Cmdliner_info.Arg.is_pos a then invalid_arg err_not_opt else ··· 231 232 (List.sort rev_compare (List.rev_map parse l))) with 232 233 | Failure e -> parse_error e 233 234 in 234 - Cmdliner_term.make (arg_to_args a (V (Conv.completion conv))) convert 235 + Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 235 236 236 237 (* Positional arguments *) 237 238 ··· 257 258 | Failure e -> parse_error e) 258 259 | _ -> assert false 259 260 in 260 - Cmdliner_term.make (arg_to_args a (V (Conv.completion conv))) convert 261 + Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 261 262 262 263 let pos_list pos conv v a = 263 264 if Cmdliner_info.Arg.is_opt a then invalid_arg err_not_pos else ··· 272 273 with 273 274 | Failure e -> parse_error e 274 275 in 275 - Cmdliner_term.make (arg_to_args a (V (Conv.completion conv))) convert 276 + Cmdliner_term.make (arg_to_args a (Completion (Conv.completion conv))) convert 276 277 277 278 let all = Cmdliner_info.Arg.pos ~rev:false ~start:0 ~len:None 278 279 let pos_all c v a = pos_list all c v a
+2
vendor/opam/cmdliner/src/cmdliner_arg.mli
··· 15 15 val make : 16 16 ?complete:complete -> ?dirs:bool -> ?files:bool -> ?restart:bool -> unit -> 17 17 'a t 18 + 19 + val context : 'a t -> 'a Cmdliner_term.t option 18 20 val complete : 'a t -> complete 19 21 val dirs : 'a t -> bool 20 22 val files : 'a t -> bool
+5 -5
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_info.Arg.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_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 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; ··· 65 65 let pp_arg_value ppf arg_info = 66 66 begin match Cmdliner_info.Arg.Set.find_opt arg_info cmd_args_info with 67 67 | None -> () 68 - | Some (V comp) -> pp_arg_values ~after_dashdash ~prefix ppf comp 68 + | Some (Completion comp) -> pp_arg_values ~after_dashdash ~prefix ppf comp 69 69 end; 70 70 in 71 71 let pp ppf () =
+174 -156
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 - 159 86 type absence = Err | Val of string Lazy.t | Doc of string 160 87 type opt_kind = Flag | Opt | Opt_vopt of string 161 - 162 88 type pos_kind = (* information about a positional argument. *) 163 89 { pos_rev : bool; (* if [true] positions are counted from the end. *) 164 90 pos_start : int; (* start positional argument. *) ··· 170 96 let pos_rev p = p.pos_rev 171 97 let pos_start p = p.pos_start 172 98 let pos_len p = p.pos_len 99 + let dumb_pos = pos ~rev:false ~start:(-1) ~len:None 173 100 174 101 type t = (* information about a command line argument. *) 175 102 { id : int; (* unique id for the argument. *) ··· 184 111 opt_kind : opt_kind; (* optional arg kind. *) 185 112 opt_names : string list; (* names (for opt args). *) 186 113 opt_all : bool; } (* repeatable (for opt args). *) 187 - 188 - let dumb_pos = pos ~rev:false ~start:(-1) ~len:None 189 114 190 115 let make 191 116 ?deprecated ?(absent = "") ?docs ?(doc_envs = []) ?(docv = "") ··· 240 165 let is_pos i = i.opt_names = [] 241 166 let is_req i = i.absent = Err 242 167 243 - let pos_cli_order a0 a1 = (* best-effort order on the cli. *) 244 - let c = compare (a0.pos.pos_rev) (a1.pos.pos_rev) in 168 + let pos_cli_order (a0 : t) (a1 : t) = (* best-effort order on the cli. *) 169 + let c = Bool.compare (a0.pos.pos_rev) (a1.pos.pos_rev) in 245 170 if c <> 0 then c else 246 171 if a0.pos.pos_rev 247 - then compare a1.pos.pos_start a0.pos.pos_start 248 - else compare a0.pos.pos_start a1.pos.pos_start 172 + then Int.compare a1.pos.pos_start a0.pos.pos_start 173 + else Int.compare a0.pos.pos_start a1.pos.pos_start 249 174 250 175 let rev_pos_cli_order a0 a1 = pos_cli_order a1 a0 251 176 252 - let compare a0 a1 = Int.compare a0.id a1.id 253 - 254 - let doclang_subst ~subst i = function 177 + let doclang_subst ~subst (i : t) = function 255 178 | "docv" -> 256 179 let docv = if i.docv = "" then "VAL" else i.docv in 257 180 Some (strf "$(i,%s)" (Cmdliner_manpage.escape docv)) ··· 262 185 | Some e -> Env.doclang_subst ~subst e id 263 186 | None -> subst id 264 187 265 - let styled_deprecated ~errs ~subst i = match i.deprecated with 188 + let styled_deprecated ~errs ~subst (i : t) = match i.deprecated with 266 189 | None -> "" | Some msg -> Cmdliner_manpage.doc_to_styled ~errs ~subst msg 267 190 268 - let styled_doc ~errs ~subst i = 191 + let styled_doc ~errs ~subst (i : t) = 269 192 Cmdliner_manpage.doc_to_styled ~errs ~subst i.doc 270 193 271 - module T = struct type nonrec t = t let compare = compare end 272 - module Map = Map.Make (T) 273 - module Set = struct 274 - type arg = t 275 - type completion = V : 'a Completion.t -> completion 194 + let compare (a0 : t) (a1 : t) = Int.compare a0.id a1.id 195 + module Map = Map.Make (struct type nonrec t = t let compare = compare end) 276 196 277 - include Map 197 + (* Due to terms appearing in the completion API, we have an annoying 198 + recursive type definition which we resolve here. Most of these 199 + types do not belong this module. *) 278 200 279 - type t = completion Map.t 201 + type term_escape = 202 + [ `Error of bool * string 203 + | `Help of Cmdliner_manpage.format * string option ] 280 204 281 - let find_opt k m = try Some (Map.find k m) with Not_found -> None 282 - let elements m = List.map fst (bindings m) 283 - let union a b = 284 - Map.merge (fun k v v' -> 285 - match v, v' with 286 - | Some v, _ | _, Some v -> Some v 287 - | None, None -> assert false) a b 288 - end 289 - end 205 + type complete = string -> (string * string) list 206 + type 'a completion = 207 + { context : 'a term option; 208 + complete : complete; 209 + dirs : bool; 210 + files : bool; 211 + restart : bool } 290 212 291 - (* Commands *) 213 + and e_completion = Completion : 'a completion -> e_completion 214 + and arg_set = e_completion Map.t 292 215 293 - module Cmd = struct 294 - type t = 216 + and cmd = 295 217 { name : string; (* name of the cmd. *) 296 218 version : string option; (* version (for --version). *) 297 219 deprecated : string option; (* deprecation message *) ··· 302 224 envs : Env.info list; (* env vars that influence the cmd. *) 303 225 man : Cmdliner_manpage.block list; (* man page text. *) 304 226 man_xrefs : Cmdliner_manpage.xref list; (* man cross-refs. *) 305 - args : Arg.Set.t; (* Command arguments. *) 227 + args : arg_set; (* Command arguments. *) 306 228 has_args : bool; (* [true] if has own parsing term. *) 307 - children : t list; } (* Children, if any. *) 229 + children : cmd list; } (* Children, if any. *) 230 + 231 + and eval = (* information about the evaluation context. *) 232 + { cmd : cmd; (* cmd being evaluated. *) 233 + ancestors : cmd list; (* ancestors of cmd, root is last. *) 234 + env : string -> string option; (* environment variable lookup. *) 235 + err_ppf : Format.formatter (* error formatter *) } 236 + 237 + and cline = cline_arg Map.t 238 + and cline_arg = (* unconverted argument data as found on the command line. *) 239 + | O of (int * string * (string option)) list (* (pos, name, value) of opt. *) 240 + | P of string list 241 + 242 + and 'a term_parser = 243 + eval -> cline -> ('a, [ `Parse of string | term_escape ]) result 244 + 245 + and 'a term = arg_set * 'a term_parser 246 + 247 + (* Sets of arguments stored as maps to their completion *) 248 + 249 + module Set = struct 250 + include Map 251 + type t = e_completion Map.t 252 + let find_opt k m = try Some (Map.find k m) with Not_found -> None 253 + let elements m = List.map fst (bindings m) 254 + let union a b = 255 + Map.merge (fun k v v' -> 256 + match v, v' with 257 + | Some v, _ | _, Some v -> Some v 258 + | None, None -> assert false) a b 259 + end 260 + end 308 261 262 + (* Commands *) 263 + 264 + module Cmd = struct 265 + type t = Arg.cmd 309 266 let make 310 267 ?deprecated ?(man_xrefs = [`Main]) ?(man = []) ?(envs = []) 311 268 ?(exits = Exit.defaults) ?(sdocs = Cmdliner_manpage.s_common_options) 312 - ?(docs = Cmdliner_manpage.s_commands) ?(doc = "") ?version name 269 + ?(docs = Cmdliner_manpage.s_commands) ?(doc = "") ?version name : t 313 270 = 314 271 { name; version; deprecated; doc; docs; sdocs; exits; 315 272 envs; man; man_xrefs; args = Arg.Set.empty; 316 273 has_args = true; children = [] } 317 274 318 - let name i = i.name 319 - let version i = i.version 320 - let deprecated i = i.deprecated 321 - let doc i = i.doc 322 - let docs i = i.docs 323 - let stdopts_docs i = i.sdocs 324 - let exits i = i.exits 325 - let envs i = i.envs 326 - let man i = i.man 327 - let man_xrefs i = i.man_xrefs 328 - let args i = i.args 329 - let has_args i = i.has_args 330 - let children i = i.children 331 - let add_args i args = { i with args = Arg.Set.union args i.args } 332 - let with_children cmd ~args ~children = 275 + let name (i : t) = i.name 276 + let version (i : t) = i.version 277 + let deprecated (i : t) = i.deprecated 278 + let doc (i : t) = i.doc 279 + let docs (i : t) = i.docs 280 + let stdopts_docs (i : t) = i.sdocs 281 + let exits (i : t) = i.exits 282 + let envs (i : t) = i.envs 283 + let man (i : t) = i.man 284 + let man_xrefs (i : t) = i.man_xrefs 285 + let args (i : t) = i.args 286 + let has_args (i : t) = i.has_args 287 + let children (i : t) = i.children 288 + let add_args (i : t) args = { i with args = Arg.Set.union args i.args } 289 + let with_children (i : t) ~args ~children = 333 290 let has_args, args = match args with 334 - | None -> false, cmd.args 335 - | Some args -> true, Arg.Set.union args cmd.args 291 + | None -> false, i.args 292 + | Some args -> true, Arg.Set.union args i.args 336 293 in 337 - { cmd with has_args; args; children } 294 + { i with has_args; args; children } 338 295 339 - let styled_deprecated ~errs ~subst i = match i.deprecated with 296 + let styled_deprecated ~errs ~subst (i : t) = match i.deprecated with 340 297 | None -> "" | Some msg -> Cmdliner_manpage.doc_to_styled ~errs ~subst msg 341 298 342 - let styled_doc ~errs ~subst i = 299 + let styled_doc ~errs ~subst (i : t) = 343 300 Cmdliner_manpage.doc_to_styled ~errs ~subst i.doc 344 301 345 - let escaped_name i = Cmdliner_manpage.escape i.name 302 + let escaped_name (i : t) = Cmdliner_manpage.escape i.name 346 303 end 347 304 348 305 (* Command lines *) 349 306 350 307 module Cline = struct 351 - type arg = (* unconverted argument data as found on the command line. *) 352 - | O of (int * string * (string option)) list (* (pos, name, value) of opt. *) 308 + type arg = Arg.cline_arg = 309 + | O of (int * string * (string option)) list 353 310 | P of string list 354 311 355 - type t = arg Arg.Map.t (* command line, maps arg_infos to arg value. *) 312 + type t = Arg.cline 356 313 end 357 - 358 314 359 315 (* Evaluation *) 360 316 361 317 module Eval = struct 362 - type t = (* information about the evaluation context. *) 363 - { cmd : Cmd.t; (* cmd being evaluated. *) 364 - ancestors : Cmd.t list; (* ancestors of cmd, root is last. *) 365 - env : string -> string option; (* environment variable lookup. *) 366 - err_ppf : Format.formatter (* error formatter *) } 318 + type t = Arg.eval 367 319 368 - let make ~cmd ~ancestors ~env ~err_ppf = { cmd; ancestors; env; err_ppf } 320 + let make ~cmd ~ancestors ~env ~err_ppf : t = { cmd; ancestors; env; err_ppf } 369 321 370 - let cmd i = i.cmd 371 - let ancestors i = i.ancestors 372 - let env_var i v = i.env v 373 - let err_ppf i = i.err_ppf 374 - let main i = match List.rev i.ancestors with [] -> i.cmd | m :: _ -> m 375 - let with_cmd i cmd = { i with cmd } 322 + let cmd (i : t) = i.cmd 323 + let ancestors (i : t) = i.ancestors 324 + let env_var (i : t) v = i.env v 325 + let err_ppf (i : t) = i.err_ppf 326 + let main (i : t) = match List.rev i.ancestors with [] -> i.cmd | m :: _ -> m 327 + let with_cmd (i : t) cmd = { i with cmd } 376 328 377 329 let doclang_name n = strf "$(b,%s)" (Cmd.escaped_name n) 378 330 let doclang_names names = 379 331 strf "$(b,%s)" (Cmdliner_manpage.escape (String.concat " " names)) 380 332 381 - let doclang_subst ei = function 382 - | "tname" | "cmd.name" -> Some (doclang_name ei.cmd) 383 - | "mname" | "tool" -> Some (doclang_name (main ei)) 333 + let doclang_subst (i : t) = function 334 + | "tname" | "cmd.name" -> Some (doclang_name i.cmd) 335 + | "mname" | "tool" -> Some (doclang_name (main i)) 384 336 | "cmd.parent" -> 385 - let ancestors = ancestors ei in 386 - if ancestors = [] then Some (doclang_name (main ei)) else 337 + let ancestors = ancestors i in 338 + if ancestors = [] then Some (doclang_name (main i)) else 387 339 Some (doclang_names (List.rev_map Cmd.name ancestors)) 388 340 | "iname" | "cmd" -> 389 - Some (doclang_names (List.rev_map Cmd.name (cmd ei :: ancestors ei))) 341 + Some (doclang_names (List.rev_map Cmd.name (cmd i :: ancestors i))) 390 342 | _ -> None 391 343 end 392 344 ··· 417 369 (* Terms *) 418 370 419 371 module Term = struct 420 - type escape = 421 - [ `Error of bool * string 422 - | `Help of Cmdliner_manpage.format * string option ] 372 + type escape = Arg.term_escape 373 + type 'a parser = 'a Arg.term_parser 374 + type 'a t = 'a Arg.term 375 + let some (aset, parser) = 376 + aset, (fun eval cline -> Result.map Option.some (parser eval cline)) 377 + end 378 + 379 + module Arg_completion = struct 380 + type complete = Arg.complete 381 + type 'a t = 'a Arg.completion 382 + 383 + let make 384 + ?(complete = Fun.const []) ?(dirs = false) ?(files = false) 385 + ?(restart = false) () : 'a t 386 + = 387 + {context = None; complete; dirs; files; restart} 388 + 389 + let none = make () 390 + let some (c : 'a t) = 391 + { c with context = Option.map Term.some c.context } 423 392 424 - type 'a parser = 425 - Eval.t -> Cline.t -> ('a, [ `Parse of string | escape ]) result 393 + let context (c : 'a t) = c.context 394 + let complete (c : 'a t) = c.complete 395 + let dirs (c : 'a t) = c.dirs 396 + let files (c : 'a t) = c.files 397 + let restart (c : 'a t) = c.restart 398 + end 426 399 427 - type 'a t = Arg.Set.t * 'a parser 400 + (* Converters *) 401 + 402 + module Arg_conv = struct 403 + type 'a parser = string -> ('a, string) result 404 + type 'a fmt = Format.formatter -> 'a -> unit 405 + type 'a t = 406 + { docv : string; 407 + parser : 'a parser; 408 + pp : 'a fmt; 409 + completion : 'a Arg_completion.t; } 410 + 411 + let make ?(completion = Arg_completion.none) ~docv ~parser ~pp () = 412 + { docv; parser; pp; completion } 413 + 414 + let of_conv 415 + conv ?(completion = conv.completion) ?(docv = conv.docv) 416 + ?(parser = conv.parser) ?(pp = conv.pp) () 417 + = 418 + { docv; parser; pp; completion } 419 + 420 + let docv c = c.docv 421 + let parser c = c.parser 422 + let pp c = c.pp 423 + let completion c = c.completion 424 + 425 + let some ?(none = "") conv = 426 + let parser s = match parser conv s with 427 + | Ok v -> Ok (Some v) | Error _ as e -> e 428 + in 429 + let pp ppf v = match v with 430 + | None -> Format.pp_print_string ppf none 431 + | Some v -> pp conv ppf v 432 + in 433 + let completion = Arg_completion.some (completion conv) in 434 + { conv with parser; pp; completion } 435 + 436 + let some' ?none conv = 437 + let parser s = match parser conv s with 438 + | Ok v -> Ok (Some v) | Error _ as e -> e 439 + in 440 + let pp ppf = function 441 + | None -> (match none with None -> () | Some v -> (pp conv) ppf v) 442 + | Some v -> pp conv ppf v 443 + in 444 + let completion = Arg_completion.some conv.completion in 445 + { conv with parser; pp; completion } 428 446 end
+55 -60
vendor/opam/cmdliner/src/cmdliner_info.mli
··· 3 3 SPDX-License-Identifier: ISC 4 4 ---------------------------------------------------------------------------*) 5 5 6 - (** Exit codes, environment variables, arguments, commands and eval information. 7 - 8 - These information types gathers untyped data used to parse command 9 - lines report errors and format man pages. *) 6 + (** Core definitions. *) 10 7 11 8 (** Exit codes. *) 12 9 module Exit : sig ··· 55 52 56 53 (** Arguments *) 57 54 module Arg : sig 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 - 99 55 type absence = 100 56 | Err (** an error is reported. *) 101 57 | Val of string Lazy.t (** if <> "", takes the given default value. *) ··· 161 117 val styled_doc : 162 118 errs:Format.formatter -> subst:Cmdliner_manpage.subst -> t -> string 163 119 120 + type 'a completion 121 + type e_completion = Completion : 'a completion -> e_completion 164 122 module Map : Map.S with type key := t 165 123 module Set : sig 166 - type arg = t 167 - type completion = V : 'a Completion.t -> completion 124 + type arg := t 168 125 type t 169 126 val is_empty : t -> bool 170 127 val empty : t 171 - val add : arg -> completion -> t -> t 172 - val choose : t -> arg * completion 173 - val partition : (arg -> completion -> bool) -> t -> t * t 174 - val filter : (arg -> completion -> bool) -> t -> t 175 - val iter : (arg -> completion -> unit) -> t -> unit 176 - val singleton : arg -> completion -> t 177 - val fold : (arg -> completion -> 'acc -> 'acc) -> t -> 'acc -> 'acc 128 + val add : arg -> e_completion -> t -> t 129 + val choose : t -> arg * e_completion 130 + val partition : (arg -> e_completion -> bool) -> t -> t * t 131 + val filter : (arg -> e_completion -> bool) -> t -> t 132 + val iter : (arg -> e_completion -> unit) -> t -> unit 133 + val singleton : arg -> e_completion -> t 134 + val fold : (arg -> e_completion -> 'acc -> 'acc) -> t -> 'acc -> 'acc 178 135 val elements : t -> arg list 179 136 val union : t -> t -> t 180 - val find_opt : arg -> t -> completion option 181 - end with type arg := t 137 + val find_opt : arg -> t -> e_completion option 138 + end 182 139 end 183 140 184 141 (** Commands. *) ··· 212 169 errs:Format.formatter -> subst:Cmdliner_manpage.subst -> t -> string 213 170 end 214 171 215 - 216 172 (** Untyped command line parses. *) 217 173 module Cline : sig 218 - type arg = (* unconverted argument data as found on the command line. *) 174 + type arg = 219 175 | O of (int * string * (string option)) list (* (pos, name, value) of opt. *) 220 - | P of string list 176 + | P of string list (** *) 177 + (** Unconverted argument data as found on the command line. *) 221 178 222 179 type t = arg Arg.Map.t (* command line, maps arg_infos to arg value. *) 223 180 end ··· 259 216 260 217 (** Terms, typed cli fragment definitions. *) 261 218 module Term : sig 262 - 263 219 type escape = 264 220 [ `Error of bool * string 265 221 | `Help of Cmdliner_manpage.format * string option ] ··· 269 225 270 226 type 'a t = Arg.Set.t * 'a parser 271 227 end 228 + 229 + (** Completion strategies *) 230 + module Arg_completion : sig 231 + type complete = string -> (string * string) list 232 + type 'a t = 'a Arg.completion 233 + val make : 234 + ?complete:complete -> ?dirs:bool -> ?files:bool -> ?restart:bool -> 235 + unit -> 'a t 236 + 237 + val context : 'a t -> 'a Term.t option 238 + val none : 'a t 239 + val some : 'a t -> 'a option t 240 + val complete : 'a t -> complete 241 + val dirs : 'a t -> bool 242 + val files : 'a t -> bool 243 + val restart : 'a t -> bool 244 + end 245 + 246 + (** Textual OCaml value converters *) 247 + module Arg_conv : sig 248 + type 'a parser = string -> ('a, string) result 249 + type 'a fmt = 'a Cmdliner_base.Fmt.t 250 + type 'a t 251 + val make : 252 + ?completion:'a Arg_completion.t -> docv:string -> parser:'a parser -> 253 + pp:'a fmt -> unit -> 'a t 254 + 255 + val of_conv : 'a t -> 256 + ?completion:'a Arg_completion.t -> ?docv:string -> ?parser:'a parser -> 257 + ?pp:'a fmt -> unit -> 'a t 258 + 259 + val docv : 'a t -> string 260 + val parser : 'a t -> 'a parser 261 + val pp : 'a t -> 'a fmt 262 + val completion : 'a t -> 'a Arg_completion.t 263 + 264 + val some : ?none:string -> 'a t -> 'a option t 265 + val some' : ?none:'a -> 'a t -> 'a option t 266 + end
+1 -1
vendor/opam/cmdliner/src/cmdliner_term.mli
··· 15 15 (** Type type for command line parser. given static information about 16 16 the command line and a command line to parse returns an OCaml value. *) 17 17 18 - type +'a t 18 + type +'a t = 'a Cmdliner_info.Term.t 19 19 (** The type for terms. The list of arguments it can parse and the parsing 20 20 function that does so. *) 21 21