Generated output filenames should match the input filename

This commit is contained in:
Oliver Davies 2019-05-01 19:02:49 +01:00
parent 2e8e58abd0
commit 052629ff7d
2 changed files with 32 additions and 2 deletions

View file

@ -24,7 +24,7 @@ class GenerateCommand extends Command
->setName(self::NAME)
->setDefinition([
new InputOption('input-file', 'i', InputOption::VALUE_OPTIONAL, 'The name of the PHP file containing your filters.', 'filters.php'),
new InputOption('output-file', 'o', InputOption::VALUE_OPTIONAL, 'The name of the XML file to generate.', 'filters.xml'),
new InputOption('output-file', 'o', InputOption::VALUE_OPTIONAL, 'The name of the XML file to generate.'),
new InputOption('expanded', 'e', InputOption::VALUE_NONE, 'Whether to generate expanded XML.')
])
->setDescription('Generates XML for Gmail filters.')
@ -50,7 +50,10 @@ class GenerateCommand extends Command
private function outputFile(InputInterface $input): string
{
return $input->getOption('output-file') ?? getcwd() . '/filters.xml';
return $input->getOption('output-file') ?? vsprintf('%s/%s.xml', [
getcwd(),
pathinfo($input->getOption('input-file'))['filename'],
]);
}
private function filters(InputInterface $input): array