Parsing command-line arguments
The option name and its arguments. e.g. ("--wrapper"; "echo"
)
read opt_name first_arg stream completion
.
Extract as many elements from the stream as this option needs.
completion
indicates when we're doing completion (so don't
raise an error if the arguments are malformed unless this is None).
When Some 0
, the next item in the stream is being completed, etc.
Takes a stream of arguments and takes as many as are needed for the option.
e.g. ["--version"; "--help"]
takes ["--version"]
and leaves ["--help"]
while ["--version"; "1.0"]
takes ["--version"; "1.0"]
and leaves []
.
cword
is the index in input_args
that we are trying to complete, or None if we're not completing.
Invoke the callback on each option. If it raises Safe_exception
, add the name of the option to the error message.
Always returns a constant value (e.g. --help becomes ShowHelp) .