PHP Class Commando\Command

This is merely for intellisense purposes!
Inheritance: implements ArrayAccess, implements Iterator
Afficher le fichier Open project: nategood/commando Class Usage Examples

Méthodes publiques

Свойство Type Description
$methods Valid "option" options, mapped to their aliases

Méthodes publiques

Méthode Description
__call ( string $name, array $arguments ) : Command This is the meat of Command. Any time we are operating on an individual option for command (e.g. $cmd->option()->require().
__construct ( array | null $tokens = null )
__destruct ( )
__toString ( ) : string
beepOnError ( boolean $beep = true ) : Command Terminal beep on error
current ( ) : mixed
define ( array $tokens = null ) : Command Factory style reads a little nicer
doNotTrapErrors ( ) : Command
error ( Exception $e )
getArgumentValues ( ) : array
getArguments ( ) : array
getFlagValues ( ) : array
getFlags ( ) : array
getHelp ( ) : string
getOption ( string $option ) : Option
getOptions ( ) : array
getSize ( ) : integer
hasOption ( string $option ) : boolean
isParsed ( ) : boolean Has this Command instance parsed its arguments?
key ( ) : integer
next ( )
offsetExists ( string $offset ) : boolean
offsetGet ( string $offset ) : mixed
offsetSet ( string $offset, string $value )
offsetUnset ( string $offset )
parse ( ) : void
printHelp ( )
rewind ( )
setHelp ( string $help ) : Command
setTokens ( array $cli_tokens ) : Command Rare that you would need to use this other than for testing, allows defining the cli tokens, instead of using $argv
trapErrors ( boolean $trap = true ) : Command
useDefaultHelp ( boolean $help = true )
valid ( ) : boolean

Private Methods

Méthode Description
_alias ( Option $option, string $alias ) : Option
_argument ( Option | null $option, integer $index = null ) : Option
_boolean ( Option $option, boolean $boolean = true ) : Option
_default ( Option $option, mixed $value ) : Option
_describe ( Option $option, string $description ) : Option
_file ( Option $option, boolean $require_exists = true, boolean $allow_globbing = false ) : void
_flag ( Option | null $option, string $name ) : Option
_increment ( Option $option, integer $max ) : Option
_map ( Option $option, Closure $callback ) : Option
_must ( Option $option, Closure $callback ) : Option
_needs ( Option $option, string $name ) : Option Set a requirement on an option
_option ( Option | null $option, string | integer $name = null ) : Option
_parseOption ( string $token ) : array
_require ( Option $option, boolean $require = true ) : Option
_title ( Option $option, string $title ) : Option
attachHelp ( )
dedupeFlags ( ) : array
parseIfNotParsed ( ) : void

Method Details

__call() public méthode

..) it relies on this magic method. It allows us to handle some logic that is applicable across the board and also allows easy aliasing of methods (e.g. "o" for "option")... since it is a CLI library, such minified aliases would only be fitting :-).
public __call ( string $name, array $arguments ) : Command
$name string
$arguments array
Résultat Command

__construct() public méthode

public __construct ( array | null $tokens = null )
$tokens array | null

__destruct() public méthode

public __destruct ( )

__toString() public méthode

public __toString ( ) : string
Résultat string dump values

beepOnError() public méthode

Terminal beep on error
public beepOnError ( boolean $beep = true ) : Command
$beep boolean
Résultat Command

current() public méthode

See also: Iterator
public current ( ) : mixed
Résultat mixed value of current option

define() public static méthode

Factory style reads a little nicer
public static define ( array $tokens = null ) : Command
$tokens array defaults to $argv
Résultat Command

doNotTrapErrors() public méthode

public doNotTrapErrors ( ) : Command
Résultat Command

error() public méthode

public error ( Exception $e )
$e Exception

getArgumentValues() public méthode

public getArgumentValues ( ) : array
Résultat array of argument values only If your command was `php filename -f flagvalue argument1 argument2` `getArguments` would return array("argument1", "argument2");

getArguments() public méthode

public getArguments ( ) : array
Résultat array of argument `Option` only

getFlagValues() public méthode

public getFlagValues ( ) : array
Résultat array of flag values only If your command was `php filename -f flagvalue argument1 argument2` `getFlags` would return array("-f" => "flagvalue");

getFlags() public méthode

public getFlags ( ) : array
Résultat array of flag `Option` only

getHelp() public méthode

public getHelp ( ) : string
Résultat string help docs

getOption() public méthode

public getOption ( string $option ) : Option
$option string
Résultat Option

getOptions() public méthode

public getOptions ( ) : array
Résultat array of `Option`s

getSize() public méthode

public getSize ( ) : integer
Résultat integer

hasOption() public méthode

public hasOption ( string $option ) : boolean
$option string name (named option) or index (anonymous option)
Résultat boolean

isParsed() public méthode

Has this Command instance parsed its arguments?
public isParsed ( ) : boolean
Résultat boolean

key() public méthode

See also: Iterator
public key ( ) : integer
Résultat integer

next() public méthode

See also: Iterator
public next ( )

offsetExists() public méthode

See also: ArrayAccess
public offsetExists ( string $offset ) : boolean
$offset string
Résultat boolean

offsetGet() public méthode

See also: ArrayAccess
public offsetGet ( string $offset ) : mixed
$offset string
Résultat mixed

offsetSet() public méthode

See also: ArrayAccess
public offsetSet ( string $offset, string $value )
$offset string
$value string

offsetUnset() public méthode

See also: ArrayAccess
public offsetUnset ( string $offset )
$offset string

parse() public méthode

public parse ( ) : void
Résultat void

printHelp() public méthode

public printHelp ( )

rewind() public méthode

See also: Iterator
public rewind ( )

setHelp() public méthode

public setHelp ( string $help ) : Command
$help string
Résultat Command

setTokens() public méthode

Rare that you would need to use this other than for testing, allows defining the cli tokens, instead of using $argv
public setTokens ( array $cli_tokens ) : Command
$cli_tokens array
Résultat Command

trapErrors() public méthode

public trapErrors ( boolean $trap = true ) : Command
$trap boolean when true, exceptions will be caught by Commando and printed cleanly to standard error.
Résultat Command

useDefaultHelp() public méthode

public useDefaultHelp ( boolean $help = true )
$help boolean

valid() public méthode

See also: Iterator
public valid ( ) : boolean
Résultat boolean

Property Details

$methods public_oe static_oe property

Valid "option" options, mapped to their aliases
public static $methods