Skip to content

Commit 0ed9dce

Browse files
committed
refactor(command): option moved to argument
1 parent 5fc7559 commit 0ed9dce

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Command/ExportCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use SchedulerBundle\SchedulerInterface;
99
use SchedulerBundle\Task\TaskInterface;
1010
use Symfony\Component\Console\Command\Command;
11+
use Symfony\Component\Console\Input\InputArgument;
1112
use Symfony\Component\Console\Input\InputInterface;
1213
use Symfony\Component\Console\Input\InputOption;
1314
use Symfony\Component\Console\Output\OutputInterface;
@@ -42,8 +43,8 @@ protected function configure(): void
4243
$this
4344
->setDescription('Export tasks to a specific format')
4445
->setDefinition([
45-
new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'The format used to export tasks', 'crontab'),
46-
new InputOption('filename', null, InputOption::VALUE_OPTIONAL, 'The name of the filename used to export tasks', 'crontab'),
46+
new InputArgument('format', InputArgument::REQUIRED, 'The format used to export tasks', 'crontab'),
47+
new InputOption('filename', null, InputOption::VALUE_OPTIONAL, 'The name of the filename used to export tasks', '/etc/cron.d'),
4748
])
4849
;
4950
}
@@ -64,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6465
}
6566

6667
$filename = $input->getOption('filename');
67-
$exporter = $this->exporterRegistry->find($input->getOption('format'));
68+
$exporter = $this->exporterRegistry->find($input->getArgument('format'));
6869

6970
$tasks->walk(function (TaskInterface $task) use ($exporter, $filename): void {
7071
$exporter->export($filename, $task);

0 commit comments

Comments
 (0)