Skip to content

Commit cfd74f3

Browse files
committed
minor #71 test: execute multiple subdirectories of examples at once (chr-hertel)
This PR was merged into the main branch. Discussion ---------- test: execute multiple subdirectories of examples at once | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | | License | MIT Cherry picking php-llm/llm-chain#378 ![image](https://github.com/user-attachments/assets/7a92af1b-f44a-48d0-b343-bbb0669ac568) Commits ------- 75a70d9 test: execute multiple subdirectories of examples at once (#378)
2 parents 7e8b3b4 + 75a70d9 commit cfd74f3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

examples/runner

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,25 @@ require_once __DIR__ . '/vendor/autoload.php';
2020
*/
2121
$app = (new SingleCommandApplication('Symfony AI Example Runner'))
2222
->setDescription('Runs all Symfony AI examples in folder examples/')
23-
->addArgument('subdirectory', InputArgument::OPTIONAL, 'Subdirectory to run examples from, e.g. "anthropic" or "huggingface".')
23+
->addArgument('subdirectories', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'List of subdirectories to run examples from, e.g. "anthropic" or "huggingface".')
2424
->addOption('filter', 'f', InputOption::VALUE_REQUIRED, 'Filter examples by name, e.g. "audio" or "toolcall".')
2525
->setCode(function (InputInterface $input, OutputInterface $output) {
2626
$io = new SymfonyStyle($input, $output);
2727
$io->title('Symfony AI Examples');
2828

29-
$directory = __DIR__;
29+
$findIn = __DIR__;
3030

31-
if ($subdirectory = $input->getArgument('subdirectory')) {
32-
$directory .= '/'.$subdirectory;
33-
if (!is_dir($directory)) {
34-
$io->error(sprintf('Subdirectory "%s" does not exist.', $subdirectory));
35-
return Command::FAILURE;
31+
if ($subdirectories = $input->getArgument('subdirectories')) {
32+
foreach ($subdirectories as $key => $subdirectory) {
33+
$directory = $findIn.'/'.$subdirectory;
34+
35+
if (!is_dir($directory)) {
36+
$io->error(sprintf('Subdirectory "%s" does not exist.', $subdirectory));
37+
}
38+
39+
$subdirectories[$key] = $directory;
3640
}
41+
$findIn = $subdirectories;
3742
}
3843

3944
$filter = '*.php';
@@ -42,7 +47,7 @@ $app = (new SingleCommandApplication('Symfony AI Example Runner'))
4247
}
4348

4449
$examples = (new Finder())
45-
->in($directory)
50+
->in($findIn)
4651
->name($filter)
4752
->exclude('vendor')
4853
->sortByName()

0 commit comments

Comments
 (0)