I'm using Cakephp 3.2, which is awesome!
I have a shell script is very politely asking if I want to overwrite my files -I'm worried the shell won't complete its intended outcome when run as a cron job.
#example of current shell output
File 'webroot/example.json' exists
Do you want to overwrite? (y/n/a/q)
The docs say: "If the shell’s interactive property is false, no question will be asked and the file will simply be overwritten." (http://book.cakephp.org/3.0/en/console-and-shells.html#creating-files) This seems to suggest that any shell can alter the "interactive" property but I haven't found a way to do that.
I could probably change this to false (http://api.cakephp.org/3.2/source-class-Cake.Console.Shell.html#84), but I think that would affect all shells, no thank you.
Example Code:
class ExampleShell extends Shell {
public function initialize() {
parent::initialize();
}
public function main() {
$array = [1,2,3];
$this->createFile('webroot/example.json', json_encode($array)); //this file already exists
}
}
?>
tl;dr
Please let me know how I can make a single shell script's interactive property set to false so that it won't require a user to allow files to be overwritten. Please provide a code sample if possible, solution must not be applied globally.
Thank you.