Skip to content

Commit

Permalink
Merge pull request #12 from Toflar/feature/cleanuptx-command
Browse files Browse the repository at this point in the history
Added cleanup-tx command for purging the .tx folder from within the toolbox.
  • Loading branch information
discordier committed Mar 11, 2014
2 parents 3fd4a00 + 392f1bc commit d0b0a19
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ The Contao Toolbox currently provides the following commands:
Update Contao language files from xliff translations.
* `to-xliff`
Update xliff translations from Contao base language.
* `cleanup-tx`
Purges the defined .tx folder.

### The `help` command.
Display information about a certain command.
Expand Down Expand Up @@ -113,7 +115,7 @@ If we have the extension acme-core and are within the contao core root directory
##### --xliff (-x)
Xliff root directory (base to "en","de" etc.), if empty it will get read from the composer.json.
This can be any path where the xlf files shall be stored locally. Note that this tool will create a subdirectory
for every language in use.
for every language in use. Use the command `cleanup-tx` to quickly clean up this folder right from the command line.

This value will get read from the key `extra/contao/transifex/languages_tx` in composer.json if omitted.

Expand Down Expand Up @@ -254,6 +256,9 @@ user@host:~/some/project$ ctb.phar upload-transifex
# Download new translation strings from transifex.
user@host:~/some/project$ ctb.phar download-transifex -m translated
# Finally convert all received xlf files back to php files in their corresponding location.
# Convert all received xlf files back to php files in their corresponding location.
user@host:~/some/project$ ctb.phar from-xliff
# Finally clean up the ".tx" folder
user@host:~/some/project$ ctb.phar cleanup-tx
```
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"require": {
"php": ">=5.3.3",
"symfony/console": "2.*",
"guzzle/guzzle": "~3.1"
"guzzle/guzzle": "~3.1",
"symfony/finder": "2.*",
"symfony/filesystem": "2.*"
},
"require-dev": {
"symfony/finder": "2.*",
"symfony/process": "2.*"
},
"autoload": {
Expand Down
37 changes: 37 additions & 0 deletions src/CyberSpectrum/Command/CleanUpTx.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace CyberSpectrum\Command;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

class CleanUpTx extends CommandBase
{
protected function configure()
{
parent::configure();

$this->setName('cleanup-tx');
$this->setDescription('Purges the defined .tx folder.');
$this->setHelp('Purges the defined .tx folder. You can use this little helper command to quickly start from zero again.' . PHP_EOL);
}

protected function getLanguageBasePath()
{
return $this->txlang;
}

protected function isNotFileToSkip($basename)
{
return true;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = new Finder();
$fs = new Filesystem();
$fs->remove($finder->directories()->in($this->getLanguageBasePath()));
}
}
2 changes: 2 additions & 0 deletions src/CyberSpectrum/ToolBoxApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace CyberSpectrum;

use CyberSpectrum\Command\CleanUpTx;
use Symfony\Component\Console;
use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Command\HelpCommand;
Expand All @@ -29,6 +30,7 @@ protected function getDefaultCommands()
new ConvertToXliff(),
new DownloadTransifex(),
new UploadTransifex(),
new CleanUpTx(),
new HelpCommand(),
new ListCommand(),
);
Expand Down

0 comments on commit d0b0a19

Please sign in to comment.