suitcase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

opts.3tcl (1744B)


      1 .Dd Oct 13, 2022
      2 .Dt opts 3tcl
      3 .Os
      4 .Sh Name
      5 .Nm opts
      6 .Nd pseudo-getopts routine ripped from UmbrellixSSG
      7 .Sh Synopsis
      8 [list [list [list len=1+]] [list string]]
      9 .Nm opts
     10 \fIlist options\fR
     11 \fIlist argv\fR
     12 
     13 Both arguments are mandatory.
     14 .Sh Description
     15 The 
     16 .Nm
     17 routine takes two arguments, both lists, and returns a list of: a list of lists of 1 or more strings, and a list of strings.
     18 
     19 The first argument is a list containing the letter or name of a flag, optionally followed by one or more colons. A letter can then be flagged up with a single dash, followed by the letter (or multiple letters), in the argv input. A name flag can be flagged up with two dashes, followed by the name. Each flag will consume a non-option argument per colon, unless it was preceded with a backslash that was correctly quoted into the string, in which case, the colon becomes part of the option and doesn't consume an element. Two dashes terminates further option parsing. I don't know if that is consumed by a flag with a colon, but I assume it would be. A flag that consumes a non-option argument must consume a non-option argument.
     20 
     21 The first list in the return value is a list of lists each containing one or more strings. These represent arguments which were consumed by the function. The first value is the flag, and the second and onward values, if any, are the non-option arguments that were consumed.
     22 
     23 The second list is non-option arguments that weren't consumed, and single-letter flags that were consumed but weren't recognised. I am open to comments as to whether this behavior is a bug - see link below - but I happen to believe it is not a bug. I will change it if I get enough (friendly, please!) hatemail.
     24 .Lk https://umbrellix.net./contact.html