Skip to content

Commit a0f4d42

Browse files
chore: Add working-dir option to ListToolsCommand
1 parent 3a11a36 commit a0f4d42

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/Command/ListToolsCommand.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,39 @@
77
use Symfony\Component\Console\Attribute\AsCommand;
88
use Symfony\Component\Console\Command\Command;
99
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Input\InputOption;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112

1213
#[AsCommand('list:enabled-tools', 'Lists enabled tools (in JSON).')]
1314
final class ListToolsCommand extends Command
1415
{
1516
public function __construct(
16-
private Configuration $configuration,
17+
private readonly Configuration $configuration,
1718
) {
1819
parent::__construct();
1920
}
2021

22+
protected function configure(): void
23+
{
24+
$this->addOption(
25+
'working-dir',
26+
null,
27+
InputOption::VALUE_OPTIONAL,
28+
'Working directory, relative to project root.',
29+
);
30+
}
31+
32+
protected function initialize(InputInterface $input, OutputInterface $output): void
33+
{
34+
if (null === $workingDir = $input->getOption('working-dir')) {
35+
return;
36+
}
37+
38+
\assert(\is_string($workingDir));
39+
40+
$this->configuration->setWorkingDir($workingDir);
41+
}
42+
2143
protected function execute(InputInterface $input, OutputInterface $output): int
2244
{
2345
$output->write(\json_encode(\array_keys($this->configuration->getEnabledTools()), \JSON_THROW_ON_ERROR));

0 commit comments

Comments
 (0)