OptionProcessorFactory

An OptionProcessorFactory enables a client to dynamically specify and assemble an option processor. In particular, the factory allows a client to flexibly define a particular option processor while ignoring specification and evaluation order dependency. Validation is postponed until final assembly time, at which time a [ValidationException] will be thrown in the event of incorrect or incomplete specification; otherwise, the constructed option processor provably reflects the client specification.

Author

Todd L Smith

Parameters

OptionKeyType

The type of the option.

optionKeyType

The type of option keys.

Types

Link copied to clipboard
data class Cardinality(val min: Int, val max: Int)

An optional parameter when defining an option or optionWithArgument, to indicate how many occurrences of the option are permitted/required. For more precise control, the option body can use OptionProcessor.checkEncountered during processing, or define a rule.

Link copied to clipboard
object Companion
Link copied to clipboard

A helper class to make option bodies more directly expressible.

Link copied to clipboard
data class OptionInvocationWithArgument<OptionKeyType : Enum<OptionKeyType>>(val processor: OptionProcessor<OptionKeyType>, val keyword: String, val argument: String)

A helper class to make bodies of options with arguments more directly expressible.

Functions

Link copied to clipboard

Add the default option, which is what to do with bare arguments that have no argument-requiring option preceding them.

Link copied to clipboard
fun helpOption(key: OptionKeyType, preamble: String, appendable: Appendable): Boolean

Add the default help option, bound to '-?'. After the preamble, it outputs the keywords and description for each option.

Link copied to clipboard

Declare a generic option that takes no argument.

Link copied to clipboard

Declare a generic option that takes an argument.

Link copied to clipboard
fun <C : Configuration> C.rule(ruleText: String, rule: C.() -> Boolean): Boolean

Add a rule. All rules run, in the order in which they were defined via this method. If a rule discovers an invalid combination of options and arguments, it should throw a suitable OptionProcessingException whose message text is the ruleText, which will be reported to the user.