diff --git a/src/Openl10n/Cli/ApplicationFactory.php b/src/Openl10n/Cli/ApplicationFactory.php index ab772e0..f4f511d 100644 --- a/src/Openl10n/Cli/ApplicationFactory.php +++ b/src/Openl10n/Cli/ApplicationFactory.php @@ -46,6 +46,7 @@ protected function getDefaultCommands() new Command\InitCommand(), new Command\PullCommand(), new Command\PushCommand(), + new Command\RemoveTranslationCommand() ]; } diff --git a/src/Openl10n/Cli/Command/RemoveTranslationCommand.php b/src/Openl10n/Cli/Command/RemoveTranslationCommand.php new file mode 100644 index 0000000..41c9694 --- /dev/null +++ b/src/Openl10n/Cli/Command/RemoveTranslationCommand.php @@ -0,0 +1,53 @@ +setName('remove-translation') + ->setDescription('Removes a translation given its identifier') + ->addArgument( + 'identifier', + InputArgument::REQUIRED, + 'Translation\'s identifier you want to remove' + ) + ; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $api = $this->get('api'); + /* @var ProjectEntryPoint $projectApi */ + $projectApi = $api->getEntryPoint('project'); + /* @var TranslationEntryPoint $translationApi */ + $translationApi = $api->getEntryPoint('translation'); + + $projectSlug = $this->get('project_handler')->getProjectSlug(); + $project = $projectApi->get($projectSlug); + + $identifier = $input->getArgument('identifier'); + + $translation = $translationApi->findOneByIdentifier($project, $identifier); + if (!$translation) { + $output->writeln(sprintf('Translation "%s" does not exist', $identifier)); + } else { + $output->writeln(sprintf('Removing translation "%s"', $identifier)); + $translationApi->delete($translation); + } + } +}