In package com.eden.orchid.api.options

public abstract class OrchidFlag extends Object

since: v1.0.0 public abstract

Denotes a Javadoc-style command-line argument. It is important to note that Options are found by scanning the classpath and are not created by Dependency Injection, and so are not able to have dependencies injected into themselves.

Constructors

OrchidFlag(String flag, boolean isRequired, Object defaultValue) public

Initialize this Flag with its flag key, whether it is required, and if it is required its optional default value.

Parameters:
  • String flag
  • isRequired
  • Object defaultValue
OrchidFlag(String flag, boolean isRequired, boolean printValue, Object defaultValue) public

Initialize this Flag with its flag key, whether it is required, and if it is required its optional default value.

Parameters:
  • String flag
  • isRequired
  • printValue
  • Object defaultValue

Methods

String getFlag() final public

The name of the flag used on the command-line. This value should _not_ start with a dash, but options specified on the command-line _must_ begin with a dash. The value returned by this flag can be injected with an @Named- annotated parameter.

void isRequired() final public

Return true if this OrchidOption must be set before continuing with the Orchid build. If the flag is required and is not set, you may pass a default value to be used. If the default value is null, the Orchid build will fail.

void shouldPrintValue() final public

Return true if this OrchidOption must be set before continuing with the Orchid build. If the flag is required and is not set, you may pass a default value to be used. If the default value is null, the Orchid build will fail.

Object getDefaultValue() final public

If the user has not provided a value for this flag, and this flag is required, this value is used instead to get a value for this option.

String getDescription() final public

Return a description of this OrchidOption, which is displayed when listing available Options.

void optionLength() public

Return the number of arguments this OrchidOption is expecting. This number is strictly enforced, and the option will only be allowed to parse the command-line option if the number of arguments it finds exactly matches this value. For each custom option that you want to recognize, optionLength must return the number of separate pieces or tokens in the option. For example, we want to be able to use the custom option of the form -tag mytag. This option has two pieces, the -tag option itself and its value, so the optionLength method in our doclet must return 2 for the -tag option. An option can return 0 if it isn't expecting any actual command-line option, but does want to add data to the 'option' object.

Object parseFlag(String options) public

A callback for when an option on the command-line matches the optionLength or when optionLength is 0. Whatever JSONElement is returned will be available in the root JSONObject at `options.{flag}`.

Parameters:
  • String options

    the raw values found on the command line. Its length will always be exactly equal to optionLength
OrchidFlag.FlagType getFlagType() public

Flags are simple values that can only be of type String, Integer, Float, or Boolean, or String[]. Return the type that this flag represents.