std/flags documentation

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: VllongNames : liststd/core/list: V -> V<stringstd/core/string: V>)

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

Automatically generated. Retrieves the helpstd/flags/help: forall<a> (option : option<a>) -> string 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 : (a, stringstd/core/string: V) -> ahelp : stringstd/core/string: V)

A required argument.

con Flag(default : (a, boolstd/core/bool: V) -> a)

For a flag foo Automatically enables forms --no-foo and --foo=true|false.

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.

fun parse( initial : a, 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 (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 “std/env/argv”) 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 “Permute”. 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”.