Skip to content

Commit 7a64c91

Browse files
committed
test: allow filtering down of examples in runner (#358)
![image](https://github.com/user-attachments/assets/ea61d26a-2e2c-445b-98f1-5b0c8562e6cc)
1 parent c6e32b6 commit 7a64c91

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/runner

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Symfony\Component\Console\Command\Command;
55
use Symfony\Component\Console\Helper\Table;
66
use Symfony\Component\Console\Input\InputArgument;
77
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Input\InputOption;
89
use Symfony\Component\Console\Output\OutputInterface;
910
use Symfony\Component\Console\SingleCommandApplication;
1011
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -20,6 +21,7 @@ require_once __DIR__ . '/vendor/autoload.php';
2021
$app = (new SingleCommandApplication('Symfony AI Example Runner'))
2122
->setDescription('Runs all Symfony AI examples in folder examples/')
2223
->addArgument('subdirectory', InputArgument::OPTIONAL, 'Subdirectory to run examples from, e.g. "anthropic" or "huggingface".')
24+
->addOption('filter', 'f', InputOption::VALUE_REQUIRED, 'Filter examples by name, e.g. "audio" or "toolcall".')
2325
->setCode(function (InputInterface $input, OutputInterface $output) {
2426
$io = new SymfonyStyle($input, $output);
2527
$io->title('Symfony AI Examples');
@@ -34,9 +36,14 @@ $app = (new SingleCommandApplication('Symfony AI Example Runner'))
3436
}
3537
}
3638

39+
$filter = '*.php';
40+
if (null !== $additionalFilter = $input->getOption('filter')) {
41+
$filter = sprintf('*%s*.php', $additionalFilter);
42+
}
43+
3744
$examples = (new Finder())
3845
->in($directory)
39-
->name('*.php')
46+
->name($filter)
4047
->exclude('vendor')
4148
->sortByName()
4249
->files();

0 commit comments

Comments
 (0)