Next: Environment Variables, Previous: Command-Line Options, Up: Running Scheme [Contents][Index]
MIT/GNU Scheme provides a mechanism for you to define your own command-line options. This is done by registering handlers to identify particular named options and to process them when Scheme starts. Unfortunately, because of the way this mechanism is implemented, you must define the options and then save a world image containing your definitions (see World Images). Later, when you start Scheme using that world image, your options will be recognized.
The following procedures define command-line parsers. In each, the argument keyword defines the option that will be recognized on the command line. The keyword must be a string containing at least one character; do not include the leading hyphens.
Defines keyword to be a simple command-line option. When this
keyword is seen on the command line, it causes thunk to be
executed. Help, when provided, should be a string describing
the option in the --help
output.
Defines keyword to be a command-line option that is followed by
one or more command-line arguments. Procedure is a procedure that
accepts one argument; when keyword is seen, it is called once for
each argument. Help, when provided, should be a string
describing the option. It is included in the --help
output.
When not provided, --help
will say something lame about your
command line option.
Multiple?, if true, says that keyword may be followed by
more than one argument on the command line. In this case, procedure is
called once for each argument that follows keyword and does not
start with a hyphen. If multiple? is #f
, procedure
is called once, with the command-line argument following keyword.
In this case, it does not matter if the following argument starts with a
hyphen.
This low-level procedure defines keyword to be a command-line
option that is defined by procedure. When keyword is seen,
procedure is called with all of the command-line arguments,
starting with keyword, as a single list argument. Procedure
must return two values (using the values
procedure): the unused
command-line arguments (as a list), and
either #f
or a thunk to invoke after the whole command line has
been parsed (and the init file loaded). Thus procedure has the option
of executing the appropriate action at parsing time, or delaying it
until after the parsing is complete. The execution of the procedures
(or their associated delayed actions) is strictly left-to-right,
with the init file loaded between the end of parsing and the
delayed actions.
Next: Environment Variables, Previous: Command-Line Options, Up: Running Scheme [Contents][Index]