Skip to content

Commit b515355

Browse files
authored
chore: extend example runner to target subdirs only (#299)
1 parent 7fd92b4 commit b515355

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

example

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use Symfony\Component\Console\Command\Command;
55
use Symfony\Component\Console\Helper\Table;
6+
use Symfony\Component\Console\Input\InputArgument;
67
use Symfony\Component\Console\Input\InputInterface;
78
use Symfony\Component\Console\Output\ConsoleOutput;
89
use Symfony\Component\Console\SingleCommandApplication;
@@ -15,12 +16,23 @@ require_once __DIR__.'/vendor/autoload.php';
1516

1617
$app = (new SingleCommandApplication('LLM Chain Example Runner'))
1718
->setDescription('Runs all LLM Chain examples in folder examples/')
19+
->addArgument('subdirectory', InputArgument::OPTIONAL, 'Subdirectory to run examples from, e.g. "anthropic" or "huggingface".')
1820
->setCode(function (InputInterface $input, ConsoleOutput $output) {
1921
$io = new SymfonyStyle($input, $output);
2022
$io->title('LLM Chain Examples');
2123

24+
$directory = __DIR__.'/examples';
25+
26+
if ($subdirectory = $input->getArgument('subdirectory')) {
27+
$directory .= '/'.$subdirectory;
28+
if (!is_dir($directory)) {
29+
$io->error(sprintf('Subdirectory "%s" does not exist.', $subdirectory));
30+
return Command::FAILURE;
31+
}
32+
}
33+
2234
$examples = (new Finder())
23-
->in(__DIR__.'/examples')
35+
->in($directory)
2436
->name('*.php')
2537
->sortByName()
2638
->files();

0 commit comments

Comments
 (0)