class ref CommandParser
Creates a new parser for a given command spec.
new box create( spec': CommandSpec box) : CommandParser box^
new box _sub( spec': CommandSpec box, parent': CommandParser box) : CommandParser box^
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)
fun box _fullname() : String val
fun box _root_spec() : CommandSpec box
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)
--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)
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)
fun box _parse_arg( token: String val, arg_pos: USize val) : (Arg val | SyntaxError val)
fun box _option_with_name( name: String val) : (OptionSpec val | None val)
fun box _option_with_short( short: U8 val) : (OptionSpec val | None val)
fun tag _short_string( c: U8 val) : String val
fun box _help_name() : String val
© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/cli-CommandParser