This is a command abstraction which actually delegates the execution logic
to a callback function.
The function will be invoked with an input string argument, and is expected
to return an integer value representing the exit code for the command:
@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");