protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
// download and extract the plugin
$this->fetch();
// check for an existing plugin with
// the same name and avoid overwriting it
if ($this->pluginExists()) {
if (!$this->confirm('The plugin is already installed. Do you want to update it?')) {
$this->cleanUp();
return;
}
} else {
if (!$this->confirm('Do you want to install this plugin?')) {
$this->cleanUp();
return;
}
}
try {
$this->move();
$this->cleanUp();
} catch (RuntimeException $e) {
// make sure to clean up even after errors
$this->cleanUp();
throw $e;
}
}