Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

CLI task with optional parameters

Hi, Is it currently possible to implement taks which expects any number of parameters but will work even if no parameters provided?

Currently it returns 'argument must be of type array' error if no params passed and task looks like that:

public function myTaskAction(array $params)

I see the only way to store arguments['params'] in di, is that the only option?



1.1k
Accepted
answer

You can pass an empty array



6.2k
edited Jul '15

Thank you, it works.

PS. Also after asking I realized that I could wrap cli call in shell script to make task calls look more concise and set defaults there.