Skip to content

Commit cb44bc9

Browse files
authored
Adding argument for direction (#197)
* Adding argument for direction * cs
1 parent d08624c commit cb44bc9

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Command/SyncCommand.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Output\OutputInterface;
1818
use Translation\Bundle\Service\StorageManager;
19+
use Translation\Bundle\Service\StorageService;
1920

2021
/**
2122
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
@@ -44,12 +45,28 @@ protected function configure()
4445
$this
4546
->setName(self::$defaultName)
4647
->setDescription('Sync the translations with the remote storage')
47-
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default');
48+
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
49+
->addArgument('direction', InputArgument::OPTIONAL, 'Use "down" if local changes should be overwritten', 'down');
4850
}
4951

5052
protected function execute(InputInterface $input, OutputInterface $output)
5153
{
54+
switch ($input->getArgument('direction')) {
55+
case 'down':
56+
$direction = StorageService::DIRECTION_DOWN;
57+
58+
break;
59+
case 'up':
60+
$direction = StorageService::DIRECTION_UP;
61+
62+
break;
63+
default:
64+
$output->writeln(sprintf('Direction must be eitehr "up" or "down". Not "%s".', $input->getArgument('direction')));
65+
66+
return;
67+
}
68+
5269
$configName = $input->getArgument('configuration');
53-
$this->storageManager->getStorage($configName)->sync();
70+
$this->storageManager->getStorage($configName)->sync($direction);
5471
}
5572
}

0 commit comments

Comments
 (0)