CommandParser

class ref CommandParser

Constructors

create

Creates a new parser for a given command spec.

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

Parameters

Returns


_sub

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

Parameters

Returns


Public Functions

parse

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) = seq)
: (Command box | CommandHelp box | SyntaxError val)

Parameters

Returns


Private Functions

_fullname

fun box _fullname()
: String val

Returns


_root_spec

fun box _root_spec()
: CommandSpec box

Returns


_parse_command

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

--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

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

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

Parameters

Returns


_option_with_name

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

Parameters

Returns


_option_with_short

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

Parameters

  • short: U8 val

Returns


_short_string

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

Parameters

  • c: U8 val

Returns


_help_name

fun box _help_name()
: String val

Returns