- Up - |
Naturally, all examples given for list
are also valid for record
, but in order to make them appear in the resulting option record, we have to specify some additional things. This section illustrates this.
Basics
For example, with the mode
as specified earlier, the argument list --mode=dump
would result in the following option record:
optRec(1: [mode#dump])
In order to make it appear, we add the keyword single
to the specification, stating at the same time that this option can be given at most once:
mode(single
type: atom(help core outputcode
feedtoemulator dump executable))
Then the option record for --mode=dump
would look like this:
optRec(1: nil mode: dump)
Default or Required
Since the mode
gives the basic mode of operation for ozc
, we would be lost if was not given in the arguments, because it would not appear in the option record. To enforce its presence, we can either supply a default:
mode(single type: atom(
...) default: feedtoemulator)
or make it a required option:
mode(single type: atom(
...) optional: false)
Multiple Occurrences
The keyword single
stated that an option may appear at most once in the option record. For some options, this in inadequate. If we want an option to be allowed to occur multiply in the argument list, we have to specify what this means. For instance,
verbose(rightmost char: &v type: bool)
means that all but the last occurrences of verbose
are ignored. By the way, in ozc
, verbose
actually has a non-boolean default:
verbose(rightmost char: &v type: bool default: auto)
This allows for three modes of operation: The default is to only output messages if they are ``interesting''. When being --verbose
, also uninteresting messages are output, whereas being --quiet
, even the interesting messages are suppressed.
Collecting in Lists
It is also possible to state that one wished all occurrences of the same option to be collected in a list. This does not occur in ozc
, so we give a fictitious example here:
cattle(multiple type: list(atom) default: nil)
Giving this argument several times, say, --cattle=angus,belgianred
, --cattle=charolais
, and --cattle=dexter,highland
on one command line would result in the following option record:
optRec(1: nil
cattle: [angus belgianred charolais dexter highland])
- Up - |