diff options
41 files changed, 175 insertions, 519 deletions
@@ -41,24 +41,25 @@ let test_with_used_args = test "test_with_used_args" let default = let meta = - let open B0_meta in - empty - |> add authors ["The cmdliner programmers"] - |> add maintainers ["Daniel Bünzli <daniel.buenzl i@erratique.ch>"] - |> add homepage "https://erratique.ch/software/cmdliner" - |> add online_doc "https://erratique.ch/software/cmdliner/doc" - |> add issues "https://github.com/dbuenzli/cmdliner/issues" - |> add repo "git+https://erratique.ch/repos/cmdliner.git" - |> add licenses ["ISC"] - |> add description_tags ["cli"; "system"; "declarative"; "org:erratique"] - |> tag B0_opam.tag - |> add B0_opam.Meta.depends + B0_meta.empty + |> B0_meta.(add authors) ["The cmdliner programmers"] + |> B0_meta.(add maintainers) + ["Daniel Bünzli <daniel.buenzl i@erratique.ch>"] + |> B0_meta.(add homepage) "https://erratique.ch/software/cmdliner" + |> B0_meta.(add online_doc) "https://erratique.ch/software/cmdliner/doc" + |> B0_meta.(add issues) "https://github.com/dbuenzli/cmdliner/issues" + |> B0_meta.(add repo) "git+https://erratique.ch/repos/cmdliner.git" + |> B0_meta.(add licenses) ["ISC"] + |> B0_meta.(add description_tags) + ["cli"; "system"; "declarative"; "org:erratique"] + |> B0_meta.tag B0_opam.tag + |> B0_meta.add B0_opam.depends [ "ocaml", {|>= "4.08.0"|}; ] - |> add B0_opam.Meta.build + |> B0_meta.add B0_opam.build {|[[ make "all" "PREFIX=%{prefix}%" ]]|} - |> add B0_opam.Meta.install + |> B0_meta.add B0_opam.install {|[[make "install" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"] [make "install-doc" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"]]|} in - B0_pack.v "default" ~doc:"cmdliner package" ~meta ~locked:true @@ + B0_pack.make "default" ~doc:"cmdliner package" ~meta ~locked:true @@ B0_unit.list () @@ -1,3 +1,17 @@ +v1.3.0 2024-05-23 La Forclaz (VS) +--------------------------------- + +- Add let operators in `Cmdliner.Term.Syntax` (#173). Thanks to Benoit + Montagu for suggesting, Gabriel Scherer for reminding us of language + punning obscurities and Sebastien Mondet for strengthening the case + to add them. +- Pager. Support full path command lookups on Windows. + (#185). Thanks to @kit-ty-kate for the report. +- In manpage specifications use `$(iname)` in the default + introduction of the `ENVIRONMENT` section. Follow up to + #168. +- Add `Cmd.eval_value'` a variation on `Cmd.eval_value`. + v1.2.0 2023-04-10 La Forclaz (VS) --------------------------------- @@ -1,6 +1,6 @@ Cmdliner — Declarative definition of command line interfaces for OCaml ------------------------------------------------------------------------------- -v1.2.0 +v1.3.0 Cmdliner allows the declarative definition of command line interfaces for OCaml. diff --git a/cmdliner.opam b/cmdliner.opam index f8e67f8..d41fb5c 100644 --- a/cmdliner.opam +++ b/cmdliner.opam @@ -1,20 +1,8 @@ -version: "1.2.0" +version: "1.3.0" opam-version: "2.0" name: "cmdliner" -synopsis: """Declarative definition of command line interfaces for OCaml""" -maintainer: ["Daniel Bünzli <daniel.buenzl i@erratique.ch>"] -authors: ["The cmdliner programmers"] -homepage: "https://erratique.ch/software/cmdliner" -doc: "https://erratique.ch/software/cmdliner/doc" -dev-repo: "git+https://erratique.ch/repos/cmdliner.git" -bug-reports: "https://github.com/dbuenzli/cmdliner/issues" -license: ["ISC"] -tags: ["cli" "system" "declarative" "org:erratique"] -depends: ["ocaml" {>= "4.08.0"}] -build: [[ make "all" "PREFIX=%{prefix}%" ]] -install: [[make "install" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"] - [make "install-doc" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"]] -description: """ +synopsis: "Declarative definition of command line interfaces for OCaml" +description: """\ Cmdliner allows the declarative definition of command line interfaces for OCaml. @@ -30,3 +18,19 @@ Cmdliner has no dependencies and is distributed under the ISC license. [2]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html Home page: http://erratique.ch/software/cmdliner""" +maintainer: "Daniel Bünzli <daniel.buenzl i@erratique.ch>" +authors: "The cmdliner programmers" +license: "ISC" +tags: ["cli" "system" "declarative" "org:erratique"] +homepage: "https://erratique.ch/software/cmdliner" +doc: "https://erratique.ch/software/cmdliner/doc" +bug-reports: "https://github.com/dbuenzli/cmdliner/issues" +depends: [ + "ocaml" {>= "4.08.0"} +] +build: [make "all" "PREFIX=%{prefix}%"] +install: [ + [make "install" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"] + [make "install-doc" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"] +] +dev-repo: "git+https://erratique.ch/repos/cmdliner.git" diff --git a/debian/changelog b/debian/changelog index 89c7211..aaa2e69 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cmdliner (1.3.0-1) unstable; urgency=medium + + * New upstream release + + -- Stéphane Glondu <glondu@debian.org> Mon, 03 Jun 2024 10:27:11 +0200 + cmdliner (1.2.0-2) unstable; urgency=medium * Depend on ocaml instead of transitional ocaml-nox diff --git a/doc/examples.mld b/doc/examples.mld index 8ac8821..a437b9c 100644 --- a/doc/examples.mld +++ b/doc/examples.mld @@ -79,7 +79,7 @@ let cmd = `S Manpage.s_bugs; `P "Report bugs to <bugs@example.org>."; `S Manpage.s_see_also; `P "$(b,rmdir)(1), $(b,unlink)(2)" ] in - let info = Cmd.info "rm" ~version:"v1.2.0" ~doc ~man in + let info = Cmd.info "rm" ~version:"v1.3.0" ~doc ~man in Cmd.v info Term.(const rm $ prompt $ recursive $ files) let main () = exit (Cmd.eval cmd) @@ -149,7 +149,7 @@ let cmd = [ `S Manpage.s_bugs; `P "Email them to <bugs@example.org>."; ] in - let info = Cmd.info "cp" ~version:"v1.2.0" ~doc ~man ~man_xrefs in + let info = Cmd.info "cp" ~version:"v1.3.0" ~doc ~man ~man_xrefs in Cmd.v info Term.(ret (const cp $ verbose $ recurse $ force $ srcs $ dest)) @@ -258,7 +258,7 @@ let cmd = `S Manpage.s_see_also; `P "$(b,cat)(1), $(b,head)(1)" ] in - let info = Cmd.info "tail" ~version:"v1.2.0" ~doc ~man in + let info = Cmd.info "tail" ~version:"v1.3.0" ~doc ~man in Cmd.v info Term.(const tail $ lines $ follow $ verb $ pid $ files) @@ -435,7 +435,7 @@ let help_cmd = let main_cmd = let doc = "a revision control system" in let man = help_secs in - let info = Cmd.info "darcs" ~version:"v1.2.0" ~doc ~sdocs ~man in + let info = Cmd.info "darcs" ~version:"v1.3.0" ~doc ~sdocs ~man in let default = Term.(ret (const (fun _ -> `Help (`Pager, None)) $ copts_t)) in Cmd.group info ~default [initialize_cmd; record_cmd; help_cmd] diff --git a/doc/index.mld b/doc/index.mld index 962dd49..db93924 100644 --- a/doc/index.mld +++ b/doc/index.mld @@ -1,4 +1,4 @@ -{0 Cmdliner {%html: <span class="version">v1.2.0</span>%}} +{0 Cmdliner {%html: <span class="version">v1.3.0</span>%}} [Cmdliner] provides a simple and compositional mechanism to convert command line arguments to OCaml values and pass them to @@ -1,7 +1,8 @@ -version = "v1.2.0" -description = "Declarative definition of command line interfaces" +description = "Declarative definition of command line interfaces for OCaml" +version = "1.3.0" requires = "" archive(byte) = "cmdliner.cma" archive(native) = "cmdliner.cmxa" plugin(byte) = "cmdliner.cma" -plugin(native) = "cmdliner.cmxs"
\ No newline at end of file +plugin(native) = "cmdliner.cmxs" +exists_if = "cmdliner.cma cmdliner.cmxa" diff --git a/src/cmdliner.ml b/src/cmdliner.ml index b5b1f11..338e987 100644 --- a/src/cmdliner.ml +++ b/src/cmdliner.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) module Manpage = Cmdliner_manpage @@ -15,19 +15,3 @@ module Cmd = struct include Cmdliner_eval end module Arg = Cmdliner_arg - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner.mli b/src/cmdliner.mli index 1932d9c..7e886cd 100644 --- a/src/cmdliner.mli +++ b/src/cmdliner.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Declarative definition of command line interfaces. @@ -184,6 +184,21 @@ module Term : sig val app : ('a -> 'b) t -> 'a t -> 'b t (** [app] is {!($)}. *) + val map : ('a -> 'b) -> 'a t -> 'b t + (** [map f t] is [app (const f) t]. *) + + val product : 'a t -> 'b t -> ('a * 'b) t + (** [product t0 t1] is [app (app (map (fun x y -> (x, y)) t0) t1)] *) + + (** [let] operators. *) + module Syntax : sig + val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t + (** [( let+ )] is {!map}. *) + + val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t + (** [( and* )] is {!product}. *) + end + (** {1 Interacting with Cmdliner's evaluation} *) val term_result : ?usage:bool -> ('a, [`Msg of string]) result t -> 'a t @@ -726,6 +741,10 @@ module Cmd : sig | `Exn (** An uncaught exception occurred. *) ] (** The type for erroring evaluation results. *) + type 'a eval_exit = + [ `Ok of 'a (** The term of the command evaluated to this value. *) + | `Exit of Exit.code (** The evaluation wants to exit with this code. *) ] + val eval_value : ?help:Format.formatter -> ?err:Format.formatter -> ?catch:bool -> ?env:(string -> string option) -> ?argv:string array -> 'a t -> @@ -744,6 +763,15 @@ module Cmd : sig {- [err] is the formatter used to print error messages (defaults to {!Format.err_formatter}).}} *) + val eval_value' : + ?help:Format.formatter -> ?err:Format.formatter -> ?catch:bool -> + ?env:(string -> string option) -> ?argv:string array -> ?term_err:int -> + 'a t -> 'a eval_exit + (** [eval_value'] is like {!eval_value}, but if the command term + does not evaluate, returns an exit code like the + {{!eval}evaluation} function do (which can be {!Exit.ok} in case + help or version was requested). *) + val eval_peek_opts : ?version_opt:bool -> ?env:(string -> string option) -> ?argv:string array -> 'a Term.t -> @@ -1160,20 +1188,3 @@ module Arg : sig [@@ocaml.deprecated "Use Cmd.Env.info instead."] (** See {!Cmd.Env.val-info}. *) end - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_arg.ml b/src/cmdliner_arg.ml index 56d1fb6..c6ae9e9 100644 --- a/src/cmdliner_arg.ml +++ b/src/cmdliner_arg.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) let rev_compare n0 n1 = compare n1 n0 @@ -359,19 +359,3 @@ let pair = Cmdliner_base.pair let t2 = Cmdliner_base.t2 let t3 = Cmdliner_base.t3 let t4 = Cmdliner_base.t4 - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_arg.mli b/src/cmdliner_arg.mli index e3faa2f..1166b13 100644 --- a/src/cmdliner_arg.mli +++ b/src/cmdliner_arg.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Command line arguments as terms. *) @@ -96,20 +96,3 @@ val t4 : val doc_quote : string -> string val doc_alts : ?quoted:bool -> string list -> string val doc_alts_enum : ?quoted:bool -> (string * 'a) list -> string - - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_base.ml b/src/cmdliner_base.ml index c1a4d21..f1c659c 100644 --- a/src/cmdliner_base.ml +++ b/src/cmdliner_base.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) let strf = Printf.sprintf @@ -339,19 +339,3 @@ let env_bool_parse s = match String.lowercase_ascii s with | s -> let alts = alts_str ~quoted:true ["true"; "yes"; "false"; "no" ] in `Error (err_invalid_val s alts) - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_base.mli b/src/cmdliner_base.mli index 2c3f3d9..3b12e73 100644 --- a/src/cmdliner_base.mli +++ b/src/cmdliner_base.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** A few helpful base definitions. *) @@ -58,19 +58,3 @@ val t4 : ('a * 'b * 'c * 'd) conv val env_bool_parse : bool parser - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_cline.ml b/src/cmdliner_cline.ml index 5bff9d8..cc81702 100644 --- a/src/cmdliner_cline.ml +++ b/src/cmdliner_cline.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (* A command line stores pre-parsed information about the command @@ -201,19 +201,3 @@ let deprecated_msgs cl = String.concat "" msg :: acc in Amap.fold add cl [] - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_cline.mli b/src/cmdliner_cline.mli index 5651bda..f9075b0 100644 --- a/src/cmdliner_cline.mli +++ b/src/cmdliner_cline.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Command lines. *) @@ -18,19 +18,3 @@ val actual_args : t -> Cmdliner_info.Arg.t -> string list val is_opt : string -> bool val deprecated_msgs : t -> string list - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_cmd.ml b/src/cmdliner_cmd.ml index 5a156f3..0cff096 100644 --- a/src/cmdliner_cmd.ml +++ b/src/cmdliner_cmd.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2022 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (* Commands *) @@ -28,19 +28,3 @@ let group ?default i cmds = Group (i, (parser, cmds)) let name c = Cmdliner_info.Cmd.name (get_info c) - -(*--------------------------------------------------------------------------- - Copyright (c) 2022 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_cmd.mli b/src/cmdliner_cmd.mli index 54da153..f2e3062 100644 --- a/src/cmdliner_cmd.mli +++ b/src/cmdliner_cmd.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2022 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Commands and their information. *) @@ -22,19 +22,3 @@ val v : info -> 'a Cmdliner_term.t -> 'a t val group : ?default:'a Cmdliner_term.t -> info -> 'a t list -> 'a t val name : 'a t -> string val get_info : 'a t -> info - -(*--------------------------------------------------------------------------- - Copyright (c) 2022 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_docgen.ml b/src/cmdliner_docgen.ml index 8e40497..3a36df5 100644 --- a/src/cmdliner_docgen.ml +++ b/src/cmdliner_docgen.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) let rev_compare n0 n1 = compare n1 n0 @@ -393,19 +393,3 @@ let pp_plain_synopsis ~errs ppf ei = let synopsis = synopsis ~parents cmd in let syn = Cmdliner_manpage.doc_to_plain ~errs ~subst buf synopsis in Format.fprintf ppf "@[%s@]" syn - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_docgen.mli b/src/cmdliner_docgen.mli index 826bfac..e57929d 100644 --- a/src/cmdliner_docgen.mli +++ b/src/cmdliner_docgen.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) val pp_man : @@ -9,19 +9,3 @@ val pp_man : val pp_plain_synopsis : errs:Format.formatter -> Format.formatter -> Cmdliner_info.Eval.t -> unit - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_eval.ml b/src/cmdliner_eval.ml index c3747bf..e4b50be 100644 --- a/src/cmdliner_eval.ml +++ b/src/cmdliner_eval.ml @@ -1,10 +1,11 @@ (*--------------------------------------------------------------------------- Copyright (c) 2022 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) type 'a eval_ok = [ `Ok of 'a | `Version | `Help ] type eval_error = [ `Parse | `Term | `Exn ] +type 'a eval_exit = [ `Ok of 'a | `Exit of Cmdliner_info.Exit.code ] let err_help s = "Term error, help requested for unknown command " ^ s let err_argv = "argv array must have at least one element" @@ -247,6 +248,11 @@ let exit_status_of_result ?(term_err = Cmdliner_info.Exit.cli_error) = function | Error `Parse -> Cmdliner_info.Exit.cli_error | Error `Exn -> Cmdliner_info.Exit.internal_error +let eval_value' ?help ?err ?catch ?env ?argv ?term_err cmd = + match eval_value ?help ?err ?catch ?env ?argv cmd with + | Ok (`Ok _ as v) -> v + | ret -> `Exit (exit_status_of_result ?term_err ret) + let eval ?help ?err ?catch ?env ?argv ?term_err cmd = exit_status_of_result ?term_err @@ eval_value ?help ?err ?catch ?env ?argv cmd @@ -274,19 +280,3 @@ let eval_result' | Ok (`Ok (Ok c)) -> c | Ok (`Ok (Error msg)) -> pp_err err cmd ~msg; Cmdliner_info.Exit.some_error | r -> exit_status_of_result ?term_err r - -(*--------------------------------------------------------------------------- - Copyright (c) 2022 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_eval.mli b/src/cmdliner_eval.mli index 18746d9..27194b8 100644 --- a/src/cmdliner_eval.mli +++ b/src/cmdliner_eval.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2022 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Command evaluation *) @@ -9,12 +9,18 @@ type 'a eval_ok = [ `Ok of 'a | `Version | `Help ] type eval_error = [ `Parse | `Term | `Exn ] +type 'a eval_exit = [ `Ok of 'a | `Exit of Cmdliner_info.Exit.code ] val eval_value : ?help:Format.formatter -> ?err:Format.formatter -> ?catch:bool -> ?env:(string -> string option) -> ?argv:string array -> 'a Cmdliner_cmd.t -> ('a eval_ok, eval_error) result +val eval_value' : + ?help:Format.formatter -> ?err:Format.formatter -> ?catch:bool -> + ?env:(string -> string option) -> ?argv:string array -> + ?term_err:int -> 'a Cmdliner_cmd.t -> 'a eval_exit + val eval_peek_opts : ?version_opt:bool -> ?env:(string -> string option) -> ?argv:string array -> 'a Cmdliner_term.t -> @@ -42,19 +48,3 @@ val eval_result' : ?term_err:Cmdliner_info.Exit.code -> (Cmdliner_info.Exit.code, string) result Cmdliner_cmd.t -> Cmdliner_info.Exit.code - -(*--------------------------------------------------------------------------- - Copyright (c) 2022 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_exit.ml b/src/cmdliner_exit.ml index 5a9fe79..2231518 100644 --- a/src/cmdliner_exit.ml +++ b/src/cmdliner_exit.ml @@ -1,21 +1,4 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_exit.mli b/src/cmdliner_exit.mli index 5a9fe79..2231518 100644 --- a/src/cmdliner_exit.mli +++ b/src/cmdliner_exit.mli @@ -1,21 +1,4 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_info.ml b/src/cmdliner_info.ml index d516fc1..561a60e 100644 --- a/src/cmdliner_info.ml +++ b/src/cmdliner_info.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (* Exit codes *) @@ -223,19 +223,3 @@ module Eval = struct let main e = match List.rev e.parents with [] -> e.cmd | m :: _ -> m let with_cmd ei cmd = { ei with cmd } end - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_info.mli b/src/cmdliner_info.mli index 2ded9dc..76ea15b 100644 --- a/src/cmdliner_info.mli +++ b/src/cmdliner_info.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Exit codes, environment variables, arguments, commands and eval information. @@ -137,19 +137,3 @@ module Eval : sig val err_ppf : t -> Format.formatter val with_cmd : t -> Cmd.t -> t end - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_manpage.ml b/src/cmdliner_manpage.ml index 941220a..63c12b2 100644 --- a/src/cmdliner_manpage.ml +++ b/src/cmdliner_manpage.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (* Manpages *) @@ -30,7 +30,7 @@ let s_exit_status_intro = `P "$(iname) exits with:" let s_environment = "ENVIRONMENT" let s_environment_intro = - `P "These environment variables affect the execution of $(tname):" + `P "These environment variables affect the execution of $(iname):" let s_files = "FILES" let s_examples = "EXAMPLES" @@ -444,12 +444,17 @@ let tmp_file_for_pager () = with Sys_error _ -> None let find_cmd cmds = - let test, null = match Sys.os_type with - | "Win32" -> "where", " NUL" - | _ -> "command -v", "/dev/null" + let find_win32 (cmd, _args) = + (* `where` does not support full path lookups *) + if String.equal (Filename.basename cmd) cmd + then (Sys.command (strf "where %s 1> NUL 2> NUL" cmd) = 0) + else Sys.file_exists cmd in - let cmd (c, _) = Sys.command (strf "%s %s 1>%s 2>%s" test c null null) = 0 in - try Some (List.find cmd cmds) with Not_found -> None + let find_posix (cmd, _args) = + Sys.command (strf "command -v %s 1>/dev/null 2>/dev/null" cmd) = 0 + in + let find = if Sys.win32 then find_win32 else find_posix in + try Some (List.find find cmds) with Not_found -> None let pp_to_pager print ppf v = let pager = @@ -505,29 +510,18 @@ let pp_to_pager print ppf v = type format = [ `Auto | `Pager | `Plain | `Groff ] let rec print - ?(errs = Format.err_formatter) - ?(subst = fun x -> None) fmt ppf page = + ?(errs = Format.err_formatter) ?(subst = fun x -> None) fmt ppf page + = match fmt with | `Pager -> pp_to_pager (print ~errs ~subst) ppf page | `Plain -> pp_plain_page ~errs subst ppf page | `Groff -> pp_groff_page ~errs subst ppf page | `Auto -> - match try (Some (Sys.getenv "TERM")) with Not_found -> None with - | None | Some "dumb" -> print ~errs ~subst `Plain ppf page - | Some _ -> print ~errs ~subst `Pager ppf page - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) + let fmt = + match Sys.getenv "TERM" with + | exception Not_found when Sys.win32 -> `Pager + | exception Not_found -> `Plain + | "dumb" -> `Plain + | _ -> `Pager + in + print ~errs ~subst fmt ppf page diff --git a/src/cmdliner_manpage.mli b/src/cmdliner_manpage.mli index d4d0849..679fcaa 100644 --- a/src/cmdliner_manpage.mli +++ b/src/cmdliner_manpage.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Manpages. @@ -82,19 +82,3 @@ val doc_to_plain : text. @raise Invalid_argument in case of illegal syntax. *) - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_msg.ml b/src/cmdliner_msg.ml index a61c815..f6bc55a 100644 --- a/src/cmdliner_msg.ml +++ b/src/cmdliner_msg.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) let strf = Printf.sprintf @@ -104,19 +104,3 @@ let pp_backtrace ppf ei e bt = in pp ppf "%s: @[internal error, uncaught exception:@\n%a@]@." (exec_name ei) pp_lines (strf "%s\n%s" (Printexc.to_string e) bt) - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_msg.mli b/src/cmdliner_msg.mli index 125e175..ff6b4f2 100644 --- a/src/cmdliner_msg.mli +++ b/src/cmdliner_msg.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Messages for the end-user. *) @@ -38,19 +38,3 @@ val pp_err_usage : val pp_backtrace : Format.formatter -> Cmdliner_info.Eval.t -> exn -> Printexc.raw_backtrace -> unit - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_term.ml b/src/cmdliner_term.ml index 13220cf..fd34e13 100644 --- a/src/cmdliner_term.ml +++ b/src/cmdliner_term.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) type term_escape = @@ -23,6 +23,14 @@ let app (args_f, f) (args_v, v) = | Error _ as e -> e | Ok v -> Ok (f v) +let map f v = app (const f) v +let product v0 v1 = app (app (const (fun x y -> (x, y))) v0) v1 + +module Syntax = struct + let ( let+ ) v f = map f v + let ( and+ ) = product +end + (* Terms *) let ( $ ) = app @@ -80,19 +88,3 @@ let with_used_args (al, v) : (_ * string list) t = let used = List.rev (Cmdliner_info.Arg.Set.fold actual_args al []) in Ok (x, used) | Error _ as e -> e - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_term.mli b/src/cmdliner_term.mli index c9b280e..66684ca 100644 --- a/src/cmdliner_term.mli +++ b/src/cmdliner_term.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Terms *) @@ -21,6 +21,14 @@ type 'a t = Cmdliner_info.Arg.Set.t * 'a parser val const : 'a -> 'a t val app : ('a -> 'b) t -> 'a t -> 'b t +val map : ('a -> 'b) -> 'a t -> 'b t +val product : 'a t -> 'b t -> ('a * 'b) t + +module Syntax : sig + val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t + val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t +end + val ( $ ) : ('a -> 'b) t -> 'a t -> 'b t type 'a ret = [ `Ok of 'a | term_escape ] @@ -33,19 +41,3 @@ val cli_parse_result' : ('a, string) result t -> 'a t val main_name : string t val choice_names : string list t val with_used_args : 'a t -> ('a * string list) t - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_term_deprecated.ml b/src/cmdliner_term_deprecated.ml index a156d3b..5f48443 100644 --- a/src/cmdliner_term_deprecated.ml +++ b/src/cmdliner_term_deprecated.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (* Term combinators *) @@ -75,19 +75,3 @@ let stdlib_exit = exit let exit ?term_err r = stdlib_exit (exit_status_of_result ?term_err r) let exit_status ?term_err r = stdlib_exit (exit_status_of_status_result ?term_err r) - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_trie.ml b/src/cmdliner_trie.ml index e7e6a7a..3444214 100644 --- a/src/cmdliner_trie.ml +++ b/src/cmdliner_trie.ml @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) module Cmap = Map.Make (Char) (* character maps. *) @@ -78,19 +78,3 @@ let ambiguities t p = (* ambiguities of [p] in [t]. *) let of_list l = let add t (s, v) = match add t s v with `New t -> t | `Replaced (_, t) -> t in List.fold_left add empty l - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/src/cmdliner_trie.mli b/src/cmdliner_trie.mli index 4b77a7f..decf409 100644 --- a/src/cmdliner_trie.mli +++ b/src/cmdliner_trie.mli @@ -1,6 +1,6 @@ (*--------------------------------------------------------------------------- Copyright (c) 2011 The cmdliner programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. + SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Tries. @@ -16,19 +16,3 @@ val add : 'a t -> string -> 'a -> [ `New of 'a t | `Replaced of 'a * 'a t ] val find : 'a t -> string -> [ `Ok of 'a | `Ambiguous | `Not_found ] val ambiguities : 'a t -> string -> string list val of_list : (string * 'a) list -> 'a t - -(*--------------------------------------------------------------------------- - Copyright (c) 2011 The cmdliner programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/test/chorus.ml b/test/chorus.ml index cbefc30..e20fa7f 100644 --- a/test/chorus.ml +++ b/test/chorus.ml @@ -28,7 +28,7 @@ let cmd = `S Manpage.s_bugs; `P "Email bug reports to <bugs@example.org>." ] in - let info = Cmd.info "chorus" ~version:"v1.2.0" ~doc ~man in + let info = Cmd.info "chorus" ~version:"v1.3.0" ~doc ~man in Cmd.v info chorus_t let main () = exit (Cmd.eval cmd) diff --git a/test/cp_ex.ml b/test/cp_ex.ml index 6a83069..81dcd43 100644 --- a/test/cp_ex.ml +++ b/test/cp_ex.ml @@ -45,7 +45,7 @@ let cmd = [ `S Manpage.s_bugs; `P "Email them to <bugs@example.org>."; ] in - let info = Cmd.info "cp" ~version:"v1.2.0" ~doc ~man ~man_xrefs in + let info = Cmd.info "cp" ~version:"v1.3.0" ~doc ~man ~man_xrefs in Cmd.v info Term.(ret (const cp $ verbose $ recurse $ force $ srcs $ dest)) diff --git a/test/darcs_ex.ml b/test/darcs_ex.ml index 2534044..71e8865 100644 --- a/test/darcs_ex.ml +++ b/test/darcs_ex.ml @@ -141,7 +141,7 @@ let help_cmd = let main_cmd = let doc = "a revision control system" in let man = help_secs in - let info = Cmd.info "darcs" ~version:"v1.2.0" ~doc ~sdocs ~man in + let info = Cmd.info "darcs" ~version:"v1.3.0" ~doc ~sdocs ~man in let default = Term.(ret (const (fun _ -> `Help (`Pager, None)) $ copts_t)) in Cmd.group info ~default [initialize_cmd; record_cmd; help_cmd] diff --git a/test/rm_ex.ml b/test/rm_ex.ml index 566869e..a7dce0a 100644 --- a/test/rm_ex.ml +++ b/test/rm_ex.ml @@ -53,7 +53,7 @@ let cmd = `S Manpage.s_bugs; `P "Report bugs to <bugs@example.org>."; `S Manpage.s_see_also; `P "$(b,rmdir)(1), $(b,unlink)(2)" ] in - let info = Cmd.info "rm" ~version:"v1.2.0" ~doc ~man in + let info = Cmd.info "rm" ~version:"v1.3.0" ~doc ~man in Cmd.v info Term.(const rm $ prompt $ recursive $ files) let main () = exit (Cmd.eval cmd) diff --git a/test/tail_ex.ml b/test/tail_ex.ml index 1010280..c04ee20 100644 --- a/test/tail_ex.ml +++ b/test/tail_ex.ml @@ -77,7 +77,7 @@ let cmd = `S Manpage.s_see_also; `P "$(b,cat)(1), $(b,head)(1)" ] in - let info = Cmd.info "tail" ~version:"v1.2.0" ~doc ~man in + let info = Cmd.info "tail" ~version:"v1.3.0" ~doc ~man in Cmd.v info Term.(const tail $ lines $ follow $ verb $ pid $ files) diff --git a/test/test_man.ml b/test/test_man.ml index e0bcc2c..4e8b087 100644 --- a/test/test_man.ml +++ b/test/test_man.ml @@ -96,6 +96,6 @@ let info = `P "Email bug reports to <hehey at example.org>.";] in let man_xrefs = [`Page ("ascii", 7); `Main; `Tool "grep";] in - Cmd.info "man_test" ~version:"v1.2.0" ~doc ~envs ~exits ~man ~man_xrefs + Cmd.info "man_test" ~version:"v1.3.0" ~doc ~envs ~exits ~man ~man_xrefs let () = exit (Cmd.eval (Cmd.v info man_test_t)) |