PHP Класс Commando\Command

This is merely for intellisense purposes!
Наследование: implements ArrayAccess, implements Iterator
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$methods Valid "option" options, mapped to their aliases

Открытые методы

Метод Описание
__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

Приватные методы

Метод Описание
_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

Описание методов

__call() публичный Метод

..) 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
Результат Command

__construct() публичный Метод

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

__destruct() публичный Метод

public __destruct ( )

__toString() публичный Метод

public __toString ( ) : string
Результат string dump values

beepOnError() публичный Метод

Terminal beep on error
public beepOnError ( boolean $beep = true ) : Command
$beep boolean
Результат Command

current() публичный Метод

См. также: Iterator
public current ( ) : mixed
Результат mixed value of current option

define() публичный статический Метод

Factory style reads a little nicer
public static define ( array $tokens = null ) : Command
$tokens array defaults to $argv
Результат Command

doNotTrapErrors() публичный Метод

public doNotTrapErrors ( ) : Command
Результат Command

error() публичный Метод

public error ( Exception $e )
$e Exception

getArgumentValues() публичный Метод

public getArgumentValues ( ) : array
Результат array of argument values only If your command was `php filename -f flagvalue argument1 argument2` `getArguments` would return array("argument1", "argument2");

getArguments() публичный Метод

public getArguments ( ) : array
Результат array of argument `Option` only

getFlagValues() публичный Метод

public getFlagValues ( ) : array
Результат array of flag values only If your command was `php filename -f flagvalue argument1 argument2` `getFlags` would return array("-f" => "flagvalue");

getFlags() публичный Метод

public getFlags ( ) : array
Результат array of flag `Option` only

getHelp() публичный Метод

public getHelp ( ) : string
Результат string help docs

getOption() публичный Метод

public getOption ( string $option ) : Option
$option string
Результат Option

getOptions() публичный Метод

public getOptions ( ) : array
Результат array of `Option`s

getSize() публичный Метод

public getSize ( ) : integer
Результат integer

hasOption() публичный Метод

public hasOption ( string $option ) : boolean
$option string name (named option) or index (anonymous option)
Результат boolean

isParsed() публичный Метод

Has this Command instance parsed its arguments?
public isParsed ( ) : boolean
Результат boolean

key() публичный Метод

См. также: Iterator
public key ( ) : integer
Результат integer

next() публичный Метод

См. также: Iterator
public next ( )

offsetExists() публичный Метод

См. также: ArrayAccess
public offsetExists ( string $offset ) : boolean
$offset string
Результат boolean

offsetGet() публичный Метод

См. также: ArrayAccess
public offsetGet ( string $offset ) : mixed
$offset string
Результат mixed

offsetSet() публичный Метод

См. также: ArrayAccess
public offsetSet ( string $offset, string $value )
$offset string
$value string

offsetUnset() публичный Метод

См. также: ArrayAccess
public offsetUnset ( string $offset )
$offset string

parse() публичный Метод

public parse ( ) : void
Результат void

printHelp() публичный Метод

public printHelp ( )

rewind() публичный Метод

См. также: Iterator
public rewind ( )

setHelp() публичный Метод

public setHelp ( string $help ) : Command
$help string
Результат Command

setTokens() публичный Метод

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
Результат Command

trapErrors() публичный Метод

public trapErrors ( boolean $trap = true ) : Command
$trap boolean when true, exceptions will be caught by Commando and printed cleanly to standard error.
Результат Command

useDefaultHelp() публичный Метод

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

valid() публичный Метод

См. также: Iterator
public valid ( ) : boolean
Результат boolean

Описание свойств

$methods публичное статическое свойство

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