๐ฎ Parameter name
Available Since 0.0.37
Table of content:
Introduction
The parameter name feature is available since 0.0.37 and allows you to set the name of a parameter in a command for more readability. The syntax is as follows <name: parser> name as the parameter name and parser as the argument parser keyword. It is recommended to use the @Param annotation to set the name of a parameter in a command.
Usage
Here is an example of using the parameter name feature
As you can see in the example above, we use the @Param annotation to set the name of the parameter. And we declare the parameter name in the @SubCommand annotation by using the following syntax <name: parser> we could also work with the old syntax when it just a parser keyword for example
And it will work as well like it did before. We could also combine the old syntax with the new one as follows
Notes
The parameter name will throw an exception if there is duplicate parameter names in the same command. Also the parameter name work with the new command lexer so if you want to change the syntax have a look there.
Advantages ๐ก
Improved Readability ๐: The parameter name feature provides a clear and descriptive name for each parameter, making the command structure more readable and self-explanatory.
Improved Maintainability ๐: By using the parameter name feature, you can easily identify the purpose and type of each parameter, reducing the need for additional comments or documentation, and you can move parameters around in
@SubCommandwithout having to update the method itself.