In a CakePHP shell, I need to use an indefinite number of arguments. For example:
cake MyShell mycommand inputFile inputFile2 inputFileN outputFile
In my case, I know for sure that should be at least 2 arguments (inputFile
and outputFile
), so the first and the last, but I don't know if there are others in between.
So, in my getOptionParser()
I have:
$parser->addSubcommand('mycommand', array(
'help' => __('This is my example command'),
'parser' => array(
'arguments' => array(
'inputFile' => array('help' => __('First input file'), 'required' => TRUE),
'outputFile' => array('help' => __('Output file'), 'required' => TRUE)
)
)
));
Now, as you can imagine, this only works if I use two arguments and only two.
I know that I could not use getOptionParser()
and manually check for $this->args
, but I would like to know if there is a better solution.
Thanks.