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.

Moving stuff around.

+148 -141
+8 -8
vendor/opam/cmdliner/src/cmdliner_arg.ml
··· 98 98 99 99 let flag a = 100 100 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else 101 - let convert ei cl = match Cmdliner_cline.opt_arg cl a with 101 + let convert ei cl = match Cmdliner_def.Cline.get_opt_arg cl a with 102 102 | [] -> try_env ei a env_bool_parse ~absent:false 103 103 | [_, _, None] -> Ok true 104 104 | [_, f, Some v] -> parse_error (Cmdliner_msg.err_flag_value f v) ··· 110 110 let flag_all a = 111 111 if Cmdliner_def.Arg_info.is_pos a then invalid_arg err_not_opt else 112 112 let a = Cmdliner_def.Arg_info.make_all_opts a in 113 - let convert ei cl = match Cmdliner_cline.opt_arg cl a with 113 + let convert ei cl = match Cmdliner_def.Cline.get_opt_arg cl a with 114 114 | [] -> try_env ei a (parse_to_list env_bool_parse) ~absent:[] 115 115 | l -> 116 116 try ··· 127 127 let convert _ cl = 128 128 let rec aux fv = function 129 129 | (v, a) :: rest -> 130 - begin match Cmdliner_cline.opt_arg cl a with 130 + begin match Cmdliner_def.Cline.get_opt_arg cl a with 131 131 | [] -> aux fv rest 132 132 | [_, f, None] -> 133 133 begin match fv with ··· 151 151 let convert _ cl = 152 152 let rec aux acc = function 153 153 | (fv, a) :: rest -> 154 - begin match Cmdliner_cline.opt_arg cl a with 154 + begin match Cmdliner_def.Cline.get_opt_arg cl a with 155 155 | [] -> aux acc rest 156 156 | l -> 157 157 let fval (k, f, v) = match v with ··· 188 188 | "" -> Conv.docv conv | docv -> docv 189 189 in 190 190 let a = Cmdliner_def.Arg_info.make_opt ~docv ~absent ~kind a in 191 - let convert ei cl = match Cmdliner_cline.opt_arg cl a with 191 + let convert ei cl = match Cmdliner_def.Cline.get_opt_arg cl a with 192 192 | [] -> try_env ei a (Conv.parser conv) ~absent:v 193 193 | [_, f, Some v] -> 194 194 (try Ok (parse_opt_value (Conv.parser conv) f v) with ··· 217 217 | "" -> Conv.docv conv | docv -> docv 218 218 in 219 219 let a = Cmdliner_def.Arg_info.make_opt_all ~docv ~absent ~kind a in 220 - let convert ei cl = match Cmdliner_cline.opt_arg cl a with 220 + let convert ei cl = match Cmdliner_def.Cline.get_opt_arg cl a with 221 221 | [] -> try_env ei a (parse_to_list (Conv.parser conv)) ~absent:v 222 222 | l -> 223 223 let parse (k, f, v) = match v with ··· 249 249 | "" -> Conv.docv conv | docv -> docv 250 250 in 251 251 let a = Cmdliner_def.Arg_info.make_pos_abs ~docv ~absent ~pos a in 252 - let convert ei cl = match Cmdliner_cline.pos_arg cl a with 252 + let convert ei cl = match Cmdliner_def.Cline.get_pos_arg cl a with 253 253 | [] -> try_env ei a (Conv.parser conv) ~absent:v 254 254 | [v] -> 255 255 (try Ok (parse_pos_value (Conv.parser conv) a v) with ··· 264 264 | "" -> Conv.docv conv | docv -> docv 265 265 in 266 266 let a = Cmdliner_def.Arg_info.make_pos ~docv ~pos a in 267 - let convert ei cl = match Cmdliner_cline.pos_arg cl a with 267 + let convert ei cl = match Cmdliner_def.Cline.get_pos_arg cl a with 268 268 | [] -> try_env ei a (parse_to_list (Conv.parser conv)) ~absent:v 269 269 | l -> 270 270 try Ok (List.rev (List.rev_map (parse_pos_value (Conv.parser conv) a) l))
+34 -94
vendor/opam/cmdliner/src/cmdliner_cline.ml
··· 5 5 6 6 (* A command line stores pre-parsed information about the command 7 7 line's arguments in a more structured way. Given the 8 - Cmdliner_info.arg values mentioned in a term and Sys.argv 9 - (without exec name) we parse the command line into a map of 10 - Cmdliner_info.arg values to [arg] values (see below). This map is used by 11 - the term's closures to retrieve and convert command line arguments 12 - (see the Cmdliner_arg module). *) 8 + Cmdliner_def.Arg_info.t values mentioned in a term and Sys.argv 9 + (without exec name) we parse the command line into 10 + [Cmdliner_def.Cline.t] which is map of [Cmdliner_def.Arg_info.t] 11 + values to [Cmdliner_def.Cline.arg] values. This map is used by the 12 + term's closures to retrieve and convert command line arguments (see 13 + the [Cmdliner_arg] module). *) 13 14 14 15 (* Completion *) 15 16 ··· 36 37 37 38 (* Command lines *) 38 39 39 - let err_multi_opt_name_def name a a' = 40 - let kind = "option name" in 41 - Cmdliner_base.err_multi_def ~kind name Cmdliner_def.Arg_info.doc a a' 42 - 43 - type arg = Cmdliner_def.Cline.arg 44 - type t = Cmdliner_def.Cline.t 45 - 46 - let get_arg cline a : arg = 47 - try Cmdliner_def.Arg_info.Map.find a cline with Not_found -> assert false 48 - 49 - let opt_arg cline a = match get_arg cline a with O l -> l | _ -> assert false 50 - let pos_arg cline a = match get_arg cline a with P l -> l | _ -> assert false 51 - let actual_args cline a = match get_arg cline a with 52 - | P args -> args 53 - | O l -> 54 - let extract_args (_pos, name, value) = 55 - name :: (match value with None -> [] | Some v -> [v]) 56 - in 57 - List.concat (List.map extract_args l) 40 + let err_multi_opt_name_def name arg_info arg_info' = 41 + Cmdliner_base.err_multi_def ~kind:"option name" name 42 + Cmdliner_def.Arg_info.doc arg_info arg_info' 58 43 59 - let arg_info_indexes args = 44 + let arg_info_indexes arg_infos = 60 45 (* from [args] returns a trie mapping the names of optional arguments to 61 46 their arg_info, a list with all arg_info for positional arguments and 62 47 a cmdline mapping each arg_info to an empty [arg]. *) 63 48 let rec loop optidx posidx cline = function 64 49 | [] -> optidx, posidx, cline 65 - | a :: l -> 66 - match Cmdliner_def.Arg_info.is_pos a with 50 + | arg_info :: l -> 51 + match Cmdliner_def.Arg_info.is_pos arg_info with 67 52 | true -> 68 - let cline = Cmdliner_def.Arg_info.Map.add a (P [] : arg) cline in 69 - loop optidx (a :: posidx) cline l 53 + let cline = Cmdliner_def.Cline.add arg_info (P []) cline in 54 + loop optidx (arg_info :: posidx) cline l 70 55 | false -> 71 - let add t name = match Cmdliner_trie.add t name a with 56 + let add t name = match Cmdliner_trie.add t name arg_info with 72 57 | `New t -> t 73 - | `Replaced (a', _) -> invalid_arg (err_multi_opt_name_def name a a') 58 + | `Replaced (a', _) -> 59 + invalid_arg (err_multi_opt_name_def name arg_info a') 74 60 in 75 - let names = Cmdliner_def.Arg_info.opt_names a in 61 + let names = Cmdliner_def.Arg_info.opt_names arg_info in 76 62 let optidx = List.fold_left add optidx names in 77 - let cline = Cmdliner_def.Arg_info.Map.add a (O [] : arg) cline in 63 + let cline = Cmdliner_def.Cline.add arg_info (O []) cline in 78 64 loop optidx posidx cline l 79 65 in 80 - let cline = Cmdliner_def.Arg_info.Map.empty in 81 - loop Cmdliner_trie.empty [] cline (Cmdliner_def.Arg_info.Set.elements args) 66 + let cline = Cmdliner_def.Cline.empty in 67 + let arg_infos = Cmdliner_def.Arg_info.Set.elements arg_infos in 68 + loop Cmdliner_trie.empty [] cline arg_infos 82 69 83 70 (* Optional argument parsing *) 84 71 ··· 107 94 with Not_found -> s, None, is_completion 108 95 109 96 let hint_matching_opt optidx s = 110 - (* hint options that could match [s] in [optidx]. FIXME explain this is 111 - a bit obscure. *) 97 + (* hint option names that could match [s] in [optidx]. *) 112 98 if String.length s <= 2 then [] else 113 99 let short_opt, long_opt = 114 100 if s.[1] <> '-' ··· 204 190 then try_complete_opt_value cline arg_info name value args 205 191 else parse_opt_value ~for_completion cline arg_info name value args 206 192 in 207 - let arg : arg = O ((k, name, value) :: opt_arg cline arg_info) in 208 - let cline = Cmdliner_def.Arg_info.Map.add arg_info arg cline in 193 + let arg : Cmdliner_def.Cline.arg = 194 + O ((k, name, value) :: 195 + Cmdliner_def.Cline.get_opt_arg cline arg_info) 196 + in 197 + let cline = Cmdliner_def.Cline.add arg_info arg cline in 209 198 loop errs (k + 1) cline pargs args 210 199 | Error `Not_found when for_completion -> 211 200 if not is_completion ··· 266 255 | Some n -> pos rev (Cmdliner_def.Arg_info.pos_start apos + n - 1) 267 256 in 268 257 let start, stop = if rev then stop, start else start, stop in 269 - let args = 270 - match take_range ~for_completion start stop pargs with 271 - | `Range args -> args 272 - | `Complete token -> 273 - let kind = Cmdliner_def.Complete.Opt_name_or_pos_value a in 274 - comp_request ~after_dashdash:has_dashdash cline ~token kind 258 + let args = match take_range ~for_completion start stop pargs with 259 + | `Range args -> args 260 + | `Complete token -> 261 + let kind = Cmdliner_def.Complete.Opt_name_or_pos_value a in 262 + comp_request ~after_dashdash:has_dashdash cline ~token kind 275 263 in 276 264 let max_spec = max stop max_spec in 277 - let cline = Cmdliner_def.Arg_info.Map.add a (P args : arg) cline in 265 + let cline = Cmdliner_def.Cline.add a (P args) cline in 278 266 let misses = match Cmdliner_def.Arg_info.is_req a && args = [] with 279 267 | true -> a :: misses 280 268 | false -> misses ··· 329 317 in 330 318 `Error (errs, cline) 331 319 with Completion_requested c -> `Complete c 332 - 333 - (* Deprecations *) 334 - 335 - type deprecated = Cmdliner_def.Arg_info.t * arg 336 - 337 - let deprecated ~env cline = 338 - let add ~env info arg acc = 339 - let deprecation_invoked = match (arg : arg) with 340 - | O [] | P [] -> (* nothing on the cli for the argument *) 341 - begin match Cmdliner_def.Arg_info.env info with 342 - | None -> false 343 - | Some ienv -> 344 - (* the parse uses the env var if defined which may be deprecated *) 345 - Option.is_some (Cmdliner_def.Env.info_deprecated ienv) && 346 - Option.is_some (env (Cmdliner_def.Env.info_var ienv)) 347 - end 348 - | _ -> Option.is_some (Cmdliner_def.Arg_info.deprecated info) 349 - in 350 - if deprecation_invoked then (info, arg) :: acc else acc 351 - in 352 - List.rev (Cmdliner_def.Arg_info.Map.fold (add ~env) cline []) 353 - 354 - let pp_deprecated ~subst ppf (info, arg) = 355 - let open Cmdliner_base in 356 - let plural l = if List.length l > 1 then "s" else "" in 357 - let subst = Cmdliner_def.Arg_info.doclang_subst ~subst info in 358 - match (arg : arg) with 359 - | O [] | P [] -> 360 - let env = Option.get (Cmdliner_def.Arg_info.env info) in 361 - let msg = Cmdliner_def.Env.styled_deprecated ~errs:ppf ~subst env in 362 - Fmt.pf ppf "@[%a @[environment variable %a: %a@]@]" 363 - Fmt.deprecated () Fmt.code (Cmdliner_def.Env.info_var env) 364 - Fmt.styled_text msg 365 - | O os -> 366 - let plural = plural os in 367 - let names = List.map (fun (_, n, _) -> n) os in 368 - let msg = Cmdliner_def.Arg_info.styled_deprecated ~errs:ppf ~subst info in 369 - Fmt.pf ppf "@[%a @[option%s %a: %a@]@]" 370 - Fmt.deprecated () plural Fmt.(list ~sep:sp code_or_quote) names 371 - Fmt.styled_text msg 372 - | P args -> 373 - let plural = plural args in 374 - let msg = 375 - Cmdliner_def.Arg_info.styled_deprecated ~errs:ppf ~subst info 376 - in 377 - Fmt.pf ppf "@[%a @[argument%s %a: %a@]@]" 378 - Fmt.deprecated () plural Fmt.(list ~sep:sp code_or_quote) args 379 - Fmt.styled_text msg
+2 -25
vendor/opam/cmdliner/src/cmdliner_cline.mli
··· 11 11 12 12 (** {1:cli Command lines} *) 13 13 14 - type t = Cmdliner_def.Cline.t 15 - 16 14 val create : 17 15 ?peek_opts:bool -> legacy_prefixes:bool -> for_completion:bool -> 18 16 Cmdliner_def.Arg_info.Set.t -> string list -> 19 - [ `Ok of t 17 + [ `Ok of Cmdliner_def.Cline.t 20 18 | `Complete of Cmdliner_def.Complete.t 21 - | `Error of string * t ] 22 - 23 - val opt_arg : 24 - t -> Cmdliner_def.Arg_info.t -> (int * string * (string option)) list 25 - 26 - val pos_arg : t -> Cmdliner_def.Arg_info.t -> string list 27 - val actual_args : t -> Cmdliner_def.Arg_info.t -> string list 28 - (** Actual command line arguments from the command line *) 29 - 30 - (** {1:deprecations Deprecations} *) 31 - 32 - type deprecated 33 - (** The type for deprecation invocations. This include both environment 34 - variable deprecations and argument deprecations. *) 35 - 36 - val deprecated : env:(string -> string option) -> t -> deprecated list 37 - (** [deprecated ~env cli] are the deprecated invocations that occur 38 - when parsing [cli]. *) 39 - 40 - val pp_deprecated : 41 - subst:Cmdliner_manpage.subst -> deprecated Cmdliner_base.Fmt.t 42 - (** [pp_deprecated] formats deprecations. *) 19 + | `Error of string * Cmdliner_def.Cline.t ]
+1 -1
vendor/opam/cmdliner/src/cmdliner_completion.ml
··· 7 7 8 8 let cons_if b v l = if b then v :: l else l 9 9 10 - type dir = 10 + type directive = 11 11 | Dirs | Files | Group of string * (string * string) list 12 12 | Restart | Message of string 13 13
+69
vendor/opam/cmdliner/src/cmdliner_def.ml
··· 321 321 | P of string list 322 322 323 323 type t = Arg_info.cline 324 + 325 + let empty = Arg_info.Map.empty 326 + let add = Arg_info.Map.add 327 + let fold = Arg_info.Map.fold 328 + let get_arg cline a : arg = 329 + try Arg_info.Map.find a cline with Not_found -> assert false 330 + 331 + let get_opt_arg cline a = 332 + match get_arg cline a with O l -> l | _ -> assert false 333 + 334 + let get_pos_arg cline a = 335 + match get_arg cline a with P l -> l | _ -> assert false 336 + 337 + let actual_args cline a = match get_arg cline a with 338 + | P args -> args 339 + | O l -> 340 + let extract_args (_pos, name, value) = 341 + name :: (match value with None -> [] | Some v -> [v]) 342 + in 343 + List.concat (List.map extract_args l) 344 + 345 + (* Deprecations *) 346 + 347 + type deprecated = Arg_info.t * arg 348 + 349 + let deprecated ~env cline = 350 + let add ~env info arg acc = 351 + let deprecation_invoked = match (arg : arg) with 352 + | O [] | P [] -> (* nothing on the cli for the argument *) 353 + begin match Arg_info.env info with 354 + | None -> false 355 + | Some ienv -> 356 + (* the parse uses the env var if defined which may be 357 + deprecated *) 358 + Option.is_some (Env.info_deprecated ienv) && 359 + Option.is_some (env (Env.info_var ienv)) 360 + end 361 + | _ -> Option.is_some (Arg_info.deprecated info) 362 + in 363 + if deprecation_invoked then (info, arg) :: acc else acc 364 + in 365 + List.rev (fold (add ~env) cline []) 366 + 367 + let pp_deprecated ~subst ppf (info, arg) = 368 + let open Cmdliner_base in 369 + let plural l = if List.length l > 1 then "s" else "" in 370 + let subst = Arg_info.doclang_subst ~subst info in 371 + match (arg : arg) with 372 + | O [] | P [] -> 373 + let env = Option.get (Arg_info.env info) in 374 + let msg = Env.styled_deprecated ~errs:ppf ~subst env in 375 + Fmt.pf ppf "@[%a @[environment variable %a: %a@]@]" 376 + Fmt.deprecated () Fmt.code (Env.info_var env) 377 + Fmt.styled_text msg 378 + | O os -> 379 + let plural = plural os in 380 + let names = List.map (fun (_, n, _) -> n) os in 381 + let msg = Arg_info.styled_deprecated ~errs:ppf ~subst info in 382 + Fmt.pf ppf "@[%a @[option%s %a: %a@]@]" 383 + Fmt.deprecated () plural Fmt.(list ~sep:sp code_or_quote) names 384 + Fmt.styled_text msg 385 + | P args -> 386 + let plural = plural args in 387 + let msg = 388 + Arg_info.styled_deprecated ~errs:ppf ~subst info 389 + in 390 + Fmt.pf ppf "@[%a @[argument%s %a: %a@]@]" 391 + Fmt.deprecated () plural Fmt.(list ~sep:sp code_or_quote) args 392 + Fmt.styled_text msg 324 393 end 325 394 326 395 (* Evaluation *)
+25 -3
vendor/opam/cmdliner/src/cmdliner_def.mli
··· 117 117 val styled_doc : 118 118 errs:Format.formatter -> subst:Cmdliner_manpage.subst -> t -> string 119 119 120 - module Map : Map.S with type key := t 121 - 122 120 type 'a conv 123 121 type e_conv = Conv : 'a conv -> e_conv 124 122 ··· 178 176 | P of string list (** *) 179 177 (** Unconverted argument data as found on the command line. *) 180 178 181 - type t = arg Arg_info.Map.t (* command line, maps arg_infos to arg value. *) 179 + type t (* command line, maps arg_infos to arg value. *) 180 + val empty : t 181 + val add : Arg_info.t -> arg -> t -> t 182 + val get_arg : t -> Arg_info.t -> arg 183 + val get_opt_arg : t -> Arg_info.t -> (int * string * (string option)) list 184 + val get_pos_arg : t -> Arg_info.t -> string list 185 + val actual_args : t -> Arg_info.t -> string list 186 + (** Actual command line arguments from the command line *) 187 + 188 + val fold : (Arg_info.t -> arg -> 'b -> 'b) -> t -> 'b -> 'b 189 + 190 + (** {1:deprecations Deprecations} *) 191 + 192 + type deprecated 193 + (** The type for deprecation invocations. This include both environment 194 + variable deprecations and argument deprecations. *) 195 + 196 + val deprecated : 197 + env:(string -> string option) -> t -> deprecated list 198 + (** [deprecated ~env cli] are the deprecated invocations that occur 199 + when parsing [cli]. *) 200 + 201 + val pp_deprecated : 202 + subst:Cmdliner_manpage.subst -> deprecated Cmdliner_base.Fmt.t 203 + (** [pp_deprecated] formats deprecations. *) 182 204 end 183 205 184 206 (** Evaluation. *)
+7 -8
vendor/opam/cmdliner/src/cmdliner_eval.ml
··· 111 111 112 112 let do_deprecated_msgs ~env err_ppf cl eval = 113 113 let cmd_info = Cmdliner_def.Eval.cmd eval in 114 - let deprecated = Cmdliner_cline.deprecated ~env cl in 114 + let deprecated = Cmdliner_def.Cline.deprecated ~env cl in 115 115 match Cmdliner_def.Cmd_info.deprecated cmd_info, deprecated with 116 116 | None, [] -> () 117 117 | depr_cmd, deprs -> ··· 130 130 Fmt.pf ppf "@[%a command %a:@[ %a@]@]" 131 131 Fmt.deprecated () Fmt.code_or_quote name Fmt.styled_text msg 132 132 in 133 - let pp_deprs = Fmt.list (Cmdliner_cline.pp_deprecated ~subst) in 133 + let pp_deprs = Fmt.list (Cmdliner_def.Cline.pp_deprecated ~subst) in 134 134 Fmt.pf err_ppf "@[%a @[<v>%a%a%a@]@]@." 135 135 Cmdliner_msg.pp_exec_msg eval pp_cmd_msg cmd_info 136 136 pp_sep () pp_deprs deprs ··· 175 175 let kind = "command" in 176 176 let err = Cmdliner_base.err_unknown ~kind ~dom ~hints arg in 177 177 let try_stdopts = 178 - (* When we users writes cmd no_such_cmd --help it's 179 - better to show the unknown command error message 180 - rather than get into the help of the parent 181 - command. Otherwise one gets confused into thinking 182 - the command exists and/or annoyed not be reading 183 - the right man page. *) 178 + (* When one writes [cmd no_such_cmd --help] it's better 179 + to show the unknown command error message rather 180 + than get into the help of the parent command. Otherwise 181 + one gets confused into thinking the command exists and/or 182 + annoyed not to be reading the right man page. *) 184 183 false 185 184 in 186 185 ancestors, current_cmd, args, Error (`Parse (try_stdopts, err))
+1 -1
vendor/opam/cmdliner/src/cmdliner_term.ml
··· 82 82 match v ei cl with 83 83 | Ok x -> 84 84 let actual_args arg_info _ acc = 85 - let args = Cmdliner_cline.actual_args cl arg_info in 85 + let args = Cmdliner_def.Cline.actual_args cl arg_info in 86 86 List.rev_append args acc 87 87 in 88 88 let used =
+1 -1
vendor/opam/cmdliner/src/cmdliner_term.mli
··· 10 10 | `Help of Cmdliner_manpage.format * string option ] 11 11 12 12 type 'a parser = 13 - Cmdliner_def.Eval.t -> Cmdliner_cline.t -> 13 + Cmdliner_def.Eval.t -> Cmdliner_def.Cline.t -> 14 14 ('a, [ `Parse of string | term_escape ]) result 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. *)