Change arguments to options

This commit is contained in:
Oliver Davies 2018-01-11 09:03:31 +00:00
parent 9410609588
commit 6d6f5596ce

View file

@ -4,8 +4,8 @@ namespace Opdavies\GmailFilterBuilder\Console\Command;
use Opdavies\GmailFilterBuilder\Builder;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@ -21,8 +21,8 @@ class GenerateCommand extends Command
$this
->setName(self::NAME)
->setDefinition([
new InputArgument('input-file', InputArgument::OPTIONAL, 'The name of the PHP file containing your filters.', 'filters.php'),
new InputArgument('output-file', InputArgument::OPTIONAL, 'The name of the XML file to generate.', 'filters.xml')
new InputOption('input-file', null, InputOption::VALUE_OPTIONAL, 'The name of the PHP file containing your filters.', 'filters.php'),
new InputOption('output-file', null, InputOption::VALUE_OPTIONAL, 'The name of the XML file to generate.', 'filters.xml')
])
->setDescription('Generates XML for Gmail filters.')
;
@ -33,8 +33,8 @@ class GenerateCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$inputFile = $input->getArgument('input-file');
$outputFile = $input->getArgument('output-file');
$inputFile = $input->getOption('input-file');
$outputFile = $input->getOption('output-file');
if (file_exists(__DIR__.'/../../../../'.$inputFile)) {
$filters = require(__DIR__.'/../../../../'.$inputFile);