Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 929a7c1

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

example

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;
@@ -17,6 +18,7 @@ require_once __DIR__.'/vendor/autoload.php';
1718
$app = (new SingleCommandApplication('LLM Chain Example Runner'))
1819
->setDescription('Runs all LLM Chain examples in folder examples/')
1920
->addArgument('subdirectory', InputArgument::OPTIONAL, 'Subdirectory to run examples from, e.g. "anthropic" or "huggingface".')
21+
->addOption('filter', 'f', InputOption::VALUE_REQUIRED, 'Filter examples by name, e.g. "audio" or "toolcall".')
2022
->setCode(function (InputInterface $input, OutputInterface $output) {
2123
$io = new SymfonyStyle($input, $output);
2224
$io->title('LLM Chain Examples');
@@ -31,9 +33,14 @@ $app = (new SingleCommandApplication('LLM Chain Example Runner'))
3133
}
3234
}
3335

36+
$filter = '*.php';
37+
if (null !== $additionalFilter = $input->getOption('filter')) {
38+
$filter = sprintf('*%s*.php', $additionalFilter);
39+
}
40+
3441
$examples = (new Finder())
3542
->in($directory)
36-
->name('*.php')
43+
->name($filter)
3744
->sortByName()
3845
->files();
3946

0 commit comments

Comments
 (0)