Interface Option<T>
- Type Parameters:
T- The generic type of theOption's value.
- All Superinterfaces:
AliasAccessor, Clonable, Cloneable, Comparable<Operand<?>>, DescriptionAccessor, Diagnosable, ExceptionAccessor<ArgsSyntaxException>, MatchCountAccessor, Operand<T>, ParsedArgsAccessor, Resetable, Schemable<DiagnosticOptions>, Synopsisable, Term, TypeAccessor<T>, ValueAccessor<T>, VisibleAccessor, VisibleAccessor.VisibleBuilder<Term>, VisibleAccessor.VisibleMutator, 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
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 AliasAccessor
AliasAccessor.AliasBuilder<B>, AliasAccessor.AliasMutator, AliasAccessor.AliasPropertyNested classes/interfaces inherited from interface DescriptionAccessor
DescriptionAccessor.DescriptionBuilder<B>, DescriptionAccessor.DescriptionMutator, DescriptionAccessor.DescriptionPropertyNested classes/interfaces inherited from interface ExceptionAccessor
ExceptionAccessor.ExceptionBuilder<EXC,B>, ExceptionAccessor.ExceptionMutator<EXC>, ExceptionAccessor.ExceptionProperty<EXC> Nested classes/interfaces inherited from interface MatchCountAccessor
MatchCountAccessor.MatchCountBuilder<B>, MatchCountAccessor.MatchCountMutator, MatchCountAccessor.MatchCountPropertyNested classes/interfaces inherited from interface ParsedArgsAccessor
ParsedArgsAccessor.ParsedArgsMutator, ParsedArgsAccessor.ParsedArgsPropertyNested classes/interfaces inherited from interface TypeAccessor
TypeAccessor.TypeBuilder<T,B>, TypeAccessor.TypeMutator<T>, TypeAccessor.TypeProperty<T> Nested classes/interfaces inherited from interface ValueAccessor
ValueAccessor.ValueBuilder<V,B>, ValueAccessor.ValueMutator<V>, ValueAccessor.ValueProperty<V> Nested classes/interfaces inherited from interface VisibleAccessor
VisibleAccessor.VisibleBuilder<B>, VisibleAccessor.VisibleMutator, VisibleAccessor.VisibleProperty -
Method Summary
Modifier and TypeMethodDescriptionReturns the long-option representing anOptioninstance.Returns the short-option representing anOptioninstance.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.default StringtoLongOption(CliContext aCliCtx) Creates theCliContextinstance specific prefixed long optionStringfrom thisOptionby prefixing theOption's long option (as ofgetLongOption()) with the long option prefix (as ofLongOptionPrefixAccessor.getLongOptionPrefix()).default StringtoShortOption(CliContext aCliCtx) Creates theCliContextinstance specific prefixed short optionStringfrom thisOptionby prefixing theOption's short option (as ofgetShortOption()) with the short option prefix (as ofShortOptionPrefixAccessor.getShortOptionPrefix()).default StringtoSpec(CliContext aCliCtx) Creates a specification including its arguments.default StringtoSyntax(CliContext aCliCtx) Creates a syntax including its arguments.default StringtoUsage(CliContext aCliCtx) Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.Methods inherited from interface Comparable
compareToMethods inherited from interface DescriptionAccessor
getDescriptionMethods inherited from interface Operand
getAlias, getParsedArgs, getValue, hasValue, toSpec, toSpec, toSpec, toSpec, toUsage, toValueMethods inherited from interface Synopsisable
toSynopsis, toSynopsis, toSynopsis, toSynopsisMethods inherited from interface Term
argsParser, getException, getMatchCount, isVisible, parseArgs, parseArgs, setVisible, toSynopsis, toSyntax, toSyntax, toSyntax, toSyntaxMethods inherited from interface TypeAccessor
getTypeMethods inherited from interface ValueAccessor
getValueOrMethods inherited from interface VisibleAccessor
isHiddenMethods inherited from interface VisibleAccessor.VisibleBuilder
withHide, withShow, withVisibleMethods inherited from interface VisibleAccessor.VisibleMutator
hide, showMethods inherited from interface VisibleAccessor.VisibleProperty
letVisible
-
Method Details
-
getLongOption
String getLongOption()Returns the long-option representing anOptioninstance. A long option usually is being prefixed with a double hyphen-minus "--" as defined inArgsPrefix.POSIX_LONG_OPTION.- Returns:
- The long-option
String.
-
getShortOption
Character getShortOption()Returns the short-option representing anOptioninstance. A short option usually is being prefixed with a single hyphen-minus "-" as defined inArgsPrefix.POSIX_SHORT_OPTION.- Returns:
- The short-option
String.
-
toKeywords
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:
toKeywordsin interfaceOperand<T>- Parameters:
aCliCtx- TheCliContextto use when assembling the keywords.- Returns:
- The keywords with the according prefix.
-
toShortOption
Creates theCliContextinstance specific prefixed short optionStringfrom thisOptionby prefixing theOption's short option (as ofgetShortOption()) with the short option prefix (as ofShortOptionPrefixAccessor.getShortOptionPrefix()).- Parameters:
aCliCtx- TheCliContextto use when assembling the short option with the according prefix.- Returns:
- The accordingly prefixed short option
Stringornullif there is no short option set.
-
toLongOption
Creates theCliContextinstance specific prefixed long optionStringfrom thisOptionby prefixing theOption's long option (as ofgetLongOption()) with the long option prefix (as ofLongOptionPrefixAccessor.getLongOptionPrefix()).- Parameters:
aCliCtx- TheCliContextto use when assembling the long option with the according prefix.- Returns:
- The accordingly prefixed long option
Stringornullif there is no long option set.
-
toUsage
Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.- Specified by:
toUsagein interfaceOperand<T>- Parameters:
aCliCtx- TheCliContextto use when creating a beautiful usage text.- Returns:
- The according usage text.
-
toSpec
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:
toSpecin interfaceOperand<T>- Parameters:
aCliCtx- TheCliContextto use when creating a beautiful specification text.- Returns:
- The according specification text.
-
toSyntax
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.
-