/** * Execute command * * @param InputInterface $input * @param OutputInterface $output * @return int * @throws Exception */ public function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); try { $hooksDir = $this->getHooksDir($this->askProjectDir($input, $output)); $files = $this->getTargetFiles(); $status = $this->removeHookFiles($hooksDir, $files); } catch (Exception $e) { if ($this->isVeryVerbose()) { throw $e; } else { $output->writeln($e->getMessage()); return 1; } } if ($status) { if ($this->isVerbose()) { $output->writeln("Existed CommitHook file(s) has been removed from '{$hooksDir}'."); } else { $output->writeln('Existed CommitHook file(s) has been removed.'); } } else { $output->writeln('No CommitHook file(s) to remove.'); } return 0; }
/** * Init input definitions * * @return $this */ protected function configureInput() { parent::configureInput(); $this->addOption('overwrite', '-w', InputOption::VALUE_NONE, 'Overwrite exist hook files.'); $this->addOption('php-binary', '-p', InputOption::VALUE_REQUIRED, 'Path to PHP binary file.'); return $this; }