Event: onCli

This event is calling only when Skynet starts from CLI mode and when input commands are passed. You can place here code whitch must be executed when user type defined command or parameter.
In event you have access to CLI object so you can get all parameters and commands.

Access to CLI commands is offered by object:

$this->cli

Take a look at example:

/src/SkynetUser/MyListener.php
public function onCli()
{
if($this->cli->isCommand('foo'))
{
/* do something */
}
}

Code above checks for command foo exists in CLI input.

Method isCommand('COMMAND_NAME'):

$this->cli->isCommand('foo')

returns TRUE if there is command @foo typed in CLI console.
Note that argument passed here is without "-" prefix.

Access to specified command parameters is offered by method:

$this->cli->getParams('foo')

It returns array with passed arguments.
If a command gets only one argument you can access it by:

$this->cli->getParam('foo')

Example:
If you want check for command -foo passed by CLI mode and it params, e.g.:

php skynet.php -foo param1 param2

You will need to do this like this:

/src/SkynetUser/MyListener.php
public function onCli()
{
if($this->cli->isCommand('foo'))
{
$params = $this->cli->getParams('foo');
foreach($params as $param)
{
/* some code here */
}
}
}

If method onCli() returns any string then this string will be displayed in CLI mode.

Example:

/src/SkynetUser/MyListener.php
public function onCli()
{
if($this->cli->isCommand('foo'))
{
/* do something */
return 'Something was done.';
}
}
Full API Documentation is included in Skynet packages available on GitHub.