W3cubDocs

/Pony

CommandParser

[Source]

class ref CommandParser

Constructors

create

[Source]

Creates a new parser for a given command spec.

new box create(
  spec': CommandSpec box)
: CommandParser box^

Parameters

Returns

_sub

[Source]

new box _sub(
  spec': CommandSpec box,
  parent': CommandParser box)
: CommandParser box^

Parameters

Returns

Public Functions

parse

[Source]

Parses all of the command line tokens and env vars and returns a Command, or the first SyntaxError.

fun box parse(
  argv: Array[String val] box,
  envs: (Array[String val] box | None val) = reference)
: (Command box | CommandHelp box | SyntaxError val)

Parameters

Returns

Private Functions

_fullname

[Source]

fun box _fullname()
: String val

Returns

_root_spec

[Source]

fun box _root_spec()
: CommandSpec box

Returns

_parse_command

[Source]

Parses all of the command line tokens and env vars into the given options and args maps. Returns the first SyntaxError, or the Command when OK.

fun box _parse_command(
  tokens: Array[String val] ref,
  options: HashMap[String val, Option val, HashEq[String val] val] ref,
  args: HashMap[String val, Arg val, HashEq[String val] val] ref,
  envsmap: HashMap[String val, String val, HashEq[String val] val] box,
  ostop: Bool val)
: (Command box | CommandHelp box | SyntaxError val)

Parameters

Returns

_parse_long_option

[Source]

--opt=foo => --opt has argument foo --opt foo => --opt has argument foo, iff arg is required

fun box _parse_long_option(
  token: String val,
  args: Array[String val] ref)
: (Option val | SyntaxError val)

Parameters

Returns

_parse_short_options

[Source]

if 'O' requires an argument -OFoo => -O has argument Foo -O=Foo => -O has argument Foo -O Foo => -O has argument Foo else -O=Foo => -O has argument foo -abc => options a, b, c. -abcFoo => options a, b, c. c has argument Foo iff its arg is required. -abc=Foo => options a, b, c. c has argument Foo. -abc Foo => options a, b, c. c has argument Foo iff its arg is required.

fun box _parse_short_options(
  token: String val,
  args: Array[String val] ref)
: (Array[Option val] ref | SyntaxError val)

Parameters

Returns

_parse_arg

[Source]

fun box _parse_arg(
  token: String val,
  arg_pos: USize val)
: (Arg val | SyntaxError val)

Parameters

Returns

_option_with_name

[Source]

fun box _option_with_name(
  name: String val)
: (OptionSpec val | None val)

Parameters

Returns

_option_with_short

[Source]

fun box _option_with_short(
  short: U8 val)
: (OptionSpec val | None val)

Parameters

  • short: U8 val

Returns

_short_string

[Source]

fun tag _short_string(
  c: U8 val)
: String val

Parameters

  • c: U8 val

Returns

_help_name

[Source]

fun box _help_name()
: String val

Returns

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