Properties

$args

$args : array

Input args data

Type

array

$binds

$binds : array

Bind an name for argument index

[ 'name1' => 0, 'name2' => 1, ]

Type

array

$sOpts

$sOpts : array

Input short-opts data

Type

array

$lOpts

$lOpts : array

Input long-opts data

Type

array

$pwd

$pwd : string

Type

string

$script

$script : string

The script path e.g `./bin/app` OR `bin/cli.php`

Type

string

$scriptName

$scriptName : string

The script name e.g `app` OR `cli.php`

Type

string

$command

$command : string

the command name(Is first argument) e.g `start` OR `start`

Type

string

$fullScript

$fullScript : string

eg `./examples/app home:useArg status=2 name=john arg0 -s=test --page=23`

Type

string

$tokens

$tokens : array

Raw argv data.

Type

array

$flags

$flags : array

Same the $tokens but no $script

Type

array

Methods

bindArgument()

bindArgument(string  $name, integer  $index) : self|mixed

Parameters

string $name
integer $index

Returns

self|mixed

bindArguments()

bindArguments(array  $map, boolean  $replace = false) 

Parameters

array $map

[ argName => index, ]

boolean $replace

getArgs()

getArgs() : array

Returns

array

getArguments()

getArguments() : array

Returns

array

setArgs()

setArgs(array  $args, boolean  $replace = false) 

Parameters

array $args
boolean $replace

hasArg()

hasArg(string|integer  $name) : boolean

Parameters

string|integer $name

Returns

boolean

getArgument()

getArgument(null|integer|string  $name, mixed  $default = null) : mixed

get Argument

Parameters

null|integer|string $name
mixed $default

Returns

mixed

getArg()

getArg(null|integer|string  $name, mixed  $default = null) : mixed

get Argument

Parameters

null|integer|string $name
mixed $default

Returns

mixed

get()

get(null|integer|string  $name, mixed  $default = null) : mixed

get Argument

Parameters

null|integer|string $name
mixed $default

Returns

mixed

getRequiredArg()

getRequiredArg(integer|string  $name, string  $errMsg = '') : mixed

Get a required argument

Parameters

integer|string $name

argument index or name

string $errMsg

Returns

mixed

getFirstArg()

getFirstArg(string  $default = '') : string

Get first argument

Parameters

string $default

Returns

string

getSecondArg()

getSecondArg(string  $default = '') : string

Get second argument

Parameters

string $default

Returns

string

getStringArg()

getStringArg(string|integer  $key, string  $default = '') : string

Get an string argument value

Parameters

string|integer $key
string $default

Returns

string

getInt()

getInt(string|integer  $key, integer  $default) : integer

Get an int argument value

Parameters

string|integer $key
integer $default

Returns

integer

getIntArg()

getIntArg(string|integer  $key, integer  $default) : integer

Get an int argument value

Parameters

string|integer $key
integer $default

Returns

integer

getArrayArg()

getArrayArg(string|integer  $key, array  $default = array()) : array

Get an array argument value

Parameters

string|integer $key
array $default

Returns

array

getSameArg()

getSameArg(array  $names, mixed  $default = null) : boolean|mixed|null

Get same args value eg: des description

$input->sameArg(['des', 'description']);

Parameters

array $names
mixed $default

Returns

boolean|mixed|null

sameArg()

sameArg(array  $names, mixed  $default = null) : mixed

Parameters

array $names
mixed $default

Returns

mixed

clearArgs()

clearArgs() 

clear args

getOpt()

getOpt(string  $name, null  $default = null) : boolean|mixed|null

get (long/short)opt value eg: -e dev --name sam

Parameters

string $name
null $default

Returns

boolean|mixed|null

getOption()

getOption(string  $name, mixed  $default = null) : mixed

Alias of the getOpt()

Parameters

string $name
mixed $default

Returns

mixed

getRequiredOpt()

getRequiredOpt(string  $name, string  $errMsg = '') : mixed

Get a required option value

Parameters

string $name
string $errMsg

Returns

mixed

getStringOpt()

getStringOpt(string  $name, string  $default = '') : string

Get an string option(long/short) value

Parameters

string $name
string $default

Returns

string

getSameStringOpt()

getSameStringOpt(array<mixed,string>  $names, string  $default = '') : string

Get an string option(long/short) value

Parameters

array<mixed,string> $names

eg ['n', 'name']

string $default

Returns

string

getIntOpt()

getIntOpt(string  $name, integer  $default) : integer

Get an int option(long/short) value

Parameters

string $name
integer $default

Returns

integer

getBoolOpt()

getBoolOpt(string  $name, boolean  $default = false) : boolean

Get (long/short)option value(bool) eg: -h --help

Parameters

string $name
boolean $default

Returns

boolean

getSameBoolOpt()

getSameBoolOpt(array<mixed,string>  $names, boolean  $default = false) : boolean

Get (long/short)option value(bool) eg: -h --help

Parameters

array<mixed,string> $names
boolean $default

Returns

boolean

boolOpt()

boolOpt(string  $name, boolean  $default = false) : boolean

Alias of the getBoolOpt()

Parameters

string $name
boolean $default

Returns

boolean

hasOpt()

hasOpt(  $name) : boolean

check option exists

Parameters

$name

Returns

boolean

getSameOpt()

getSameOpt(array  $names, mixed  $default = null) : boolean|mixed|null

Get same opts value eg: -h --help

$input->sameOpt(['h','help']);

Parameters

array $names
mixed $default

Returns

boolean|mixed|null

sameOpt()

sameOpt(array  $names, null  $default = null) : boolean|mixed|null

Alias of the getSameOpt()

Parameters

array $names
null $default

Returns

boolean|mixed|null

getOpts()

getOpts() : array

Returns

array

getOptions()

getOptions() : array

Returns

array

clearOpts()

clearOpts() 

clear (l/s)opts

sOpt()

sOpt(string  $name, null  $default = null) : mixed|null

Get short-opt value

Parameters

string $name
null $default

Returns

mixed|null

shortOpt()

shortOpt(string  $name, null  $default = null) : mixed|null

Alias of the sOpt()

Parameters

string $name
null $default

Returns

mixed|null

getShortOpt()

getShortOpt(string  $name, null  $default = null) : mixed|null

Alias of the sOpt()

Parameters

string $name
null $default

Returns

mixed|null

hasSOpt()

hasSOpt(string  $name) : boolean

Check short-opt exists

Parameters

string $name

Returns

boolean

findOneShortOpts()

findOneShortOpts(array<mixed,string>  $names) : string

Check multi short-opt exists

Parameters

array<mixed,string> $names

Returns

string

sBoolOpt()

sBoolOpt(string  $name, boolean  $default = false) : boolean

get short-opt value(bool)

Parameters

string $name
boolean $default

Returns

boolean

getShortOpts()

getShortOpts() : array

Returns

array

setSOpt()

setSOpt(string  $name, mixed  $value) 

Parameters

string $name
mixed $value

getSOpts()

getSOpts() : array

Returns

array

setSOpts()

setSOpts(array  $sOpts, boolean  $replace = false) 

Parameters

array $sOpts
boolean $replace

clearSOpts()

clearSOpts() 

clear s-opts

lOpt()

lOpt(string  $name, null  $default = null) : mixed|null

Alias of the getLongOpt()

Parameters

string $name
null $default

Returns

mixed|null

longOpt()

longOpt(string  $name, null  $default = null) : mixed|null

Alias of the getLongOpt()

Parameters

string $name
null $default

Returns

mixed|null

getLongOpt()

getLongOpt(string  $name, null  $default = null) : mixed|null

Get long-opt value

Parameters

string $name
null $default

Returns

mixed|null

hasLOpt()

hasLOpt(string  $name) : boolean

check long-opt exists

Parameters

string $name

Returns

boolean

lBoolOpt()

lBoolOpt(string  $name, boolean  $default = false) : boolean

get long-opt value(bool)

Parameters

string $name
boolean $default

Returns

boolean

getLongOpts()

getLongOpts() : array

Returns

array

setLOpt()

setLOpt(string  $name,   $value) 

Parameters

string $name
$value

getLOpts()

getLOpts() : array

Returns

array

setLOpts()

setLOpts(array  $lOpts, boolean  $replace = false) 

Parameters

array $lOpts
boolean $replace

clearLOpts()

clearLOpts() 

clear lang opts

__toString()

__toString() : string

Returns

string

toString()

toString() : string

Returns

string

getPwd()

getPwd() : string

Returns

string

getWorkDir()

getWorkDir() : string

Returns

string

setPwd()

setPwd(string  $pwd) 

Parameters

string $pwd

getScript()

getScript() : string

Returns

string

setScript()

setScript(string  $script) 

Parameters

string $script

getScriptName()

getScriptName() : string

Returns

string

getBinName()

getBinName() : string

Returns

string

getCommand()

getCommand() : string

Returns

string

setCommand()

setCommand(string  $command) 

Parameters

string $command

getFullScript()

getFullScript() : string

Returns

string

setFullScript()

setFullScript(string  $fullScript) 

Parameters

string $fullScript

getTokens()

getTokens() : array

Returns

array

setTokens()

setTokens(array  $tokens) 

Parameters

array $tokens

findCommand()

findCommand() 

find command name. it is first argument.