Interface Option<T>

Type Parameters:
T - The generic type of the Option's value.
All Superinterfaces:
org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.Clonable, Cloneable, Comparable<Operand<?>>, org.refcodes.mixin.DescriptionAccessor, org.refcodes.runtime.Diagnosable, org.refcodes.exception.ExceptionAccessor<ArgsSyntaxException>, MatchCountAccessor, Operand<T>, ParsedArgsAccessor, org.refcodes.mixin.Resetable, org.refcodes.schema.Schemable<org.refcodes.runtime.DiagnosticOptions>, Synopsisable, Term, org.refcodes.mixin.TypeAccessor<T>, org.refcodes.mixin.ValueAccessor<T>, org.refcodes.graphical.VisibleAccessor, org.refcodes.graphical.VisibleAccessor.VisibleBuilder<Term>, org.refcodes.graphical.VisibleAccessor.VisibleMutator, org.refcodes.graphical.VisibleAccessor.VisibleProperty
All Known Subinterfaces:
Property<T>
All Known Implementing Classes:
AbstractOption, AbstractProperty, ArrayOption, BooleanOption, BooleanProperty, CharOption, CharProperty, CleanFlag, ConfigOption, ConfigProperty, DaemonFlag, DebugFlag, DoubleOption, DoubleProperty, EnumOption, EnumProperty, FileOption, FileProperty, Flag, FloatOption, FloatProperty, ForceFlag, HelpFlag, InitFlag, IntOption, IntProperty, LongOption, LongProperty, QuietFlag, StringOption, StringProperty, SysInfoFlag, VerboseFlag

public interface Option<T> extends Operand<T>
An Option represents a command line option with the according option's value. An Option can be seen as a key/value(s) pair usually represented by two succeeding arguments (e.g. "--file someFile". An Option has a state which changes with each invocation of the Term.parseArgs(String[], String[], CliContext) method.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor

    org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.DescriptionAccessor

    org.refcodes.mixin.DescriptionAccessor.DescriptionBuilder<B extends org.refcodes.mixin.DescriptionAccessor.DescriptionBuilder<B>>, org.refcodes.mixin.DescriptionAccessor.DescriptionMutator, org.refcodes.mixin.DescriptionAccessor.DescriptionProperty

    Nested classes/interfaces inherited from interface org.refcodes.exception.ExceptionAccessor

    org.refcodes.exception.ExceptionAccessor.ExceptionBuilder<EXC extends Throwable,B extends org.refcodes.exception.ExceptionAccessor.ExceptionBuilder<EXC,B>>, org.refcodes.exception.ExceptionAccessor.ExceptionMutator<EXC extends Throwable>, org.refcodes.exception.ExceptionAccessor.ExceptionProperty<EXC extends Throwable>

    Nested classes/interfaces inherited from interface org.refcodes.cli.ParsedArgsAccessor

    ParsedArgsAccessor.ParsedArgsMutator, ParsedArgsAccessor.ParsedArgsProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor

    org.refcodes.mixin.TypeAccessor.TypeBuilder<T,B extends org.refcodes.mixin.TypeAccessor.TypeBuilder<T,B>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T>, org.refcodes.mixin.TypeAccessor.TypeProperty<T>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor

    org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V>, org.refcodes.mixin.ValueAccessor.ValueProperty<V>

    Nested classes/interfaces inherited from interface org.refcodes.graphical.VisibleAccessor

    org.refcodes.graphical.VisibleAccessor.VisibleBuilder<B extends org.refcodes.graphical.VisibleAccessor.VisibleBuilder<B>>, org.refcodes.graphical.VisibleAccessor.VisibleMutator, org.refcodes.graphical.VisibleAccessor.VisibleProperty
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the long-option representing an Option instance.
    Returns the short-option representing an Option instance.
    default String[]
    Produces the keywords (short and/or long options, operations, commands, whatever) with the according prefix (if any) to be considered when overall parsing the command line arguments.
    default String
    Creates the CliContext instance specific prefixed long option String from this Option by prefixing the Option's long option (as of getLongOption()) with the long option prefix (as of LongOptionPrefixAccessor.getLongOptionPrefix()).
    default String
    Creates the CliContext instance specific prefixed short option String from this Option by prefixing the Option's short option (as of getShortOption()) with the short option prefix (as of ShortOptionPrefixAccessor.getShortOptionPrefix()).
    default String
    toSpec(CliContext aCliCtx)
    Creates a specification including its arguments.
    default String
    Creates a syntax including its arguments.
    default String
    Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.

    Methods inherited from interface org.refcodes.mixin.Clonable

    clone

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface org.refcodes.mixin.DescriptionAccessor

    getDescription

    Methods inherited from interface org.refcodes.cli.Operand

    getAlias, getParsedArgs, getValue, hasValue, toSpec, toSpec, toSpec, toSpec, toUsage, toValue

    Methods inherited from interface org.refcodes.mixin.Resetable

    reset

    Methods inherited from interface org.refcodes.schema.Schemable

    toSchema

    Methods inherited from interface org.refcodes.cli.Synopsisable

    toSynopsis, toSynopsis, toSynopsis, toSynopsis

    Methods inherited from interface org.refcodes.mixin.TypeAccessor

    getType

    Methods inherited from interface org.refcodes.mixin.ValueAccessor

    getValueOr

    Methods inherited from interface org.refcodes.graphical.VisibleAccessor.VisibleBuilder

    withHide, withShow, withVisible

    Methods inherited from interface org.refcodes.graphical.VisibleAccessor.VisibleMutator

    hide, show

    Methods inherited from interface org.refcodes.graphical.VisibleAccessor.VisibleProperty

    letVisible
  • Method Details

    • getLongOption

      String getLongOption()
      Returns the long-option representing an Option instance. A long option usually is being prefixed with a double hyphen-minus "--" as defined in ArgsPrefix.POSIX_LONG_OPTION.
      Returns:
      The long-option String.
    • getShortOption

      Character getShortOption()
      Returns the short-option representing an Option instance. A short option usually is being prefixed with a single hyphen-minus "-" as defined in ArgsPrefix.POSIX_SHORT_OPTION.
      Returns:
      The short-option String.
    • toKeywords

      default String[] toKeywords(CliContext aCliCtx)
      Produces the keywords (short and/or long options, operations, commands, whatever) with the according prefix (if any) to be considered when overall parsing the command line arguments.
      Specified by:
      toKeywords in interface Operand<T>
      Parameters:
      aCliCtx - The CliContext to use when assembling the keywords.
      Returns:
      The keywords with the according prefix.
    • toShortOption

      default String toShortOption(CliContext aCliCtx)
      Creates the CliContext instance specific prefixed short option String from this Option by prefixing the Option's short option (as of getShortOption()) with the short option prefix (as of ShortOptionPrefixAccessor.getShortOptionPrefix()).
      Parameters:
      aCliCtx - The CliContext to use when assembling the short option with the according prefix.
      Returns:
      The accordingly prefixed short option String or null if there is no short option set.
    • toLongOption

      default String toLongOption(CliContext aCliCtx)
      Creates the CliContext instance specific prefixed long option String from this Option by prefixing the Option's long option (as of getLongOption()) with the long option prefix (as of LongOptionPrefixAccessor.getLongOptionPrefix()).
      Parameters:
      aCliCtx - The CliContext to use when assembling the long option with the according prefix.
      Returns:
      The accordingly prefixed long option String or null if there is no long option set.
    • toUsage

      default String toUsage(CliContext aCliCtx)
      Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.
      Specified by:
      toUsage in interface Operand<T>
      Parameters:
      aCliCtx - The CliContext to use when creating a beautiful usage text.
      Returns:
      The according usage text.
    • toSpec

      default String toSpec(CliContext aCliCtx)
      Creates a specification including its arguments.

      A specification differs from a syntax in that the specification provides the full definition not omitting any choices whereas the syntax only provides a syntactically correct variant. For example, having an option with a short option and a long option, the specification will show the short option and the long option whereas the syntax will only show either the short option or, if no short option is set, the long option.

      Specified by:
      toSpec in interface Operand<T>
      Parameters:
      aCliCtx - The CliContext to use when creating a beautiful specification text.
      Returns:
      The according specification text.
    • toSyntax

      default String toSyntax(CliContext aCliCtx)
      Creates a syntax including its arguments.

      A specification differs from a syntax in that the specification provides the full definition not omitting any choices whereas the syntax only provides a syntactically correct variant. For example, having an option with a short option and a long option, the specification will show the short option and the long option whereas the syntax will only show either the short option or, if no short option is set, the long option.

      Specified by:
      toSyntax in interface Operand<T>
      Specified by:
      toSyntax in interface Term
      Parameters:
      aCliCtx - The CLI context controlling notation and formatting
      Returns:
      The human readable command line syntax