std/flags▲toc

Parsing of command line flags.

struct optionstd/flags/option: V -> V<a>(shortNames : stringstd/core/string: VlongNames : liststd/core/list: V -> V<stringstd/core/string: V>arg : optionArgstd/flags/optionArg: V -> V<a>help : stringstd/core/string: V)

Specifies a single option For example: Optionstd/flags/Option: forall<a> (shortNames : string, longNames : list<string>, arg : optionArg<a>, help : string) -> option<a>("h?",["help"],Flagstd/flags/Flag: forall<a> (default : a) -> optionArg<a>(Help),"show help information").

Automatically generated. Retrieves the arg constructor field of the optionstd/flags/option: V -> V type.

Automatically generated. Retrieves the help constructor field of the optionstd/flags/option: V -> V type.

Automatically generated. Retrieves the longNames constructor field of the optionstd/flags/option: V -> V type.

Automatically generated. Retrieves the shortNames constructor field of the optionstd/flags/option: V -> V type.

type optionArgstd/flags/optionArg: V -> V<a>

Specifies the argument of an option

An optional argument.

con Req(parse : (stringstd/core/string: V) -> ahelp : stringstd/core/string: V)

A required argument.

con Flag(default : a)

Boolean flag without an argument.

Automatically generated. Retrieves the default constructor field of the optionArgstd/flags/optionArg: V -> V type.

Automatically generated. Retrieves the help constructor field of the optionArgstd/flags/optionArg: V -> V type.

type optionOrderstd/flags/optionOrder: V -> V<a>

Specifies how to handle options that follow nonOption command line arguments.

con Permute

Allow options to be permuted with nonFlag arguments

Flags following nonOption arguments are treated as arguments

con Wrap(wrap : (stringstd/core/string: V) -> a)

Wrap each nonOption argument into an option

Automatically generated. Tests for the Wrap constructor of the optionOrderstd/flags/optionOrder: V -> V type.

Automatically generated. Retrieves the wrap constructor field of the optionOrderstd/flags/optionOrder: V -> V type.

fun parse( flags : liststd/core/list: V -> V<optionstd/flags/option: V -> V<a>>, args : liststd/core/list: V -> V<stringstd/core/string: V>, ordering : ?optionOrderstd/flags/optionOrder: V -> V<a> ) : totalstd/core/total: E (liststd/core/list: V -> V<a>, liststd/core/list: V -> V<stringstd/core/string: V>, liststd/core/list: V -> V<stringstd/core/string: V>)

Parse the command line arguments args (see argvstd/env/argv: vector<string>) according to the flag descriptions flags. Takes an optional argument ordering that specifies how flags are handled that follow nonFlag arguments. The default ordering is Permutestd/flags/Permute: forall<a> optionOrder<a>. Returns three lists: the list of parsed options, a list of nonOption arguments, and a list of potential error messages.

fun test( cmdargs : liststd/core/list: V -> V<stringstd/core/string: V> ) : consolestd/core/console: X ()std/core/(): V
fun usageInfo( flags : liststd/core/list: V -> V<optionstd/flags/option: V -> V<a>>, header : stringstd/core/string: V ) : stringstd/core/string: V

Return a nicely formatted string describing the usage of a command, consisting of a header followed by the descriptions of the flags.