Annotation Type Alias


  • @Target(TYPE)
    @Retention(RUNTIME)
    @Documented
    public @interface Alias
    Specifies a command alias

    This annotation is used as arguments to the Parser annotation to specify command aliases which provide shortcuts to other commands.

    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String[] arguments
      Arguments for the alias i.e.
      java.lang.String name
      Name of the alias
    • Element Detail

      • name

        java.lang.String name
        Name of the alias

        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.

        Returns:
        Name
      • arguments

        java.lang.String[] arguments
        Arguments for the alias i.e. how the alias should be expanded

        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.

        Returns:
        Arguments