System.Args

lib/System/Args.gob

A command line, read one argument at a time.

Nothing is declared ahead of time. next answers what the next argument is

type Arg = Short(Char) | Long(String) | Value(String)
type Parser
fun parser : fun(Array String) -> Parser
fun next : fun(Parser) -> Either String (Option Arg)

The next argument, Right(None) once there are none left, or Left with a message when the option before it was handed a value it did not ask for.

An attached value nobody took is an error rather than something to drop: --verbose=no silently meaning --verbose is the opposite of what was written.

fun value : fun(Parser) -> Either String String

The value of the option next just answered: what was attached to it, the rest of its cluster, or else the next argument whatever it looks like, so that -o - writes to standard output and --dump --x dumps a stage named --x. Left with a message if the command line has run out.

fun unexpected : fun(Arg) -> String

What to say about an argument the program has no use for.