W3cubDocs

/Pony

Options

[Source]

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

Implements

Constructors

create

[Source]

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

Parameters

Returns

Public Functions

add

[Source]

Adds a new named option to the parser configuration.

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

Parameters

Returns

remaining

[Source]

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

[Source]

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

[Source]

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 | 
    U64 val | F64 val)) | ParseError ref | None val)

Returns

Private Functions

_strip

[Source]

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

[Source]

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

[Source]

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

fun ref _skip()
: Bool val

Returns

_verify

[Source]

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 | 
    U64 val | F64 val)) | ParseError ref)

Parameters

Returns

© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/options-Options