@param string|null $input The input for the string.
@return int The exit code for the command.
function callback(string $input);
Any output generated to stdout will be buffered as the command's output.
Usage examples:
Get all the users in the system whose username contains at least one 'a'
$systemUsers = Command::create('cat', array('/etc/passwd'))
->pipe(
Command::create('grep', array('-v' => '^#'), array('delimiter' => ' '))
)
->pipe(
Command::create('cut', array('-d' => ':', '-f' => 1), array('delimiter' => ''))
)
->pipe($callbackCommand)
->run()
->getOutputAsArray("\n");
Mostrar archivo
Open project: ncuesta/clinner
Class Usage Examples
Method | Description | |
---|---|---|
__construct ( Closure $callback ) | Constructor. | |
getCallback ( ) : Closure | Get the callback function for this command. | |
getCallbackCode ( ) : string | Get the code of the inner callback as string. | |
getErrorOutput ( ) : string | Get the output for this command's execution. | |
getExitCode ( ) : integer | Get the exit code for this command's execution. | |
getOutput ( ) : string | Get the output for this command's execution. | |
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 ) : Clinner\Command\CommandInterface | Run this command and get the exit code for it. | |
setCallback ( Closure $callback ) : |
Set the callback function for this command. | |
toCommandString ( ) : string | Get a string representation of this command with its arguments, as if it would be written in a command-line interface when run. |
public __construct ( Closure $callback ) | ||
$callback | Closure | The callback function. |
public getCallback ( ) : Closure | ||
return | Closure |
public getCallbackCode ( ) : string | ||
return | string |
public getErrorOutput ( ) : string | ||
return | string |
public getExitCode ( ) : integer | ||
return | integer |
public getPipedCommand ( ) : Clinner\Command\PipeableCommandInterface | ||
return | Clinner\Command\PipeableCommandInterface |
public hasPipedCommand ( ) : boolean | ||
return | 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. |
return | Clinner\Command\PipingCommandInterface | This instance, for a fluent API. |
public setCallback ( Closure $callback ) : |
||
$callback | Closure | The callback function. |
return | This instance, for a fluent API. |
public toCommandString ( ) : string | ||
return | string |