mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-01-22 12:07:32 +00:00
Generated output filenames should match the input filename
This commit is contained in:
parent
2e8e58abd0
commit
052629ff7d
|
@ -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
|
||||
|
|
|
@ -33,6 +33,33 @@ class GenerateFiltersTest extends TestCase
|
|||
$this->fs->remove([self::OUTPUT_FILENAME]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function the_output_filename_matches_the_input_name()
|
||||
{
|
||||
$this->commandTester->execute([
|
||||
'--input-file' => self::INPUT_FILENAME,
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->fs->exists('input.xml'));
|
||||
|
||||
$this->fs->remove('input.xml');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function the_output_filename_can_be_set_explicity()
|
||||
{
|
||||
$outputFilename = 'a-different-filename.xml';
|
||||
|
||||
$this->commandTester->execute([
|
||||
'--input-file' => self::INPUT_FILENAME,
|
||||
'--output-file' => $outputFilename,
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->fs->exists($outputFilename));
|
||||
|
||||
$this->fs->remove($outputFilename);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_converts_filters_from_php_to_minified_xml()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue