@Target(value=TYPE) @Retention(value=RUNTIME) @Documented public @interface Alias
This annotation is used as arguments to the Parser
annotation to
specify command aliases which provide shortcuts to other commands.
public abstract String name
If this is the same as the name of a command then this alias may not be honoured unless the parser configuration specifies that aliases override built-in commands.
public abstract String[] arguments
These may be constants such as { "foo", "--bar" }
which
would cause passing in the alias to be the same as passing in the
arguments foo
and --bar
. Alternatively these may include
positional parameters which are indicated as $N
where N
is an index starting at 1.
Where positional parameters are used then that parameter is expanded to
take in the users inputs after the alias name into account. For example
imagine an alias defined with arguments
{ "foo", "$2", "$1" }
, if the user invoked the alias as
alias a b
then the alias gets expanded and the actual command
invoked is foo b a
. In the case where a positional parameter has
no corresponding input provided it is left as-is which will usually
result in parser errors.
By default aliases may not refer to other aliases though the parser may be configured to allow this if desired. However even when allowed circular references are not permitted and will still result in a parser error.
Copyright © 2012–2017. All rights reserved.