Next: Environment Variables, Previous: Command-Line Options, Up: Running Scheme
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.
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.
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 a thunk that is executed to implement the behavior of the option.