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 a message directive to the protocol

+121 -67
+16 -8
vendor/opam/cmdliner/doc/cli.mld
··· 404 404 completions = version nl directives 405 405 version = "1" 406 406 directives = *(directive nl) 407 - directive = group / %s"files" / %s"dirs" / %"restart" 407 + directive = message / group / %s"files" / %s"dirs" / %"restart" 408 + message = %s"message" nl text nl %s"message-end" 408 409 group = %s"group" nl group_name nl *item 409 410 group_name = *pchar 410 411 item = %s"item" nl completion nl item_doc nl %s"item-end" 411 412 completion = *pchar 412 - item_doc = *(pchar / nl) 413 + item_doc = text 414 + text = *(pchar / nl) 413 415 nl = %0A 414 416 pchar = %20-%7E / %8A-%FF 415 417 ]} ··· 417 419 The semantics of directives is as follows: 418 420 419 421 {ul 420 - {- A [group] directive defines an informational [group_name] 421 - followed by a possibly empty list of completion items that are part of 422 - the group. An item provides a [completion] value followed by an 423 - [item_doc] string which can include ANSI escapes and be made of 424 - multiple lines but cannot have a line made of the literal [item-end] 425 - which is used to signal the end of item.} 422 + {- A [message] directive defines a message to be reported to the user. 423 + It is multi-line ANSI styled text which cannot have a line that is 424 + exactly made of the text [message-end] as it is used to signal the 425 + end of the message. Messages should be reported in the order they 426 + are received.} 427 + {- A [group] directive defines an informational [group_name] followed 428 + by a possibly empty list of completion items that are part of the 429 + group. An item provides a [completion] value, this is a string that 430 + defines what the requested [ARG] value can be replaced with. It is 431 + followed by an [item_doc], multi-line ANSI styled text which cannot 432 + have a line that is exactly made of the text [item-end] as it is 433 + used to signal the end of the item.} 426 434 {- A [file] directive indicates that the script should add existing 427 435 files staring with [ARG] to completion values.} 428 436 {- A [dir] directive indicates that the script should add existing
+14 -10
vendor/opam/cmdliner/src/cmdliner.mli
··· 629 629 (** Argument completion. 630 630 631 631 This module provides a type to describe how positional and 632 - optional argument values described by {{!Arg.type-conv}argument 632 + optional argument values of {{!Arg.type-conv}argument 633 633 converters} can be completed. It defines which completion 634 634 directives from the {{!page-cli.completion_protocol}protocol} 635 635 get emitted by your tool for the argument. 636 636 637 - {b Note.} Subcommand and option name 638 - completion is done automatically by the library itself. 639 - {{!Cmdliner.Arg.predef}Prefined argument converters} already 637 + {b Note.} Subcommand and option name are completed 638 + automatically by the library itself and 639 + {{!Cmdliner.Arg.predef}prefined argument converters} already 640 640 have completions built-in whenever appropriate. *) 641 641 module Completion : sig 642 642 ··· 680 680 case other completions returned alongside by {!func} are 681 681 ignored. Educate your users to use the [--], for example 682 682 mention them in {{!page-cookbook.manpage_synopsis}user defined 683 - synopses}. It is good cli specification hygiene anyways as it 684 - properly delineates argument scopes. *) 683 + synopses}, it is good cli specification hygiene as it properly 684 + delineates argument scopes. *) 685 + 686 + val message : string -> 'a directive 687 + (** [message s] is a multi-line, ANSI styled, UTF-8 message reported 688 + to end users. *) 685 689 686 690 val raw : string -> 'a directive 687 691 (** [raw s] takes over the whole {{!page-cli.completion_protocol}protocol} ··· 701 705 Given an optional context determined from a partial command 702 706 line parse and a token to complete it returns a list of 703 707 completion directives or an error which is reported to 704 - end-users via the protocol. *) 708 + end-users by using a protocol {!message}. *) 705 709 706 710 type 'a complete = 707 711 | Complete : 'ctx Term.t option * ('ctx, 'a) func -> 'a complete (** *) ··· 719 723 720 724 [context] defines a commmand line fragment that is evaluated 721 725 before performing the completion. It the evaluation is 722 - successful the result is given to the completion function otherwise 723 - [None] is given. 726 + successful the result is given to the completion 727 + function. Otherwise [None] is given. 724 728 725 729 {b Warning.} [context] must be part of the term of the command 726 730 in which you use the completion otherwise the context will ··· 739 743 740 744 val complete_paths : 'a t 741 745 (** [complete_paths] holds a context insensitive function that 742 - always returns [Ok \[]{!files}[;]{!dirs}{[\]]. *) 746 + always returns [Ok \[]{!files}[;]{!dirs}[\]]. *) 743 747 744 748 val complete_restart : 'a t 745 749 (** [complete_dirs] holds a context insensitive function that
+1
vendor/opam/cmdliner/src/cmdliner_arg.mli
··· 17 17 val files : 'a directive 18 18 val dirs : 'a directive 19 19 val restart : 'a directive 20 + val message : string -> 'a directive 20 21 val raw : string -> 'a directive 21 22 22 23 type ('ctx, 'a) func =
+27 -24
vendor/opam/cmdliner/src/cmdliner_completion.ml
··· 8 8 let cons_if b v l = if b then v :: l else l 9 9 10 10 type dir = 11 - [ `Dirs | `Error of string | `Files | `Group of string * (string * string) list 12 - | `Restart ] 11 + | Dirs | Files | Group of string * (string * string) list 12 + | Restart | Message of string 13 13 14 14 let pp_protocol ppf dirs = 15 15 let pp_line ppf s = Cmdliner_base.Fmt.(string ppf s; cut ppf ()) in 16 + let pp_text ppf s = Cmdliner_base.Fmt.(pf ppf "@[%a@]@," styled_text s) in 16 17 let vnum = 1 (* Protocol version number *) in 17 18 let pp_item ppf (name, doc) = 18 19 pp_line ppf "item"; 19 - pp_line ppf name; 20 - Cmdliner_base.Fmt.(pf ppf "@[%a@]@," styled_text doc); 20 + pp_line ppf name; pp_text ppf doc; 21 21 pp_line ppf "item-end"; 22 22 in 23 23 let pp_dir ppf = function 24 - | `Dirs -> pp_line ppf "dirs" 25 - | `Files -> pp_line ppf "files" 26 - | `Error msg -> failwith "TODO" 27 - | `Restart -> pp_line ppf "restart" 28 - | `Group (name, items) -> 24 + | Dirs -> pp_line ppf "dirs" 25 + | Files -> pp_line ppf "files" 26 + | Restart -> pp_line ppf "restart" 27 + | Group (name, items) -> 29 28 pp_line ppf "group"; 30 29 pp_line ppf name; 31 30 Cmdliner_base.Fmt.(list ~sep:nop pp_item) ppf items; 31 + | Message msg -> 32 + pp_line ppf "message"; pp_text ppf msg; pp_line ppf "message-end" 32 33 in 33 34 Cmdliner_base.Fmt.pf ppf "@[<v>%d@,%a@]" vnum 34 35 Cmdliner_base.Fmt.(list ~sep:nop pp_dir) dirs ··· 44 45 Some (name, doc) 45 46 in 46 47 let subcmds = Cmdliner_cmd.get_children_infos cmd in 47 - (`Group ("Subcommands", List.filter_map maybe_item subcmds)) :: directives 48 + (Group ("Subcommands", List.filter_map maybe_item subcmds)) :: directives 48 49 49 50 let add_options_group ~err_ppf ~subst cmd comp directives = 50 51 let prefix = Cmdliner_def.Complete.prefix comp in ··· 65 66 let set = Cmdliner_def.Cmd_info.args info in 66 67 if Cmdliner_def.Arg_info.Set.is_empty set then directives else 67 68 let options = Cmdliner_def.Arg_info.Set.elements set in 68 - `Group ("Options", List.concat (List.map maybe_items options)) :: directives 69 + Group ("Options", List.concat (List.map maybe_items options)) :: directives 69 70 70 71 let add_argument_value_directives directives comp = 71 72 let Directives ds = Cmdliner_def.Complete.directives comp in 72 73 match ds with 73 - | Error msg -> `Directives [`Error msg] 74 + | Error msg -> `Directives [Message msg] 74 75 | Ok ds -> 75 - let rec loop values ~files ~dirs ~restart ~raw = function 76 + let rec loop values msgs ~files ~dirs ~restart ~raw = function 76 77 | [] -> 77 78 begin match raw with 78 79 | Some r -> `Raw r 79 80 | None -> 80 81 if Cmdliner_def.Complete.after_dashdash comp && restart 81 - then `Directives [`Restart] else 82 + then `Directives [Restart] else 82 83 let dd = 83 - cons_if dirs `Dirs @@ 84 - cons_if files `Files @@ 85 - cons_if (values <> []) (`Group ("Values", List.rev values)) [] 84 + cons_if dirs Dirs @@ 85 + cons_if files Files @@ 86 + cons_if (values <> []) (Group ("Values", List.rev values)) [] 86 87 in 87 - `Directives (List.rev_append dd directives) 88 + `Directives (List.rev_append msgs (List.rev_append dd directives)) 88 89 end 89 90 | d :: ds -> 90 91 match d with 91 92 | Cmdliner_def.Arg_completion.String (s, doc) -> 92 - loop ((s, doc) :: values) ~files ~dirs ~restart ~raw ds 93 + loop ((s, doc) :: values) msgs ~files ~dirs ~restart ~raw ds 93 94 | Value (_, _) -> failwith "TODO" 94 - | Files -> loop values ~files:true ~dirs ~restart ~raw ds 95 - | Dirs -> loop values ~files ~dirs:true ~restart ~raw ds 96 - | Restart -> loop values ~files ~dirs ~restart:true ~raw ds 97 - | Raw r -> loop values ~files ~dirs ~restart ~raw:(Some r) ds 95 + | Files -> loop values msgs ~files:true ~dirs ~restart ~raw ds 96 + | Dirs -> loop values msgs ~files ~dirs:true ~restart ~raw ds 97 + | Restart -> loop values msgs ~files ~dirs ~restart:true ~raw ds 98 + | Message msg -> 99 + loop values (Message msg :: msgs) ~files ~dirs ~restart ~raw ds 100 + | Raw r -> loop values msgs ~files ~dirs ~restart ~raw:(Some r) ds 98 101 in 99 - loop [] ~files:false ~dirs:false ~restart:false ~raw:None ds 102 + loop [] [] ~files:false ~dirs:false ~restart:false ~raw:None ds 100 103 101 104 let output ~out_ppf ~err_ppf ei cmd_args_info cmd comp = 102 105 let subst = Cmdliner_def.Eval.doclang_subst ei in
+5 -4
vendor/opam/cmdliner/src/cmdliner_def.ml
··· 203 203 | `Help of Cmdliner_manpage.format * string option ] 204 204 205 205 type 'a completion_directive = 206 - | String of string * string | Value of 'a * string | Files | Dirs | Restart 207 - | Raw of string 206 + | Message of string | String of string * string | Value of 'a * string 207 + | Files | Dirs | Restart | Raw of string 208 208 209 209 type ('ctx, 'a) completion_func = 210 210 'ctx option -> token:string -> ('a completion_directive list, string) result ··· 356 356 357 357 module Arg_completion = struct 358 358 type 'a directive = 'a Arg_info.completion_directive = 359 - | String of string * string | Value of 'a * string 359 + | Message of string | String of string * string | Value of 'a * string 360 360 | Files | Dirs | Restart | Raw of string 361 361 362 362 let value ?(doc = "") v = Value (v, doc) ··· 364 364 let files = Files 365 365 let dirs = Dirs 366 366 let restart = Restart 367 + let message msg = Message msg 367 368 let raw s = Raw s 368 369 369 370 type ('ctx, 'a) func = ··· 394 395 395 396 let directive_some : 'a directive -> 'a option directive = function 396 397 | Value (v, doc) -> Value (Some v, doc) 397 - | (String _ | Files | Dirs | Restart | Raw _ as v) -> v 398 + | (Message _ | String _ | Files | Dirs | Restart | Raw _ as v) -> v 398 399 399 400 let complete_some (c : 'a t) : 'a option t = match c.complete with 400 401 | Complete (ctx, func) ->
+2 -1
vendor/opam/cmdliner/src/cmdliner_def.mli
··· 212 212 (** Completion strategies *) 213 213 module Arg_completion : sig 214 214 type 'a directive = 215 - | String of string * string | Value of 'a * string 215 + | Message of string | String of string * string | Value of 'a * string 216 216 | Files | Dirs | Restart | Raw of string 217 217 218 218 val value : ?doc:string -> 'a -> 'a directive ··· 220 220 val files : 'a directive 221 221 val dirs : 'a directive 222 222 val restart : 'a directive 223 + val message : string -> 'a directive 223 224 val raw : string -> 'a directive 224 225 225 226 type ('ctx, 'a) func =
+14 -5
vendor/opam/cmdliner/src/tool/bash-completion.sh
··· 3 3 local w=("${COMP_WORDS[@]}") # Keep COMP_WORDS intact for restart completion 4 4 w[COMP_CWORD]="--__complete=${COMP_WORDS[COMP_CWORD]}" 5 5 local line="${w[@]:0:1} --__complete ${w[@]:1}" 6 - local version type group item item_line item_doc 6 + local version type group item text_line item_doc msg 7 7 { 8 8 read version 9 9 if [[ $version != "1" ]]; then ··· 21 21 if [[ $prefix != -* ]]; then 22 22 COMPREPLY+=( $(compgen -f "$prefix") ) 23 23 fi 24 + elif [[ $type == "message" ]]; then 25 + msg=""; 26 + while read text_line; do 27 + if [[ "$text_line" == "message-end" ]]; then 28 + break 29 + fi 30 + msg+=$'\n'"$text_line" 31 + done 32 + printf "$msg" >&2 24 33 elif [[ $type == "item" ]]; then 25 34 read item; 26 35 item_doc=""; 27 - while read item_line; do 28 - if [[ "$item_line" == "item-end" ]]; then 36 + while read text_line; do 37 + if [[ "$text_line" == "item-end" ]]; then 29 38 break 30 39 fi 31 40 if [[ -n "$item_doc" ]]; then 32 - item_doc+=$'\n'"$item_line" 41 + item_doc+=$'\n'"$text_line" 33 42 else 34 - item_doc=$item_line 43 + item_doc=$text_line 35 44 fi 36 45 done 37 46 # Sadly it seems bash does not support doc strings, so we only
+28 -10
vendor/opam/cmdliner/src/tool/cmdliner_data.ml
··· 4 4 local w=("${COMP_WORDS[@]}") # Keep COMP_WORDS intact for restart completion 5 5 w[COMP_CWORD]="--__complete=${COMP_WORDS[COMP_CWORD]}" 6 6 local line="${w[@]:0:1} --__complete ${w[@]:1}" 7 - local version type group item item_line item_doc 7 + local version type group item text_line item_doc msg 8 8 { 9 9 read version 10 10 if [[ $version != "1" ]]; then ··· 22 22 if [[ $prefix != -* ]]; then 23 23 COMPREPLY+=( $(compgen -f "$prefix") ) 24 24 fi 25 + elif [[ $type == "message" ]]; then 26 + msg=""; 27 + while read text_line; do 28 + if [[ "$text_line" == "message-end" ]]; then 29 + break 30 + fi 31 + msg+=$'\n'"$text_line" 32 + done 33 + printf "$msg" >&2 25 34 elif [[ $type == "item" ]]; then 26 35 read item; 27 36 item_doc=""; 28 - while read item_line; do 29 - if [[ "$item_line" == "item-end" ]]; then 37 + while read text_line; do 38 + if [[ "$text_line" == "item-end" ]]; then 30 39 break 31 40 fi 32 41 if [[ -n "$item_doc" ]]; then 33 - item_doc+=$'\n'"$item_line" 42 + item_doc+=$'\n'"$text_line" 34 43 else 35 - item_doc=$item_line 44 + item_doc=$text_line 36 45 fi 37 46 done 38 47 # Sadly it seems bash does not support doc strings, so we only ··· 68 77 w[CURRENT]="--__complete=${words[CURRENT]}" 69 78 local line="${w[@]:0:1} --__complete ${w[@]:1}" 70 79 local -a completions 71 - local version type group item item_line item_doc 80 + local version type group item text_line item_doc msg 72 81 eval $line | { 73 82 read -r version 74 83 if [[ $version != "1" ]]; then ··· 82 91 completions=() 83 92 fi 84 93 read -r group 94 + elif [[ "$type" == "message" ]]; then 95 + msg=""; 96 + while read text_line; do 97 + if [[ "$text_line" == "message-end" ]]; then 98 + break 99 + fi 100 + msg+=$'\n'"$text_line" 101 + done 102 + _message -r "$msg" 85 103 elif [[ "$type" == "item" ]]; then 86 104 read -r item; 87 105 item_doc=""; 88 - while read -r item_line; do 89 - if [[ "$item_line" == "item-end" ]]; then 106 + while read -r text_line; do 107 + if [[ "$text_line" == "item-end" ]]; then 90 108 break 91 109 fi 92 110 if [[ -n "$item_doc" ]]; then 93 111 # Sadly it seems impossible to make multiline 94 112 # doc strings. Get in touch if you know any better. 95 - item_doc+=" $item_line" 113 + item_doc+=" $text_line" 96 114 else 97 - item_doc="$item_line" 115 + item_doc="$text_line" 98 116 fi 99 117 done 100 118 # Handle glued forms, the completion item is the full option
+14 -5
vendor/opam/cmdliner/src/tool/zsh-completion.sh
··· 4 4 w[CURRENT]="--__complete=${words[CURRENT]}" 5 5 local line="${w[@]:0:1} --__complete ${w[@]:1}" 6 6 local -a completions 7 - local version type group item item_line item_doc 7 + local version type group item text_line item_doc msg 8 8 eval $line | { 9 9 read -r version 10 10 if [[ $version != "1" ]]; then ··· 18 18 completions=() 19 19 fi 20 20 read -r group 21 + elif [[ "$type" == "message" ]]; then 22 + msg=""; 23 + while read text_line; do 24 + if [[ "$text_line" == "message-end" ]]; then 25 + break 26 + fi 27 + msg+=$'\n'"$text_line" 28 + done 29 + _message -r "$msg" 21 30 elif [[ "$type" == "item" ]]; then 22 31 read -r item; 23 32 item_doc=""; 24 - while read -r item_line; do 25 - if [[ "$item_line" == "item-end" ]]; then 33 + while read -r text_line; do 34 + if [[ "$text_line" == "item-end" ]]; then 26 35 break 27 36 fi 28 37 if [[ -n "$item_doc" ]]; then 29 38 # Sadly it seems impossible to make multiline 30 39 # doc strings. Get in touch if you know any better. 31 - item_doc+=" $item_line" 40 + item_doc+=" $text_line" 32 41 else 33 - item_doc="$item_line" 42 + item_doc="$text_line" 34 43 fi 35 44 done 36 45 # Handle glued forms, the completion item is the full option