Customizing Parameters of an Operation in the Shell Interface

You can modify an operation's usage syntax in the shell interface. Operations can accept named or positional parameters. You can shorten a named parameter by defining an alias.

In the shell interface, an operation can accept two kinds of parameters:
  • Named parameters. Users specify each parameter as a flag (such as -aa value). Users can supply named parameters in any order relative to one another. Named parameters precede all positional parameters.
  • Positional parameters. Users supply positional parameters in a specific order, parallel to the order of parameters in the operation method signature.

Prerequisites

You have already annotated the operation's parameters with @TeaParam. You have specified the name attribute, as required.

Procedure

  1. Determine the syntax of each parameter.
    Specify that syntax as the value of the usage attribute within the @TeaParam annotation. Supply a value enumerated by AgentParamUsage.
    Value Description
    NAMED Named parameter.
    POSITIONAL Positional parameter.
    LEGACY Backward compatibility. When usage is absent, this is the default behavior.

    The usage attribute is new in release 1.2.0. In earlier releases the combination of name and alias attributes determined whether the parameter syntax was positional or named. To preserve that behavior in later releases, supply this value.

    Definition
    public String testA(
      @TeaParam(name = "aa", description = "AA parameter",
                usage = AgentParamUsage.POSTITIONAL)
        final long[] greetings)
     
    Resulting Usage
    shell> testA [12 15] 
  2. Optional. Specify a parameter alias.
    Sometimes the name of a parameter is too long to use as an option flag. You can supply a shorter flag as the value of the alias attribute within the @TeaParam annotation.

    Alias is available only for named parameters; it has no effect on positional parameters.

    Definition
    public String testB(
      @TeaParam(name = "awkwardly_long_parameter",
                description = "A parameter with a long name",
                usage = AgentParamUsage.NAMED,
                alias="bb")
        final long[] greetings) 
    Resulting Usage
    shell> testB -awkwardly_long_parameter [12 15]
    shell> testB --awkwardly_long_parameter [12 15]
    shell> testB -bb [12 15]
    shell> testB --bb [12 15]