메소드 | 설명 | |
---|---|---|
__construct ( string $name, array | |
Constructor. | |
__toString ( ) : string | Get the string representation of this command. | |
create ( string $name, array | |
Factory method for creating new Commands and allowing to take advantage of the fluent API provided by this class. | |
fromString ( string $commandString ) : Clinner\Command\CommandInterface | Factory method for creating new Commands from their string representation, as if they were being run from the command line. If no valid commands are found, a NullCommand will be returned. | |
getArguments ( ) : |
Get the arguments for this command as a ValueHolder. | |
getErrorOutput ( ) : string | Get the error output for this command. | |
getExitCode ( ) : integer | Get the exit code for this command. | |
getName ( ) : string | Get the name of this command. | |
getOption ( string $name, mixed $default = null ) : mixed | Get a single option value for this command, optionally providing a default value for it. | |
getOptions ( ) : |
Get the options for this command as a ValueHolder. | |
getOutput ( ) : string | Get this command's output. | |
getOutputAsArray ( string $delimiter = ' ' ) : array | Get the output of this command as an array, splitting it with a given $delimiter. | |
getPipedCommand ( ) : Clinner\Command\PipeableCommandInterface | Get the command piped to this one, if any. | |
hasPipedCommand ( ) : boolean | Answer whether this command has a command piped to it. | |
pipe ( PipeableCommandInterface $anotherCommand, boolean $appendToPipe = true ) : Clinner\Command\PipingCommandInterface | Pipe $anotherCommand to this one, so that this command's output is directly sent to $anotherCommand's standard input. | |
run ( string $input = null ) : |
Run this command with the given $input. | |
setArguments ( |
Set this command's arguments as a whole. | |
setName ( string $name ) : |
Set the name of this command to $name. | |
setOption ( string $name, mixed $value ) : |
Set a single option for this command. | |
setOptions ( |
Set this command's options as a whole. | |
toCommandString ( boolean $includePiped = false ) : string | Get a string representation of this command with its arguments, as if it would be written in a command-line interface when run. |
메소드 | 설명 | |
---|---|---|
_run ( string $input ) : integer | Actually run this command and its piped commands chain, if applicable. | |
parse ( string $commandString, array $options = [] ) : Clinner\Command\CommandInterface | Parse a command from a string representation and return the resulting object. |
public __toString ( ) : string | ||
리턴 | string |
public static create ( string $name, array | |
||
$name | string | The name of the command. |
$arguments | array | |
(Optional) arguments for the command. |
$options | array | |
(Optional) options for the command. |
리턴 |
$command = Command::fromString('cat /etc/hosts | grep localhost');
Is roughly equivalent to:
$command = Command::create('cat', array('/etc/hosts'))
->pipe(Command::create('grep', array('localhost')));
public static fromString ( string $commandString ) : Clinner\Command\CommandInterface | ||
$commandString | string | The command string to parse. |
리턴 | Clinner\Command\CommandInterface |
public getArguments ( ) : |
||
리턴 |
public getErrorOutput ( ) : string | ||
리턴 | string |
public getExitCode ( ) : integer | ||
리턴 | integer |
public getOptions ( ) : |
||
리턴 |
public getOutputAsArray ( string $delimiter = ' ' ) : array | ||
$delimiter | string | The boundary string. |
리턴 | array |
public getPipedCommand ( ) : Clinner\Command\PipeableCommandInterface | ||
리턴 | Clinner\Command\PipeableCommandInterface |
public hasPipedCommand ( ) : boolean | ||
리턴 | boolean |
public pipe ( PipeableCommandInterface $anotherCommand, boolean $appendToPipe = true ) : Clinner\Command\PipingCommandInterface | ||
$anotherCommand | PipeableCommandInterface | The command to pipe. |
$appendToPipe | boolean | Whether $anotherCommand will be appended to the currently piped commands (TRUE) or if it will be added after this command, rearranging the commands pipe to include it. |
리턴 | Clinner\Command\PipingCommandInterface | This instance, for a fluent API. |
public setArguments ( |
||
$arguments | The arguments for this command. | |
리턴 | This instance, for a fluent API. |
public setOptions ( |
||
$options | The options for this command. | |
리턴 | This instance, for a fluent API. |
public toCommandString ( boolean $includePiped = false ) : string | ||
$includePiped | boolean | (Optional) indicates whether the resulting string will include any piped command to this one. Defaults to FALSE. |
리턴 | string |