term
, which subsumes integer, float, atom
,
it may be possible to get away cheaper (e.g., by only giving booleans).
However, it is recommended practice to always specify types: parsing
becomes more reliable and error messages will be easier to interpret.-sbar
is taken to mean -s bar
,
not -s -b -a -r
, that is, there is no clustering of flags.-s=foo
is disallowed. The rationale is that although
some command-line parsers will silently interpret this as -s =foo
,
this is very seldom what you want. To have an option argument start with’=’(very
un-recommended), say so explicitly.depth
twice: once as
-d5
and once as --iters 7
. The default when
encountering duplicated flags is to keeplast
(this
behaviour can be controlled, by ParseOption duplicated_flags).
Opts is a list of parsed options in the form Key(Value).
Dashed args not in OptsSpec are not permitted and will raise
error (see tip on how to pass unknown flags in the module description).
PositionalArgs are the remaining non-dashed args after each
flag has taken its argument (filling in true
or false
for booleans). There are no restrictions on non-dashed arguments and
they may go anywhere (although it is good practice to put them last).
Any leading arguments for the runtime (up to and including’--’)
are discarded.
opt_parse(OptsSpec, ApplArgs, Opts, PositionalArgs, [])
.
Opts is a list of parsed options in the form Key(Value),
or (with the option functor(Func)
given) in the form
Func(Key, Value). Dashed args not in OptsSpec are not
permitted and will raise error (see tip on how to pass unknown flags in
the module description).
PositionalArgs are the remaining non-dashed args after each
flag has taken its argument (filling in true
or false
for booleans). There are no restrictions on non-dashed arguments and
they may go anywhere (although it is good practice to put them last).
ParseOptions are
keepfirst, keeplast, keepall
with
the obvious meaning. Default is keeplast
.[]
or absent).
Flagless options cannot be manipulated from the command line and will
not show up in the generated help. This is useful when you have (also)
general configuration parameters in your OptsSpec, especially
if you think they one day might need to be controlled externally. See
example in the module overview.
allow_empty_flag_spec(false)
gives the more customary
behaviour of raising error on empty flags.