From 7c1125129038fb4e1f34bf040e25bb56068bc03f Mon Sep 17 00:00:00 2001 From: Kate Date: Thu, 1 Sep 2022 15:29:06 +0100 Subject: [PATCH] Add Cmd.alias to create aliases of commands --- src/cmdliner.mli | 3 +++ src/cmdliner_cmd.ml | 4 ++++ src/cmdliner_cmd.mli | 1 + 3 files changed, 8 insertions(+) diff --git a/src/cmdliner.mli b/src/cmdliner.mli index 43622e2..7449dcd 100644 --- a/src/cmdliner.mli +++ b/src/cmdliner.mli @@ -656,6 +656,9 @@ module Cmd : sig val name : 'a t -> string (** [name c] is the name of [c]. *) + val alias : info -> 'a t -> 'a t + (** [alias i cmd] creates an alias of [cmd] with information [i] *) + (** {1:eval Evaluation} These functions are meant to be composed with {!Stdlib.exit}. diff --git a/src/cmdliner_cmd.ml b/src/cmdliner_cmd.ml index 5a156f3..ad5a306 100644 --- a/src/cmdliner_cmd.ml +++ b/src/cmdliner_cmd.ml @@ -29,6 +29,10 @@ let group ?default i cmds = let name c = Cmdliner_info.Cmd.name (get_info c) +let alias i = function +| Cmd (_, p) -> Cmd (i, p) +| Group (_, grp) -> Group (i, grp) + (*--------------------------------------------------------------------------- Copyright (c) 2022 The cmdliner programmers diff --git a/src/cmdliner_cmd.mli b/src/cmdliner_cmd.mli index 54da153..d8e265b 100644 --- a/src/cmdliner_cmd.mli +++ b/src/cmdliner_cmd.mli @@ -22,6 +22,7 @@ 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 +val alias : info -> 'a t -> 'a t (*--------------------------------------------------------------------------- Copyright (c) 2022 The cmdliner programmers