From c8a689f51d6b2cd32ed28a07cd65eede18711584 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 12 Feb 2018 11:35:20 +0100 Subject: [PATCH 1/2] Adding argument for direction --- Command/SyncCommand.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Command/SyncCommand.php b/Command/SyncCommand.php index dccaf929..cbaa4cc5 100644 --- a/Command/SyncCommand.php +++ b/Command/SyncCommand.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Translation\Bundle\Service\StorageManager; +use Translation\Bundle\Service\StorageService; /** * @author Tobias Nyholm @@ -44,12 +45,26 @@ protected function configure() $this ->setName(self::$defaultName) ->setDescription('Sync the translations with the remote storage') - ->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default'); + ->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default') + ->addArgument('direction', InputArgument::OPTIONAL, 'Use "down" if local changes should be overwritten', 'down'); + } protected function execute(InputInterface $input, OutputInterface $output) { + switch ($input->getArgument('direction')) { + case 'down': + $direction = StorageService::DIRECTION_DOWN; + break; + case 'up': + $direction = StorageService::DIRECTION_UP; + break; + default: + $output->writeln(sprintf('Direction must be eitehr "up" or "down". Not "%s".', $input->getArgument('direction'))); + return; + } + $configName = $input->getArgument('configuration'); - $this->storageManager->getStorage($configName)->sync(); + $this->storageManager->getStorage($configName)->sync($direction); } } From 41a4d33e2ef2ce186565994c2d4cb77fd48c56d0 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 12 Feb 2018 11:39:08 +0100 Subject: [PATCH 2/2] cs --- Command/SyncCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Command/SyncCommand.php b/Command/SyncCommand.php index cbaa4cc5..9fc97be2 100644 --- a/Command/SyncCommand.php +++ b/Command/SyncCommand.php @@ -47,7 +47,6 @@ protected function configure() ->setDescription('Sync the translations with the remote storage') ->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default') ->addArgument('direction', InputArgument::OPTIONAL, 'Use "down" if local changes should be overwritten', 'down'); - } protected function execute(InputInterface $input, OutputInterface $output) @@ -55,12 +54,15 @@ protected function execute(InputInterface $input, OutputInterface $output) switch ($input->getArgument('direction')) { case 'down': $direction = StorageService::DIRECTION_DOWN; + break; case 'up': $direction = StorageService::DIRECTION_UP; + break; default: $output->writeln(sprintf('Direction must be eitehr "up" or "down". Not "%s".', $input->getArgument('direction'))); + return; }