\Vegas\CliOptionParser

Class OptionParser

Command Line Interface (CLI) utility class.

Summary

Methods
Properties
Constants
parse()
toBoolean()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

parse()

parse( $argv)

PARSE ARGUMENTS

This command line option parser supports any combination of three types of options [single character options (-a -b or -ab or -c -d=dog or -cd dog), long options (--foo or --bar=baz or --bar baz) and arguments (arg1 arg2)] and returns a simple array.

[pfisher ~]$ php test.php --foo --bar=baz --spam eggs ["foo"] => true ["bar"] => "baz" ["spam"] => "eggs"

[pfisher ~]$ php test.php -abc foo ["a"] => true ["b"] => true ["c"] => "foo"

[pfisher ~]$ php test.php arg1 arg2 arg3 [0] => "arg1" [1] => "arg2" [2] => "arg3"

[pfisher ~]$ php test.php plain-arg --foo --bar=baz --funny="spam=eggs" --also-funny=spam=eggs \

'plain arg 2' -abc -k=value "plain arg 3" --s="original" --s='overwrite' --s [0] => "plain-arg" ["foo"] => true ["bar"] => "baz" ["funny"] => "spam=eggs" ["also-funny"]=> "spam=eggs" [1] => "plain arg 2" ["a"] => true ["b"] => true ["c"] => true ["k"] => "value" [2] => "plain arg 3" ["s"] => "overwrite"

Not supported: -cd=dog.

Parameters

$argv

toBoolean()

toBoolean( $key,  $default)

Converts string argument value to strict boolean value

Parameters

$key
$default