Standard Option Parser Classes

Parse-Arguments supports the most popular types of POSIX and GNU command-line options.


<negative-option-parser>[Abstract Open Class]

Parses command-line options which may appear in positive and negative forms.

Superclasses

<option-parser>

Initialization Keywords

negative-long-options:An instance of <list>. Specifies the negative long options handled by this parser, represented as strings. Defaults to #().
negative-short-options:An instance of <list>. Specifies the negative short options handled by this parser, represented as strings. Defaults to #().

Description

This class is exported from the module option-parser-protocol. We document it here because it is the superclass of <simple-option-parser>.

Certain command-line options appear in a positive and negative form. For example, many programs accept --verbose and --quiet options.

This class provides internal support for creating parsers to handle such options. It cannot be instantiated.


<simple-option-parser>[Sealed Class]

Parses options without any parameters.

Superclasses

<negative-option-parser>

Initialization Keywords

default:An instance of <boolean>. Specifies the value returned by this option parser if no applicable options appear on the command line. Defaults to #f.

Description

Simple options have no parameters, and may appear in both positive and negative forms. When parsing a list of arguments, option-value is first set to the default. As the command line is then scanned from left to right, each positive option sets the value to #t and each negative option sets it to #f.

This behavior is consistent with that of the utility rm, which allows the user to set default options with a shell alias of the form alias rm="rm -i". Such defaults can be overriden by explicity passing a flag when calling rm because the rightmost value takes precedence.

Option Forms

-q, --quiet, -v, --verbose


<parameter-option-parser>[Sealed Class]

Parses options which have a parameter and which may appear only once.

Superclasses

<option-parser>

Initialization Keywords

None.

Description

A <parameter-option-parser> sets option-value to either #f or a <string>. If the option appears more than once on the command line, the rightmost value is used.

Option Forms

-fname, -f name, -f=name, -f = name, --file name, --file=name, --file = name


<repeated-parameter-option-parser>[Sealed Class]

Parses options which have a parameter and which may appear more than once.

Superclasses

<option-parser>

Initialization Keywords

None.

Description

A <repeated-parameter-option-parser> sets option-value to a <sequence> of strings.

Option Forms

-fname, -f name, -f=name, -f = name, --file name, --file=name, --file = name