File 'base/getopt.tcl' (part of 'Pool_Base')


Home | Packages | Files | Procedures | Classes | Keywords | External packages


Written by
Andreas Kupries
Description
Option processors useable for commandline processing, evaluation of argument lists given to vararg-procedures or evaluation of widget options.
Depends on
Tcl
Keywords
option processing, commandline processing, vararg procedures, widget options

::pool::getopt::boolean (o v)

This type checker accepts only boolean values as recognized by the core function Tcl_GetBoolean.
Argument: oThe option whose value is checked.
Argument: vThe value to check.
Returns: A boolean value. True if v contained a boolean value.

::pool::getopt::changeDefault (optDef option newDefault)

Convenience procedure easing the way to change the default value of an option.
Argument: optDefThe name of the array holding the option definition.
Argument: optionThe name of the change to change.
Argument: newDefaultThe new value to use as default.

::pool::getopt::checkValues (optDef optVal)

Checks the values in the given array using the type checker procedures mentioned in the definition array.
Argument: optDefThe name of the array containing the option and alias definitions and their type checkers.
Argument: optValThe name of the array containing the values to check

::pool::getopt::defAlias (optDef alias option)

Convenience procedure helping in the setup of an array containing option and alias definitions. Shields users from the internal representation of an option/alias definition. This procedure places an alias definition into the array.
Argument: optDefThe name of the array to place the new definition into.
Argument: aliasThe name of the new alias, without a preceding '-'.
Argument: optionThe name of the option the alias refers to, without a preceding '-'.

::pool::getopt::defOption (optDef option args)

Convenience procedure helping in the setup of an array containing option and alias definitions. Shields users from the internal representation of an option/alias definition. This procedure places an option definition into the array.
Argument: optDefThe name of the array to place the new definition into.
Argument: optionThe name of the specified option, without a preceding '-'.
Argument: argsThe specification, given as <option,value>-pairs. Processed options are -type and -default.&p '-type' will accept every non-empty string and defaults to ::pool::getopt::notype. The value will be interpreted later as the name of a procedure having 2 arguments and returning a boolean value. The arguments will be the name of an option and the value given to it, in this order. A result of 'false' will be interpreted as 'The value given to the option is illegal'.&p '-default' will accept everything and defaults to the empty string.

::pool::getopt::defShortcuts (optDef)

Computes the full set of unique shortcuts for a given a set of option definitions and adds these as aliases to the array. Existing aliases are treated like options.
Argument: optDefThe name of the array to place the shortcuts into.

::pool::getopt::initValues (optDef optVal)

Initializes the given storage array with the default values of the options in the definition array.
Argument: optDefThe name of the array containing the option and alias definitions and their default values
Argument: optValThe name of the array to initalize.

::pool::getopt::integer (o v)

This type checker accepts only integer numbers.
Argument: oThe option whose value is checked.
Argument: vThe value to check.
Returns: A boolean value. True if v contained an integer.

::pool::getopt::nonempty (o v)

This type checker accepts every value different from the emtpy string/list
Argument: oThe option whose value is checked.
Argument: vThe value to check.
Returns: A boolean value. True if v was not the empty string/list.

::pool::getopt::notype (o v)

This type checker does no checking at all, it just accepts everything given to it.
Argument: oThe option whose value is checked.
Argument: vThe value to check.
Returns: Always true, signaling acceptance of the value in v.

::pool::getopt::number (o v)

This type checker accepts all numbers, it makes no distinction between integers and floats.
Argument: oThe option whose value is checked.
Argument: vThe value to check.
Returns: A boolean value. True if v contained a number.

::pool::getopt::parseArguments (optDef optList optVal)

This is the main parser procedure.
Argument: optDefThe name of the array containing the option and alias definitions to recognize here.
Argument: optListThe name of the variable containing the list of arguments to parse.
Argument: optValThe name of the array to hold the found values.

::pool::getopt::process (optDef optlist optval)

Parses optlist as a list of option-value pairs followed by normal arguments. The end of the option sequence is detected by the presence of arguments not beginning with '-' or the single option '--'. Only options and aliases defined in optDef are allowed. Values given to an alias are stored under the name of the option, *not* the alias. All values are stored in the array optval. The option-names are used as keys, including the '-'! The storage array is initialized with the default values of the allowed options. The moment all option values are known and not changing anymore the 'type' procedures are called with option-names and -values to determine the legality of the specified value. The return value 'False' signals an illegal value.
Argument: optDefThe name of the array containing the option and alias definitions to recognize.
Argument: optlistThe list of arguments to parse.
Argument: optvalThe name of the array to hold the found values.
Returns: A list containing the arguments not processed here.

::pool::getopt::processOpt (optDef optlist optval)

Basically the same functionality as ::pool::getopt::process, but with the following differences:&p The storage array is *not* initialized with the default values.&p The <optlist> must not contain arguments after the <option,value>-sequence.&p There is no return value.
Argument: optDefThe name of the array containing the option and alias definitions to recognize here.
Argument: optlistThe list of arguments to parse.
Argument: optvalThe name of the array to hold the found values.


Generated by AutoDoc 2.1 at 02/20/1999, invoked by Andreas Kupries