Options

class ref Options is
  Iterator[((String val , (None val | String val | I64 val | F64 val)) | ParseError ref | None val)] ref

Implements


Constructors

create

new ref create(
  args: Array[String val] box,
  fatal: Bool val = seq)
: Options ref^

Parameters

Returns


Public Functions

add

Adds a new named option to the parser configuration.

fun ref add(
  long: String val,
  short: (None val | String val) = seq,
  arg: (None val | StringArgument val | I64Argument val | 
    F64Argument val) = seq,
  mode: (Required val | Optional val) = seq)
: Options ref

Parameters

Returns


remaining

Returns all unprocessed command line arguments. After parsing all options, this will only include positional arguments, potentially unrecognised and ambiguous options and invalid arguments.

fun ref remaining()
: Array[String ref] ref

Returns


has_next

Parsing options is done if either an error occurs and fatal error reporting is turned on, or if all command line arguments have been processed.

fun box has_next()
: Bool val

Returns


next

Skips all positional arguments and attemps to match named options. Returns a ParsedOption on success, a ParseError on error, or None if no named options are found.

fun ref next()
: ((String val , (None val | String val | I64 val | 
    F64 val)) | ParseError ref | None val)

Returns


Private Functions

_strip

Strips accepted options from the copied array of command line arguments.

fun ref _strip(
  opt: _Option ref,
  matched: String ref,
  start: ISize val,
  finish: ISize val)
: None val

Parameters

Returns


_select

Selects an option from the configuration depending on the current command line argument.

fun ref _select(
  candidate: String ref,
  start: ISize val,
  offset: ISize val,
  finish: ISize val)
: (_Option ref | ParseError ref)

Parameters

Returns


_skip

Skips all non-options. Returns true if a named option has been found, false otherwise.

fun ref _skip()
: Bool val

Returns


_verify

Verifies whether a parsed option from the command line is well-formed. That is, checking whether required or optional arguments are supplied. Returns a ParsedOption on success, a ParseError otherwise.

fun ref _verify(
  opt: _Option ref,
  combined: Bool val)
: ((String val , (None val | String val | I64 val | 
    F64 val)) | ParseError ref)

Parameters

Returns