_Tcl::select_option(array options, string choice, ?string type?) ^

Given an array of strings in 'options', and the specified choice, return the option specified in options that matches choice, either exactly, or with an initial, unambiguous match. If no match is possible, or more than one option matches, throw an error.

If 'type' is specified, it is used to generate the error message. Defaults to 'option'.

hash options = _Tcl::select_switches(array switches, array argv, ?endswitch:0?, ?catchbad:0?, ?name: 'switch'?) ^

Given an array of valid switches, and an argv array (which should begin with possible switches and be followed by the remaining args), return a hash containing the names of the switches as keys, with the assigned values as values.

If ?endswitch? is specified as a true value, then "--" is treated as an end of switch marker. The default is to not treat "--" specially.

Any options that are matched are removed from the argv array, simplifying work for the caller.

The 'switches' array contains a list of all valid switches. For example, if "-foo" is a valid boolean switch, then the string "foo" should appear in the array. If the switch takes a parameter, then specify it as "foo:s".

If 'catchbad' is specified with a true value, then an exception is thrown if a bad switch is specified.

The 'name' parameter is only used if catchbad is true : if set, it is used to customize the error message slightly.


parrot