Annotation Interface Arg


@Target(FIELD) @Retention(RUNTIME) public @interface Arg
Annotates a field to represent one of the arguments in a command line interface. Used in conjunction with CommandLineArgumentParser.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    List of alternative names for this argument.
    The command line argument's default value that is used when no value for the argument has been provided.
    The command line argument name.
    boolean
    Indicates whether this is a required command line argument.
    Optionally returns usage information, which is printed when no value or an invalid value for the argument is provided.
  • Element Details

    • name

      String name
      The command line argument name. If not specified, the field name will also act as the argument name. The argument name is normalized, so a name like "outputDir" will match different variants like "--outputDir", "--outputdir", "-outputdir", and "-output-dir".
      Default:
      "$$default"
    • aliases

      String[] aliases
      List of alternative names for this argument. While name() represents this argument's "primary" name, using aliases can be used for things like shorthand versions, or backward compatibility when renaming arguments.
      Default:
      {}
    • required

      boolean required
      Indicates whether this is a required command line argument. When false, the argument is considered optional. Failing to provide the argument will result in the default value returned by defaultValue(), or null if no default value has been specified.
      Default:
      true
    • defaultValue

      String defaultValue
      The command line argument's default value that is used when no value for the argument has been provided. If a default value is specified, the argument is considered optional. If not, the argument is considered mandatory.

      Boolean flags are always considered optional, with a default value of false. Attempting to define a default value for a boolean argument will therefore be ignored.

      Default:
      "$$default"
    • usage

      String usage
      Optionally returns usage information, which is printed when no value or an invalid value for the argument is provided.
      Default:
      ""