/usr/lib/s9fes/help/parse-optionsb is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | S9 LIB (display-usage list) ==> unspecific
(option char boolean object) ==> opt-list
(option char symbol object) ==> opt-list
(opt-char opt-list) ==> char
(opt-arg? opt-list) ==> boolean
(opt-type opt-list) ==> symbol
(opt-val opt-list) ==> object
(parse-options! list1 list2 procedure|#f) ==> list
(load-from-library "parse-optionsb.scm")
The LIST1 argument of PARSE-OPTIONS! is a list of strings
containing option groups and their arguments, if any. LIST2
is a list of lists describing the expected options. LIST2
has the following format:
(list (option opt-chr1 arg-type1 [default])
...
(option opt-chrN arg-typeN [default]))
Each OPT-CHR is a character associated with that option and
each ARG-TYPE is the type of the option. When it is a boolean,
it indicates whether the option expects an argument. When it
is a symbol, it must be one of the following:
'STRING The option may have any type of argument.
(This is in fact the same as #T.)
'INTEGER The option expects a numeric (integer) argument.
'FILE The option expects a file name. The file must
exist and must be readable by the calling program.
'COUNT The option has no argument, but specifying it
multiples times increases its value instead of
just setting it to #T.
When a default object is specified in OPTION, it constitutes
the default value of this option when it is not specified in
the LIST1 argument of PARSE-OPTIONS!.
The OPT-CHAR and OPT-TYPE procedures access the values of an
opt-list return by OPTION. OPT-ARG? checks whether an option
expects an argument. The OPT-VAL procedure returns the current
value of that option. The initial value of each option is #F.
The PARSE-OPTIONS procedure parses the options passed to it
in LIST1. Each option group (e.g.: "-abc") and argument must
be packaged in a separate string, i.e. '("-o" "file") works,
but '("-o file") probably does not. The SYS:COMMAND-LINE
procedure is typically used to supply a suitable LIST1.
Each option character in LIST1 must be prefixed with a #\-
or #\+ character. A #\- will set the value of an option to
#T, a #\+ will set it to #F. When (opt-arg? x) is true for
an option X, it will expect an argument in the subsequent
option group. The value of the option will be that string,
no matter whether the option character is preceded by #\-
or #\+ character.
When PARSE-OPTIONS detects a formal error (unknown option
character, missing argument, etc), it will invoke the given
PROCEDURE, which should print a short synopsis (a.k.a "usage").
When #F is privided in the place of the usage procedure, a
default message will be passed to ERROR. After running a
user-supplied usage procedure the program will terminate with
(sys:exit 1).
When PARSE-OPTIONS returns, it delivers a list of trailing
option groups that do not begin with a #\- or #\+ character.
The special option "--" can be used to abort option processing.
In this case, any remaining option groups will be returned,
not matter which characters they contain.
The DISPLAY-USAGE procedure prints the strings in its LIST
argument. Each member prints in an individual line. When
a non-string is found in LIST, DISPLAY-USAGE will assume it
is a null-ary usage procedure, as described above, and call
it.
(option #\o 'string) ==> (#\o string (#f))
(opt-char (option #\o 'string)) ==> #\o
(opt-arg? (option #\o 'string)) ==> #t
(opt-type (option #\o 'string)) ==> string
(opt-val (option #\o 'string)) ==> #f
(parse-options! '("-o" "file1" "file2")
`(,(option #\o #t))
#f) ==> ("file2")
|