···404404completions = version nl directives
405405version = "1"
406406directives = *(directive nl)
407407-directive = group / %s"files" / %s"dirs" / %"restart"
407407+directive = message / group / %s"files" / %s"dirs" / %"restart"
408408+message = %s"message" nl text nl %s"message-end"
408409group = %s"group" nl group_name nl *item
409410group_name = *pchar
410411item = %s"item" nl completion nl item_doc nl %s"item-end"
411412completion = *pchar
412412-item_doc = *(pchar / nl)
413413+item_doc = text
414414+text = *(pchar / nl)
413415nl = %0A
414416pchar = %20-%7E / %8A-%FF
415417]}
···417419The semantics of directives is as follows:
418420419421{ul
420420-{- A [group] directive defines an informational [group_name]
421421- followed by a possibly empty list of completion items that are part of
422422- the group. An item provides a [completion] value followed by an
423423- [item_doc] string which can include ANSI escapes and be made of
424424- multiple lines but cannot have a line made of the literal [item-end]
425425- which is used to signal the end of item.}
422422+{- A [message] directive defines a message to be reported to the user.
423423+ It is multi-line ANSI styled text which cannot have a line that is
424424+ exactly made of the text [message-end] as it is used to signal the
425425+ end of the message. Messages should be reported in the order they
426426+ are received.}
427427+{- A [group] directive defines an informational [group_name] followed
428428+ by a possibly empty list of completion items that are part of the
429429+ group. An item provides a [completion] value, this is a string that
430430+ defines what the requested [ARG] value can be replaced with. It is
431431+ followed by an [item_doc], multi-line ANSI styled text which cannot
432432+ have a line that is exactly made of the text [item-end] as it is
433433+ used to signal the end of the item.}
426434{- A [file] directive indicates that the script should add existing
427435 files staring with [ARG] to completion values.}
428436{- A [dir] directive indicates that the script should add existing
+14-10
vendor/opam/cmdliner/src/cmdliner.mli
···629629 (** Argument completion.
630630631631 This module provides a type to describe how positional and
632632- optional argument values described by {{!Arg.type-conv}argument
632632+ optional argument values of {{!Arg.type-conv}argument
633633 converters} can be completed. It defines which completion
634634 directives from the {{!page-cli.completion_protocol}protocol}
635635 get emitted by your tool for the argument.
636636637637- {b Note.} Subcommand and option name
638638- completion is done automatically by the library itself.
639639- {{!Cmdliner.Arg.predef}Prefined argument converters} already
637637+ {b Note.} Subcommand and option name are completed
638638+ automatically by the library itself and
639639+ {{!Cmdliner.Arg.predef}prefined argument converters} already
640640 have completions built-in whenever appropriate. *)
641641 module Completion : sig
642642···680680 case other completions returned alongside by {!func} are
681681 ignored. Educate your users to use the [--], for example
682682 mention them in {{!page-cookbook.manpage_synopsis}user defined
683683- synopses}. It is good cli specification hygiene anyways as it
684684- properly delineates argument scopes. *)
683683+ synopses}, it is good cli specification hygiene as it properly
684684+ delineates argument scopes. *)
685685+686686+ val message : string -> 'a directive
687687+ (** [message s] is a multi-line, ANSI styled, UTF-8 message reported
688688+ to end users. *)
685689686690 val raw : string -> 'a directive
687691 (** [raw s] takes over the whole {{!page-cli.completion_protocol}protocol}
···701705 Given an optional context determined from a partial command
702706 line parse and a token to complete it returns a list of
703707 completion directives or an error which is reported to
704704- end-users via the protocol. *)
708708+ end-users by using a protocol {!message}. *)
705709706710 type 'a complete =
707711 | Complete : 'ctx Term.t option * ('ctx, 'a) func -> 'a complete (** *)
···719723720724 [context] defines a commmand line fragment that is evaluated
721725 before performing the completion. It the evaluation is
722722- successful the result is given to the completion function otherwise
723723- [None] is given.
726726+ successful the result is given to the completion
727727+ function. Otherwise [None] is given.
724728725729 {b Warning.} [context] must be part of the term of the command
726730 in which you use the completion otherwise the context will
···739743740744 val complete_paths : 'a t
741745 (** [complete_paths] holds a context insensitive function that
742742- always returns [Ok \[]{!files}[;]{!dirs}{[\]]. *)
746746+ always returns [Ok \[]{!files}[;]{!dirs}[\]]. *)
743747744748 val complete_restart : 'a t
745749 (** [complete_dirs] holds a context insensitive function that
+1
vendor/opam/cmdliner/src/cmdliner_arg.mli
···1717 val files : 'a directive
1818 val dirs : 'a directive
1919 val restart : 'a directive
2020+ val message : string -> 'a directive
2021 val raw : string -> 'a directive
21222223 type ('ctx, 'a) func =
+27-24
vendor/opam/cmdliner/src/cmdliner_completion.ml
···88let cons_if b v l = if b then v :: l else l
991010type dir =
1111-[ `Dirs | `Error of string | `Files | `Group of string * (string * string) list
1212-| `Restart ]
1111+| Dirs | Files | Group of string * (string * string) list
1212+| Restart | Message of string
13131414let pp_protocol ppf dirs =
1515 let pp_line ppf s = Cmdliner_base.Fmt.(string ppf s; cut ppf ()) in
1616+ let pp_text ppf s = Cmdliner_base.Fmt.(pf ppf "@[%a@]@," styled_text s) in
1617 let vnum = 1 (* Protocol version number *) in
1718 let pp_item ppf (name, doc) =
1819 pp_line ppf "item";
1919- pp_line ppf name;
2020- Cmdliner_base.Fmt.(pf ppf "@[%a@]@," styled_text doc);
2020+ pp_line ppf name; pp_text ppf doc;
2121 pp_line ppf "item-end";
2222 in
2323 let pp_dir ppf = function
2424- | `Dirs -> pp_line ppf "dirs"
2525- | `Files -> pp_line ppf "files"
2626- | `Error msg -> failwith "TODO"
2727- | `Restart -> pp_line ppf "restart"
2828- | `Group (name, items) ->
2424+ | Dirs -> pp_line ppf "dirs"
2525+ | Files -> pp_line ppf "files"
2626+ | Restart -> pp_line ppf "restart"
2727+ | Group (name, items) ->
2928 pp_line ppf "group";
3029 pp_line ppf name;
3130 Cmdliner_base.Fmt.(list ~sep:nop pp_item) ppf items;
3131+ | Message msg ->
3232+ pp_line ppf "message"; pp_text ppf msg; pp_line ppf "message-end"
3233 in
3334 Cmdliner_base.Fmt.pf ppf "@[<v>%d@,%a@]" vnum
3435 Cmdliner_base.Fmt.(list ~sep:nop pp_dir) dirs
···4445 Some (name, doc)
4546 in
4647 let subcmds = Cmdliner_cmd.get_children_infos cmd in
4747- (`Group ("Subcommands", List.filter_map maybe_item subcmds)) :: directives
4848+ (Group ("Subcommands", List.filter_map maybe_item subcmds)) :: directives
48494950let add_options_group ~err_ppf ~subst cmd comp directives =
5051 let prefix = Cmdliner_def.Complete.prefix comp in
···6566 let set = Cmdliner_def.Cmd_info.args info in
6667 if Cmdliner_def.Arg_info.Set.is_empty set then directives else
6768 let options = Cmdliner_def.Arg_info.Set.elements set in
6868- `Group ("Options", List.concat (List.map maybe_items options)) :: directives
6969+ Group ("Options", List.concat (List.map maybe_items options)) :: directives
69707071let add_argument_value_directives directives comp =
7172 let Directives ds = Cmdliner_def.Complete.directives comp in
7273 match ds with
7373- | Error msg -> `Directives [`Error msg]
7474+ | Error msg -> `Directives [Message msg]
7475 | Ok ds ->
7575- let rec loop values ~files ~dirs ~restart ~raw = function
7676+ let rec loop values msgs ~files ~dirs ~restart ~raw = function
7677 | [] ->
7778 begin match raw with
7879 | Some r -> `Raw r
7980 | None ->
8081 if Cmdliner_def.Complete.after_dashdash comp && restart
8181- then `Directives [`Restart] else
8282+ then `Directives [Restart] else
8283 let dd =
8383- cons_if dirs `Dirs @@
8484- cons_if files `Files @@
8585- cons_if (values <> []) (`Group ("Values", List.rev values)) []
8484+ cons_if dirs Dirs @@
8585+ cons_if files Files @@
8686+ cons_if (values <> []) (Group ("Values", List.rev values)) []
8687 in
8787- `Directives (List.rev_append dd directives)
8888+ `Directives (List.rev_append msgs (List.rev_append dd directives))
8889 end
8990 | d :: ds ->
9091 match d with
9192 | Cmdliner_def.Arg_completion.String (s, doc) ->
9292- loop ((s, doc) :: values) ~files ~dirs ~restart ~raw ds
9393+ loop ((s, doc) :: values) msgs ~files ~dirs ~restart ~raw ds
9394 | Value (_, _) -> failwith "TODO"
9494- | Files -> loop values ~files:true ~dirs ~restart ~raw ds
9595- | Dirs -> loop values ~files ~dirs:true ~restart ~raw ds
9696- | Restart -> loop values ~files ~dirs ~restart:true ~raw ds
9797- | Raw r -> loop values ~files ~dirs ~restart ~raw:(Some r) ds
9595+ | Files -> loop values msgs ~files:true ~dirs ~restart ~raw ds
9696+ | Dirs -> loop values msgs ~files ~dirs:true ~restart ~raw ds
9797+ | Restart -> loop values msgs ~files ~dirs ~restart:true ~raw ds
9898+ | Message msg ->
9999+ loop values (Message msg :: msgs) ~files ~dirs ~restart ~raw ds
100100+ | Raw r -> loop values msgs ~files ~dirs ~restart ~raw:(Some r) ds
98101 in
9999- loop [] ~files:false ~dirs:false ~restart:false ~raw:None ds
102102+ loop [] [] ~files:false ~dirs:false ~restart:false ~raw:None ds
100103101104let output ~out_ppf ~err_ppf ei cmd_args_info cmd comp =
102105 let subst = Cmdliner_def.Eval.doclang_subst ei in
+5-4
vendor/opam/cmdliner/src/cmdliner_def.ml
···203203 | `Help of Cmdliner_manpage.format * string option ]
204204205205 type 'a completion_directive =
206206- | String of string * string | Value of 'a * string | Files | Dirs | Restart
207207- | Raw of string
206206+ | Message of string | String of string * string | Value of 'a * string
207207+ | Files | Dirs | Restart | Raw of string
208208209209 type ('ctx, 'a) completion_func =
210210 'ctx option -> token:string -> ('a completion_directive list, string) result
···356356357357module Arg_completion = struct
358358 type 'a directive = 'a Arg_info.completion_directive =
359359- | String of string * string | Value of 'a * string
359359+ | Message of string | String of string * string | Value of 'a * string
360360 | Files | Dirs | Restart | Raw of string
361361362362 let value ?(doc = "") v = Value (v, doc)
···364364 let files = Files
365365 let dirs = Dirs
366366 let restart = Restart
367367+ let message msg = Message msg
367368 let raw s = Raw s
368369369370 type ('ctx, 'a) func =
···394395395396 let directive_some : 'a directive -> 'a option directive = function
396397 | Value (v, doc) -> Value (Some v, doc)
397397- | (String _ | Files | Dirs | Restart | Raw _ as v) -> v
398398+ | (Message _ | String _ | Files | Dirs | Restart | Raw _ as v) -> v
398399399400 let complete_some (c : 'a t) : 'a option t = match c.complete with
400401 | Complete (ctx, func) ->
+2-1
vendor/opam/cmdliner/src/cmdliner_def.mli
···212212(** Completion strategies *)
213213module Arg_completion : sig
214214 type 'a directive =
215215- | String of string * string | Value of 'a * string
215215+ | Message of string | String of string * string | Value of 'a * string
216216 | Files | Dirs | Restart | Raw of string
217217218218 val value : ?doc:string -> 'a -> 'a directive
···220220 val files : 'a directive
221221 val dirs : 'a directive
222222 val restart : 'a directive
223223+ val message : string -> 'a directive
223224 val raw : string -> 'a directive
224225225226 type ('ctx, 'a) func =
+14-5
vendor/opam/cmdliner/src/tool/bash-completion.sh
···33 local w=("${COMP_WORDS[@]}") # Keep COMP_WORDS intact for restart completion
44 w[COMP_CWORD]="--__complete=${COMP_WORDS[COMP_CWORD]}"
55 local line="${w[@]:0:1} --__complete ${w[@]:1}"
66- local version type group item item_line item_doc
66+ local version type group item text_line item_doc msg
77 {
88 read version
99 if [[ $version != "1" ]]; then
···2121 if [[ $prefix != -* ]]; then
2222 COMPREPLY+=( $(compgen -f "$prefix") )
2323 fi
2424+ elif [[ $type == "message" ]]; then
2525+ msg="";
2626+ while read text_line; do
2727+ if [[ "$text_line" == "message-end" ]]; then
2828+ break
2929+ fi
3030+ msg+=$'\n'"$text_line"
3131+ done
3232+ printf "$msg" >&2
2433 elif [[ $type == "item" ]]; then
2534 read item;
2635 item_doc="";
2727- while read item_line; do
2828- if [[ "$item_line" == "item-end" ]]; then
3636+ while read text_line; do
3737+ if [[ "$text_line" == "item-end" ]]; then
2938 break
3039 fi
3140 if [[ -n "$item_doc" ]]; then
3232- item_doc+=$'\n'"$item_line"
4141+ item_doc+=$'\n'"$text_line"
3342 else
3434- item_doc=$item_line
4343+ item_doc=$text_line
3544 fi
3645 done
3746 # Sadly it seems bash does not support doc strings, so we only
+28-10
vendor/opam/cmdliner/src/tool/cmdliner_data.ml
···44 local w=("${COMP_WORDS[@]}") # Keep COMP_WORDS intact for restart completion
55 w[COMP_CWORD]="--__complete=${COMP_WORDS[COMP_CWORD]}"
66 local line="${w[@]:0:1} --__complete ${w[@]:1}"
77- local version type group item item_line item_doc
77+ local version type group item text_line item_doc msg
88 {
99 read version
1010 if [[ $version != "1" ]]; then
···2222 if [[ $prefix != -* ]]; then
2323 COMPREPLY+=( $(compgen -f "$prefix") )
2424 fi
2525+ elif [[ $type == "message" ]]; then
2626+ msg="";
2727+ while read text_line; do
2828+ if [[ "$text_line" == "message-end" ]]; then
2929+ break
3030+ fi
3131+ msg+=$'\n'"$text_line"
3232+ done
3333+ printf "$msg" >&2
2534 elif [[ $type == "item" ]]; then
2635 read item;
2736 item_doc="";
2828- while read item_line; do
2929- if [[ "$item_line" == "item-end" ]]; then
3737+ while read text_line; do
3838+ if [[ "$text_line" == "item-end" ]]; then
3039 break
3140 fi
3241 if [[ -n "$item_doc" ]]; then
3333- item_doc+=$'\n'"$item_line"
4242+ item_doc+=$'\n'"$text_line"
3443 else
3535- item_doc=$item_line
4444+ item_doc=$text_line
3645 fi
3746 done
3847 # Sadly it seems bash does not support doc strings, so we only
···6877 w[CURRENT]="--__complete=${words[CURRENT]}"
6978 local line="${w[@]:0:1} --__complete ${w[@]:1}"
7079 local -a completions
7171- local version type group item item_line item_doc
8080+ local version type group item text_line item_doc msg
7281 eval $line | {
7382 read -r version
7483 if [[ $version != "1" ]]; then
···8291 completions=()
8392 fi
8493 read -r group
9494+ elif [[ "$type" == "message" ]]; then
9595+ msg="";
9696+ while read text_line; do
9797+ if [[ "$text_line" == "message-end" ]]; then
9898+ break
9999+ fi
100100+ msg+=$'\n'"$text_line"
101101+ done
102102+ _message -r "$msg"
85103 elif [[ "$type" == "item" ]]; then
86104 read -r item;
87105 item_doc="";
8888- while read -r item_line; do
8989- if [[ "$item_line" == "item-end" ]]; then
106106+ while read -r text_line; do
107107+ if [[ "$text_line" == "item-end" ]]; then
90108 break
91109 fi
92110 if [[ -n "$item_doc" ]]; then
93111 # Sadly it seems impossible to make multiline
94112 # doc strings. Get in touch if you know any better.
9595- item_doc+=" $item_line"
113113+ item_doc+=" $text_line"
96114 else
9797- item_doc="$item_line"
115115+ item_doc="$text_line"
98116 fi
99117 done
100118 # Handle glued forms, the completion item is the full option
+14-5
vendor/opam/cmdliner/src/tool/zsh-completion.sh
···44 w[CURRENT]="--__complete=${words[CURRENT]}"
55 local line="${w[@]:0:1} --__complete ${w[@]:1}"
66 local -a completions
77- local version type group item item_line item_doc
77+ local version type group item text_line item_doc msg
88 eval $line | {
99 read -r version
1010 if [[ $version != "1" ]]; then
···1818 completions=()
1919 fi
2020 read -r group
2121+ elif [[ "$type" == "message" ]]; then
2222+ msg="";
2323+ while read text_line; do
2424+ if [[ "$text_line" == "message-end" ]]; then
2525+ break
2626+ fi
2727+ msg+=$'\n'"$text_line"
2828+ done
2929+ _message -r "$msg"
2130 elif [[ "$type" == "item" ]]; then
2231 read -r item;
2332 item_doc="";
2424- while read -r item_line; do
2525- if [[ "$item_line" == "item-end" ]]; then
3333+ while read -r text_line; do
3434+ if [[ "$text_line" == "item-end" ]]; then
2635 break
2736 fi
2837 if [[ -n "$item_doc" ]]; then
2938 # Sadly it seems impossible to make multiline
3039 # doc strings. Get in touch if you know any better.
3131- item_doc+=" $item_line"
4040+ item_doc+=" $text_line"
3241 else
3333- item_doc="$item_line"
4242+ item_doc="$text_line"
3443 fi
3544 done
3645 # Handle glued forms, the completion item is the full option