Next: , Previous: , Up: getopts   [Index]


16.2 Type definitions

R6RS Record Type: command-line-option

Type of records representing command line options.

Immutable Field of command-line-option: brief

A Scheme character representing a dash plus single character (brief) option selector; to specify an option with no brief selector, we can set this field to #f.

Immutable Field of command-line-option: long

A Scheme string representing a long option selector, without the double–dash prefix; to specify an option with no long selector, we can set this field to #f.

Immutable Field of command-line-option: requires-argument?

Boolean, true if this option requires an argument.

Immutable Field of command-line-option: description

Scheme string describing this option, to be used in help screens.

Immutable Field of command-line-option: action

Semantic action, a closure to be invoked when this option is found on the command line.

We have to remember that command-line-option records can be compared with eq?.

Function: make-command-line-option brief long requires-argument? description action

Build and return a new command-line-option record.

Function: command-line-option? obj

Return #t if obj is a record of type command-line-option, otherwise return #f.

Syntax: define-command-line-option ?name ?clause ...
Auxiliary Syntax: brief ?char
Auxiliary Syntax: long ?string
Auxiliary Syntax: requires-argument ?bool
Auxiliary Syntax: description ?string
Auxiliary Syntax: action ?function

Build a new command-line-option record and bind it to ?name, which must be a Scheme symbol. All the ?clause arguments must be subforms with an auxiliary syntactic keyword as first element. Example:

(define-command-line-option interactive
  (brief               #\i)
  (long                "interactive")
  (requires-argument   #f)
  (description         "ask the user first")
  (action              (lambda (option) ---)))
Function: command-line-option-brief opt
Function: command-line-option-long opt
Function: command-line-option-requires-argument? opt
Function: command-line-option-description opt
Function: command-line-option-action opt

Accessors for the fields of a command-line-option record.


Next: , Previous: , Up: getopts   [Index]