Options
Arguments have plenty of options to customize their behavior. All of these options can be set in either an Argument instance, or in the ArgumentBuilder when creating an argument.
- Names
The name or names (aka aliases) that the argument can be referred to by. Single character names can be used in argument name lists (e.g.
-abc), each alphabetic character being an argument name, that is,-a-b-c.- Type
An argument type that will be used to parse the user input into a value for this argument.
- Default value
Sets a value to use when the user does not provide one.
Argument.create(new IntegerArgumentType(), "number") .defaultValue(10);- Required
Marks the argument as required. If the user does not provide a value for this argument, an error will be thrown by Lanat indicating that the argument is missing.
By default, arguments are not required.
- Positional
Marks the argument as a positional argument. Positional arguments are arguments that do not need to have a name specified when being used. That is, the user can directly provide the value for the argument without specifying the argument's name.
@Argument.Define(positional = true) public int number;myCommand 123 # or myCommand --number 123- Unique
Specifies that this argument has priority over other arguments, even if they are required. This means that if an argument in a command is set as required, but one argument with unique was used, then the unused required argument will not throw an error.
As an example, arguments like
--helpor--versionare usually marked as unique, since they are expected to be used alone and not with other arguments. It also doesn't matter if some other required arguments are not provided.- Prefix
The prefix is the character that precedes the argument's name in the command line input. It must be a value defined in the
Argument.PrefixCharenum.Argument.create(new IntegerArgumentType(), "number") .prefix(Argument.PrefixChar.SLASH);myCommand /number 123- Visible
Makes the argument visible or hidden in the help message. By default, arguments are visible.
- Description
A description of the argument. This is used in the help message to describe what the argument does.
- Representation Color
The color of the argument's representation in the help message. This is used to visually differentiate the argument from others. The value is a
Color. BothTrueColorandSimpleColorare available from the terminal text formatter library.Argument.create(new IntegerArgumentType(), "number") .representationColor(TrueColor.of(0xeffd12));